Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box

Status
Not open for further replies.

tlaksh

Programmer
Feb 25, 2001
98
US
I have a query that has a where clause & get its value from a combo box. I want it to show all records if nothing is selected in the combo box

How can i achieve this? Please help.

Thanks
Lakshmi.
 
Lakshmi,


In the where clause where you have the reference to the combo box control add an &"*" this will allow you to pass the wildcard for everything when nothing is selected but limit the list to what you select in the combo box otherwise.

Steve
 
I tried that but it does not seem to work. I am adding it in the query's cliteria along with

[Forms]![Parameter_queries]![Combo1] & "*"

but it still does not show records for all the options in the combo box

Thanks
Lakshmi.
 
Hi,

You can check the value of the ComboBox and if it is null or "", [Nz(ComboBox1) = ""] then
change the WHERE clause to a value that is always True.

If Nz(ComboBox1) = "" Then
strSQLWhere = "[IDField]=" & IDField
Else
....
End If

You can start with that,

Dean :)
 
Lakshmi,

Apologies you will need the LIKE statement at the beginning of your criteria as well.
 
The statement works with Like but then when a combo item is chosen it also includes anything that looks like this item. for eg. if the combo item chosen is 16 and we have say 167 in the table it displays result for both.

Thanks
Lakshmi.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top