Criteria based on Combobox

E

ehale

Hello. I have a problem I hope someone can help me with.
I have a table with a field called tblCoverage that has
either "Auto Liability" or "General Liability" in it. I
want to run a query that will include criteria for that
field. In a form, I have a combobox with entries
for, "Auto Liability" "General Liability" and "Auto &
General Liability". I want the query to return all
records if "Auto & General Liability" is selected from
this combobox, etc. How can I accomplish this? Any help
is very appreciated.
 
W

Warrio

you can create a query for each of your three cases

If yourCombo = "Auto Liability" Then
myQuery="Select * from tblCoverage where myField = 'Auto Liability' "

ElseIf yourCombo = "Auto Liability" Then
myQuery="Select * from tblCoverage where myField = 'General Liability'
"

Else
myQuery="Select * from tblCoverage where myField = 'Auto Liability' OR
myField = 'General Liability' "

EndIf

and then run your query.
 
J

John Spencer (MVP)

One method is to use criteria like the following

Field: TblCoverage
Criteria: Forms!FormName!Combobox OR Forms!FormName!Combobox = "Auto & General Liability"

or another method

Field: FindCoverage: Forms!FormName!Combobox
Criteria: LIKE "*" & [tblCoverage] & "*"
 
Top