sql and wildcards

G

Guest

I have the following sql expression where the query either uses the value in
a combo box named combo67 (which by default is null) or the ‘is null’
statement is true and it moves on to the next combo box and so on:

((field1)=forms!reports_switch_main!combo67 Or
forms!reports_switch_main!combo67 Is Null)

My question is, how do I modify this so that the user can enter wildcard
characters into the combo box field (such as asterisks, e.g. *house*)?

Many Thanks!
 
D

Douglas J. Steele

To use wildcards, you must use like instead of =:

((field1) like forms!reports_switch_main!combo67 Or
forms!reports_switch_main!combo67 Is Null)

If you use:

((field1) like "*" & forms!reports_switch_main!combo67 & "*" Or
forms!reports_switch_main!combo67 Is Null)

then the user doesn't have to enter the wildcard characters themselves:
selecting "house" from the combobox will result in selecting all rows where
the letters "house" appear anywhere in field1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top