IIF Statement - How to specify NO Criteria

R

reddy

I have a query that obtains its critieria from a form.

Select *
From tblData
Where Date=[Forms]![FrmMonthlies]![CmbDate]

If no date is chosen on the Form, I want the Date criteria in the Query to
be blank.

I tried this:
Select *
From tblData
Where Date=
IIF([Forms]![FrmMonthlies]![CmbDate]="","",[Forms]![FrmMonthlies]![CmbDate])

This does not work. Please advise.
 
F

fredg

I have a query that obtains its critieria from a form.

Select *
From tblData
Where Date=[Forms]![FrmMonthlies]![CmbDate]

If no date is chosen on the Form, I want the Date criteria in the Query to
be blank.

I tried this:
Select *
From tblData
Where Date=
IIF([Forms]![FrmMonthlies]![CmbDate]="","",[Forms]![FrmMonthlies]![CmbDate])

This does not work. Please advise.

Where Date=[Forms]![FrmMonthlies]![CmbDate] or
Forms![FrmMonthies]!CmbDate] Is Null

NITE: Date is a reserved Access/VBA/Jet word and should not be used as
a field name.
For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 

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