Results 1 to 2 of 2
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Detecting the absence of optional function argumen (2000)

    How do you detect if an optional argument has not been passed to a

    function? If you put a breakpoint at the line
    <font color=red>If IsNull(lp1) Then</font color=red>
    in the Qx function in Module1 of the attached mdb and then select,

    e.g., March 8, 2003 in the calendar on the startup form, you can see

    that, since neither of the two optional arguments are passed to the

    function upon calling it through the control source of the PORT1 text b

    ox (which is on either the Gruppo 2 or Gruppo 3 page of the tab

    control), intellisense labels them both as "Missing" and IsNull(lp1) returns false. How can I trap

    these missing optional values? I've tried using <font color=red>Isempty(lp1)</font color=red> instead but it still returns false.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Detecting the absence of optional function argumen (2000)

    How you test for an optional argument depends on the data type and any default value you have declared for that argument. With variants you have to test for missing arguments as well as for Null. With strings, you get an empty string ("") if no argument was passed. With numeric types, you get a zero.

    Since you haven't declared the data type of the variables lp1 and lp2, they default to variants, which can be either null (if a null is passed) or missing if nothing is passed. Neither value is useful to you in this routine, so you need to test for both. You aren't using lp2 for anything in the routine, so I can't suggest handling for it, but you can change your test for lp1 to this:

    <code>If IsNull(lp1) Or IsMissing(lp1) Then</code>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •