RE: Check function parameters for null Values

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



strReturn = mytest1(Nz([Forms]![frm_Price_Scenario]![cb_Product_1],""), _
& Nz([Forms]![frm_Price_Scenario]![cb_SourcePlant_1],""))

Function mytest1(a As string, b As String) As String

mytest1 = IIf(a="" or b="","Null", "Ok")

End Function

"Bruce" wrote:

> I have written a function to dosomething and return the value to a text box
> on my form. I want to pass 2 parameters from my form, i.e. cb_Product_1 and
> cb_Product_2 but only if they are not null.
>
> The following example in mytest1 worksbut requires hard coding the controls
> in the code. I really need to specify parameters like in the second example
> myTest2, but it gives me #error if I enter =
> mytest2([cb_Product_1],[cb_SourcePlant_1]) as the formula in my textbox if
> one or both of the parameters is null. When the statement is false (i.e. No
> nulls), then it returns "Ok" which it should.
>
> Why does mytest2 generate an error when the if statment is true?
>
> Bruce....
>
>
> Function mytest1()
>
> a = [Forms]![frm_Price_Scenario]![cb_Product_1]
> b = [Forms]![frm_Price_Scenario]![cb_SourcePlant_1]
>
> If Nz(a) = "" Or Nz(b) = "" Then
> mytest1 = ("Null")
> Else
> mytest1 = ("Ok")
> End If
>
> End Function
>
>
>
>
> Function mytest2(a As String, b As Integer)
>
> If Nz(a) = "" Or Nz(b) = "" Then
> mytest2 = ("Null")
> Else
> mytest2 = ("Ok")
> End If
>
> End Function
.



Relevant Pages

  • RE: Check function parameters for null Values
    ... "Einar" wrote: ... >> The following example in mytest1 worksbut requires hard coding the controls ... I really need to specify parameters like in the second example ... >> Function mytest2(a As String, ...
    (microsoft.public.access.modulesdaovba)
  • RE: Check function parameters for null Values
    ... expected (normally generates Runtime Error 94). ... > The following example in mytest1 worksbut requires hard coding the controls ... I really need to specify parameters like in the second example ... > Function mytest2(a As String, ...
    (microsoft.public.access.modulesdaovba)
  • Re: aus der LinkedList auslesen
    ... public void doSomething(){ ... Wie auch oben gezeigt arbeite lieber mit Methoden, ... List liste = new ArrayList; ... String s = reader.readLine; ...
    (de.comp.lang.java)
  • Re: methods without sideeffects (proposal)
    ... In V2 you add the NoSideEffect() attribute. ... so the code that called it shouldn't compile any longer because it ... > method has no side effects on the string class instance but it does have ... > that V1 of your product has a class A with method called DoSomething(). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Populating CString in Win32 dll interface that accepts LPCTSTR
    ... I missed that OP said "populated" and was fooled by the LPCTSTR which caused me to assume he was passing the string into the function. ... But the OP wanted the string to be "populated" by the DLL. ... bool Something ... #define DoSomething DoSomethingW ...
    (microsoft.public.vc.mfc)