Query criteria from open form or if field is null

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I have a query that pulls data based on mail date. The
criteria for mail date is based on a field on an open form
called [MailDate]. If a date is filled in I want it to
pull only that date. If a date is not filled in on the
form I want it to pull only records where the mail date is
null. Does anyone know how to write this criteria?
 
WHERE MyDateField = [Forms]![MyForm]![MailDate] OR
((MyDateField IS NULL) AND ([Forms]![MyForm]![MailDate] IS NULL))

Note that you cannot compare anything except the special IS NULL predicate
to a Null value, so you have to do it this funky way.

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
Back
Top