We help IT Professionals succeed at work.

Help with wildcard in query please.

Fritz Paul
Fritz Paul asked
on
I use Access 2010.
I have a combobox [Filter_Location] on a form [frm_Planting] and I want to use the value of the combobox in a query criteria. If the combobox is empty, I want all the values in the source. Otherwise I want only the values specified by the combobox.
I use the following criterium, but the problem is if the value of the combobox is 3, the query also give me values for 13, 23 etc.
Like "*" & [Forms]![frm_Planting]![Filter_Location]
Comment
Watch Question

Top Expert 2016
Commented:
Hi,

pls try
Like nz([Forms]![frm_Planting]![Filter_Location], "*")

Open in new window

Regards
Top Expert 2016

Commented:
or
 Like Iif([Forms]![frm_Planting]![Filter_Location]="","*",[Forms]![frm_Planting]![Filter_Location])

Open in new window

Author

Commented:
Thanks, but if [Forms]![frm_Planting]![Filter_Location]="", then it return no records, otherwise it works correctly.
Top Expert 2016

Commented:
Have you tried my 2nd solution

Author

Commented:
Thanks, I did not notice your first solution.
Like nz([Forms]![frm_Planting]![Filter_Location], "*")
This works thanks!