Query criteria

G

Guest

Hi all

I have two unbound fields on a form. One contains a date field (startdate)
which defaults to last week's Monday's date, the other (cboItinerary) is
blank unless a date value is chosen from the combo box by a user.

I have an IIf statement in a query that stipulates if field cboItinerary is
null then it uses the startdate value to search on, if not, it uses the data
entered in cboItinerary.

The query returns no results though if I leave cboItinerary blank when I
know there should be records, it used to work on just startdate until I tried
adding the cboItinerary field to the equation. Syntax below if someone can
help please?

IIf(IsNull([forms]![frm Expenses
Menu]![cboItinerary]),[Itinerary].[ReviewDate] Between [forms]![frm Expenses
Menu]![StartDate] And [forms]![frm Expenses Menu]![StartDate]+4,[forms]![frm
Expenses Menu]![cboItinerary])

Thanks in advance for any help.
Sue
 
G

Guest

Try this

Where [Itinerary].[ReviewDate] Between IIf(IsNull([forms]![frm Expenses
Menu]![cboItinerary]), [forms]![frm Expenses Menu]![StartDate], [forms]![frm
Expenses Menu]![cboItinerary]) And IIf(IsNull([forms]![frm Expenses
Menu]![cboItinerary])[forms]![frm Expenses Menu]![StartDate]+4,[forms]![frm
Expenses Menu]![cboItinerary])
 
G

Guest

Thanks that worked :)

Sue


Ofer said:
Try this

Where [Itinerary].[ReviewDate] Between IIf(IsNull([forms]![frm Expenses
Menu]![cboItinerary]), [forms]![frm Expenses Menu]![StartDate], [forms]![frm
Expenses Menu]![cboItinerary]) And IIf(IsNull([forms]![frm Expenses
Menu]![cboItinerary])[forms]![frm Expenses Menu]![StartDate]+4,[forms]![frm
Expenses Menu]![cboItinerary])

--
\\// Live Long and Prosper \\//
BS"D


hughess7 said:
Hi all

I have two unbound fields on a form. One contains a date field (startdate)
which defaults to last week's Monday's date, the other (cboItinerary) is
blank unless a date value is chosen from the combo box by a user.

I have an IIf statement in a query that stipulates if field cboItinerary is
null then it uses the startdate value to search on, if not, it uses the data
entered in cboItinerary.

The query returns no results though if I leave cboItinerary blank when I
know there should be records, it used to work on just startdate until I tried
adding the cboItinerary field to the equation. Syntax below if someone can
help please?

IIf(IsNull([forms]![frm Expenses
Menu]![cboItinerary]),[Itinerary].[ReviewDate] Between [forms]![frm Expenses
Menu]![StartDate] And [forms]![frm Expenses Menu]![StartDate]+4,[forms]![frm
Expenses Menu]![cboItinerary])

Thanks in advance for any help.
Sue
 

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