Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2002
    Location
    MA
    Posts
    24

    Question Unanswered: dateadd function

    Hello everyone.

    Here is my question. Ive added the following "=DateAdd("m",+[lngMntcIntv],[dtmMntcLast])" to the record source of a text box on a form. Where lngMntcIntv=x months and dtmMntcLast= x date.

    The function works great except when the dtmMntcLast field is empty. In these situations, it displays "#Error".

    Can something be done to display something else or nothing at all?

    thanks in adavance!

    Tim

  2. #2
    Join Date
    Aug 2002
    Location
    Québec, Canada
    Posts
    109
    You can use the IsNull() function or the Nz() function to test the validity of your variable. You can then do nothing, show an error message or add 0 months

    JefB

  3. #3
    Join Date
    Sep 2002
    Location
    MA
    Posts
    24
    Thanks JefB for your reply. Sounds logical, but have an ie: of syntax? Maybe its just this Cold I have but having trouble coming up with something.

    thanks again

  4. #4
    Join Date
    Aug 2002
    Location
    Québec, Canada
    Posts
    109
    Using the lines of code you posted:

    Code:
    "=DateAdd('m',[lngMntcIntv],[dtmMntcLast])"
    You could use that to add 0 months if the value is null:

    Code:
    "=DateAdd('m',[lngMntcIntv],IIF(IsNull([dtmMntcLast]),0,[dtmMntcLast]))"
    It should work properly, the IIF statement is as follow:

    IIF(condition, true part, false part)

    JefB

Posting Permissions

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