By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,346 Members | 2,158 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,346 IT Pros & Developers. It's quick & easy.

Select All if Textbox Empty

P: 8

I have a form with text/combo boxes that draws from a query and sends records to a report.

The query has the following code in the criteria block of some of the columns:

This code tells the query to select only those records that match what was entered or selected in the pertinent text/combo box in the "report" form. So the SQL appears as follows:
SELECT tbl.fld1, tbl1.fld2, tbl1.fld3, tbl1.fld4
FROM tbl1
WHERE (((tbl1.fld1)=[Forms]![frmName]![fld1]) AND ((tbl1.fld2)=[Forms]![frmName]![fld2]))

So when I hit the report button. Only those records matching the search criteria set in the form appear in the report.

Sometimes I want to search by fld1 & fld2, and sometimes I want to search only by fld1 or only by fld2. Thus I leave the other tbo/cbo blank.

The problem with that is Access responds to the empty cbo/tbo as "Select all where fld is empty" rather than how I want it to - "Select All since cbo/tbo is empty".

Is there an if (or other) statement I can write into the query to tell it that if it comes across an empty tbo/cbo, "Select All" in that column?
Dec 3 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,366
Use the Like operator. Don't forget the wildcards. And if you want the Nulls, don't forget to Nz() the field first.
Dec 3 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.