Query Wizard

L

Leo

Hi -

I am using the query wizard and I have a field (e.g. named Region) that I
want to show only if there is something selected in my combo box (i.e. only
if a field type (e.g. Asia, North America etc.) has been selected in my combo
box. Thus, in my query wizard, under criteria, I have
[forms]![frm_Name]![cmb_Box_Region].

So what I am trying to do is to write an 'If' statment to only return fields
if a region was selected in the combo box. Else if no region was selected, I
DO NOT show this field AT ALL.

I used the following IIf statement but it returns no data if the combo box
is blank:

Criteria: IIf([forms]![frm_Name]![cmb_Box] <>"", [forms]![frm_Name]![cmb_Box])

Also, I tried using the 'Like "*"' function and the 'Is Null' function and
they do not seem to work.

Lastly, I know that if I duplicate this SQL statement in VBA instead of the
wizard, I could probably use a bunch of IF statements to alter my SQL. But
since I am using a CrossTab Query, it makes it a little harder for me to
duplicate this SQL statement in VBA.

Does my question make sense?

Please help. Thanks
 
J

John Spencer (MVP)

Finally realized what you meant (I think).

Criteria: [forms]![frm_Name]![cmb_Box] OR [forms]![frm_Name]![cmb_Box] Is Null

Access will reformat this when you save the query and if you have a lot of other
criteria, you may end up with a query too complex error.
 

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