Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf command with Between

Status
Not open for further replies.

jmc014

Technical User
Nov 24, 2007
80
ES
Hi, I could use a little help if anyone's got the time,

I've got a simple query that I'm trying to get some simple results from:

If the Main Form [Date_Frm] field is null, then return all the date form the table.
ELSE, if the [Date_Frm] field contains a date, return the Between dates criteria.

Here is the criteria that I'm using in my query:

IIf(IsNull([Forms]![Main_Form]![Search_GSIS]![Date_Frm]);[ArrivalSCH];Between [Forms]![Main_Form]![Search_GSIS]![Fecha_Frm] And [Forms]![Main_Form]![Search_GSIS]![Date_To])

Issue:
If the Date_Frm field is blank, no problem, the results are showing. But when the Date_Frm field contains a valid date, the results from my query are always blank.

Note:
Using the "Between [Forms]![Main_Form]![Search_GSIS]![Fecha_Frm] And [Forms]![Main_Form]![Search_GSIS]![Date_To]" criteira WITHOUT IIF works fine!

Thanks for anyone's time
 
I would try use the Nz() function like:
Code:
Between Nz([Forms]![Main_Form]![Search_GSIS]![Date_Frm],#1/1/1900#) And Nz([Forms]![Main_Form]![Search_GSIS]![Date_To],#12/31/3000#)

This assumes all dates will be between 1/1/1900 and 12/31/3000. You can substitute other dates or expressions.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top