Consulting

Results 1 to 5 of 5

Thread: Suppressing #Error returned as a query result

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,411
    Location

    Suppressing #Error returned as a query result

    I have a query that evaluates a record column "Due date" and returns:

    1. The week of of the year index and ..
    2. The date of Monday of that week:

    So if I entered July 4, 2024, I get the returned values 27 and Jul 1

    However, in some record instances, the "Due date" column is not filled in. When I attempt to query under this condition

    Name Date Due
    Mary July 4, 2024
    Bob

    I get
    27 Jul 1
    #Error

    These are the two field statements:
    WeekIndex: DatePart("ww",[DueDate])
    WeekBeginDate: Format(DateAdd("d",-Weekday([DueDate])+2,[DueDate]),"mmm dd")
    So it appears if the DueDate in the record is Null then the WeekIndex statement ignore the Null value and returns a Null value but in the case of the WeekBeginDate an error occurs.

    I have worked around this problem using:

    WeekBeginDate: IIf(IsDate([DueDate]),Format(DateAdd("d",-Weekday([DueDate])+2,[DueDate]),"mmm dd"),"")
    Is there a better\more efficient way to suppress that #Error returned if the DueDate field is Null. I know there is a Nz function but unsure how to employ it.

    Thank you.
    Last edited by Aussiebear; 07-04-2024 at 01:06 PM.
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

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