Specify DATE RANGE.

G

Guest

Greetings. I am having a problem with the code below:

Between [Forms]![frm_CalculateUsage]![BeginDate] And
IIf([Forms]![frm_CalculateUsage]![EndDate]=Null,Date(),[Forms]![frm_CalculateUsage]![EndDate])

What I am trying to do is the following:

I have a form linked to a query. The form has to unbound text boxes,
"BeginDate" and "EndDate."

With the above code, I was trying to make it so that the user could put in
botha BeginDate and EndDate, or only the BeginDate and (if left blank) the
EndDate would default to the current date.

Then, by pressing a command button on the form, the query would pull up
information between the two dates. It works if I put in a BeginDate and an
EndDate, but if I leave EndDate blank, the query acts as though it is working
for a little while, then the hour glass turns back into apointer, with no
results given. Please help. Thansks.
 
B

Brendan Reynolds

You can't use the "=" operator when comparing anything with Null, you need
to use the IsNull function, which returns true if the value is Null, e.g.
IIf(IsNull(YourForm!YourControl), etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top