SQL Query with Iff and Wild Card

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to use the results from a form to build an SQL Query. The form
has combo box's to select a value that is updated to a table that is in turn
used as the selection criteria of the query. When I select a value the
criteria in the query works fine. When the selection is blank (i.e. I should
view all records) I don't see any records. The statement in the query is:

IIf([VulnerableEntitySelect]![Type]<>"",[VulnerableEntitySelect]![Type],"*")

I have tried using the asterick without the quotes and tried using null in
place of "*" with no luck.

What should I be using?

Thanks,

Randy
 
Probably

Like IIf(Forms![VulnerableEntitySelect]![Type] Is Not
Null,Forms![VulnerableEntitySelect]![Type],"*")

That will work as long as your field doesn't contain nulls. If the field
has nulls then the records where the field is null will not be shown.

If you need ALL records then try the following criteria

WHERE TheField = Forms![VulnerableEntitySelect]![Type] OR
Forms![VulnerableEntitySelect]![Type] Is Null
 
Back
Top