[AccessD] Checking for Optional Parameters
Bill Benson
bensonforums at gmail.com
Wed Jan 25 02:45:49 CST 2023
I agree IsMissing is the correct vba function to call. I rarely use params
that way anymore because it often forces me to usr another variable inside
the called routine, test for isMissing(paramX) then assign something to the
internal variable. Also, isMissing only works for variants if I am not
mistaken (and maybe I am) so that makes me cast the type to what the
internal routine needs to work with. Instead I try to declare a true/false
variable and give it an optional variable in the declaration statement.
Function MyFunc (param1 as string, optional blnparam2 as Boolean =False,
optional strParam as string=“” )
On Tue, Jan 24, 2023 at 8:05 AM Jim Dettman via AccessD <
accessd at databaseadvisors.com> wrote:
>
> Is Missing:
>
>
> https://learn.microsoft.com/en-us/office/vba/language/reference/user-interfa
> ce-help/ismissing-function
> <https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/ismissing-function>
>
> Jim.
>
> -----Original Message-----
> From: AccessD On Behalf Of Arthur Fuller
> Sent: Tuesday, January 24, 2023 7:47 AM
> To: Access Developers discussion and problem solving
> <accessd at databaseadvisors.com>
> Subject: [AccessD] Checking for Optional Parameters
>
> I keep forgetting which check to use to determine whether or not an
> optional parameter was passed to a function.
>
> <code>
> Function myFunc( Optional d as Date ) as <whatever>
> 'is it:
> If IsMissing( d) or
> If IsNull(d) or ?
> </code>
>
> Side question: As a matter of coding style, do you use named parameters in
> your own functions (i.e. as in, say, a call to MsgBox, which gives you that
> prompt that walks you through the syntax as you type)?
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
More information about the AccessD
mailing list