Dates and Null

  • Thread starter Thread starter rob p
  • Start date Start date
R

rob p

I also had a date problem and found this posting from a couple weeks ago:

I tried the code below and upon entering first date and then CR for second,
I get error "Invalid use of Null". I was careful to type the code. Is there
a setting somewhere I need to flip also?
thanks.



how can I have a query that will allow a user to enter
either a specific date or a range of dates?

Put a criterion of

([Shipdate] >= CDate([Enter start date:]) OR [Enter start date:] IS
NULL)
AND
([Shipdate] < DateAdd("d", 1, CDate([Enter end date:])) OR [Enter end
date:] IS NULL)

If they enter dates (the same date for specific date) in both prompts,
it will find all shipdates in between; if they enter only a start date
it will find from that date on; if they enter only an end date it will
find all earlier dates.
 
I tried the code below and upon entering first date and then CR for second,
I get error "Invalid use of Null". I was careful to type the code. Is there
a setting somewhere I need to flip also?
thanks.

<BLUSH!!!>

My apologies; that was my oversight. The CDate() function won't work
on NULLs.

Change the query to

[Shipdate] >= CDate(NZ([Enter start date:],#1/1/100#))
AND
[Shipdate] < DateAdd("d", 1, CDate(NZ([Enter end
date:]),#12/30/9999#))
 
Back
Top