showing all items when criteria is left empty

wilkob

Registered User.
Local time
Today, 10:15
Joined
Jan 10, 2005
Messages
86
I am not sure if this is possible so here it goes:

I have been writing a little query that collects data to batchprint invoices. I want to add some criteria for the user

I have one criteria on the invoice date: between [start date] and [end date]

and I want to add one criteria for the invoice number:
[enter invoice number]

I would like the user to have the possibility to leave the invoice number field empty which should then print all invoices for a certain date

Any ideas how I can achieve this?
 
Assume the following - a table named tblInvoice, with relevant fields named InvoiceNo and InvoiceDate:

SELECT tblInvoice.* FROM tblInvoice
WHERE tblInvoice.InvoiceDate>=[start date]
AND tblInvoice.InvoiceDate<=[end date]
AND (([enter invoice number] Is Null) OR ([enter invoice number] Is Not Null AND tblInvoice.InvoiceNo=[enter invoice number]));

See if this works for you.
 

Users who are viewing this thread

Back
Top Bottom