Re: Problem with an "optional" parameter...
- From: "Ken Snell [MVP]" <kthsneisllis9@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 7 Oct 2005 10:48:16 -0400
Your expectation is correct... if you pass parm2 a value of False, it will
use that instead of its default value of True. Thus, I suggest that you look
more carefully at your code to confirm that you indeed are passing a False
value when you think you are, and that the function isn't changing the value
of parm2 before you test it.
--
Ken Snell
<MS ACCESS MVP>
"Brad Pears" <donotreply@xxxxxxxxxxx> wrote in message
news:%23AMFyj0yFHA.2540@xxxxxxxxxxxxxxxxxxxxxxx
>I have a function that includes an "optional" boolean parameter as the 2nd
>(and last) parameter.
>
> In one particular location, I am executing the function and have passed it
> a "false" value. In every other instance where this function is executed -
> I am not even passing the optional parameter because I want the value to
> be "true".
>
> I coded the function as follows...
>
> Function TestFunc(parm1 as string, optional parm2 as boolean = true)
> ...
> if parm2 then
> some code
> else
> some code
> endif
> ...
> end function
>
> What is happening is that even when I pass a "false" value to this
> optional parameter, it is using the "true" value. I anticipated that the
> "true" value would only be used when no "optional" parameter was passed
> and that when a value of "false" is passed, it would use that. Is this not
> the case?
>
> Am I going to have to modify ever line of code where this function is
> executed (tons of places) to pass a value of either "true" or "false" to
> resolve it? (thus removing the "optional" parameter and replacing with a
> requried parameter)
>
> Thanks,
>
> Brad
>
.
- Prev by Date: Re: Problem with an "optional" parameter...
- Next by Date: Re: Knowledge Base Help Not working
- Previous by thread: Re: Problem with an "optional" parameter...
- Next by thread: Re: Problem with an "optional" parameter...
- Index(es):