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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the comboBox 'Like IIF' twice in a query

Status
Not open for further replies.

skipjakk

Technical User
Feb 25, 2002
18
US
I have had great success with the following criteria expression attached to a combobox:

Like IIf([Forms]![Frm Reporting Main]![cboOM]="ALL","*",[Forms]![Frm Reporting Main]![cboOM])

to pull up all the values if someone picks 'ALL' in the combobox, however, when I try to link the query to TOW comboboxes, one of which will always have "ALL"(hence pulling all data for that field) It doesn't work:

Like IIf([Forms]![Frm Reporting Main]![cboOM]="ALL","*",[Forms]![Frm Reporting Main]![cboOM])


Like IIf([Forms]![Frm Reporting Main]![cboHeir]="ALL","*",[Forms]![Frm Reporting Main]![cboHeir])



Any suggestions?
 
When you say "... it doesn't work ...", what do you mean exactly? Returns no records? Returns all records? Returns the wrong records? Displays an Error?
 
If there both "ALL" it returns all records, but when I do "ALL" and one of the combobox choices in the other, it returns no records.
 
I suspect a quotes thing. Switch to SQL view. Your WHERE clause should look something like
[blue][tt]
WHERE
fld1 Like IIf([Forms]![Frm Reporting Main]![cboOM]="ALL",
"*",
"'" & [Forms]![Frm Reporting Main]![cboOM] & "'")

AND

fld2 Like IIf([Forms]![Frm Reporting Main]![cboHeir]="ALL",
"*",
"'" & [Forms]![Frm Reporting Main]![cboHeir] & "'")
[/tt][/blue]
where "fld1" and "fld2" are your field names.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top