Query results based on 2 form control values

zarcoff

New member
Local time
Today, 00:45
Joined
Oct 29, 2014
Messages
5
Hi All,

If anyone can help me I would be so appreciative. I have 2 form controls one a combobox and the other a text box. The text box helps select the site (txtLocation) where the user can enter part of the name of the site and all sites with those characters are returned. I've done this by adding:

Code:
Like [Forms]![frmSearchDB2]![txtLocation] & "*"

into the criteria on the Site field in the query design editor. Simple!

I also want the combobox to have an affect on the query. I want it to query on user status. However if the combobox reads "All Users" I want it to return all status's and all null values. I have tried loads of combinations and because I'm not that great at Access I'm not sure I'm even doing it in the right place. In the criteria field I put:

Code:
iif([Forms]![frmSearchDB2]![cbxUserStatus] = "All Users",like "*",[Forms]![frmSearchDB2]![cbxUserStatus])

It kind of works but no null values are pulled back. Should it be an expression? Can anyone help? Do I need to do it in VBA?

Thank you in advance!

Zar! :banghead:
 
You can't get Null values using "like *", try the below:
[Forms]![frmSearchDB2]![cbxUserStatus] OR [Forms]![frmSearchDB2]![cbxUserStatus] = "All Users"
 

Users who are viewing this thread

Back
Top Bottom