Like Operator with a combo box value

echorley

Registered User.
Local time
Today, 05:43
Joined
Mar 11, 2003
Messages
131
I have a select query that has filenames listed. I would like to use the Like Operator to select only those filenames with certain bits of string.

For example: In the Criteria area of a query Like "*Defense*" selects all filenames with the word Defense successfully.

However, I would like to select the key word from a combo box and use it in the Like expression.

For example:

Like "* '&Forms![View Selected Plays]![Play Type]&' *"

The code above does not return any results even if the term Defense is selected in the combo box.

I am sure this is a quotes, single quote, *, % type problem, but every combination I try yields no results.

Thanks.
 
Hello:

The key to that is to have a "Where" expression in your SQL statement such as:
'
strSQL = strSQL & "WHERE (((YourTableName." & YourFieldName & ")='" & YourCombo.Value & "'));"
'
Make sure your form is open when you run the query.

Regards
Mark
 
That works if

the field you are looking for matches exactly what you are looking for. These are file names that I am searching through.

For example, in the string c:\holt_scout\01-CA1-Defense-40-Stunt1.avi, I want the query to be able to pick up all the file names with the word "Defense" or "40".

The Like operator in the Criteria of a query works if I enter it explicitly: Like "*Defense*".

Where I have Defense, I want to be able to put the results of a combo box on a form.
 

Users who are viewing this thread

Back
Top Bottom