Parameter Query Question

Z

Zoomiest

Why doesn't this work?

In the Criteria field of a QBE grid, I have the following formula, to
pull some parameters off a form. How can I code the "*" condition, if
the chkAll is true?

IIf([Forms]![frmLA_Control_Panel].[chkAll]=True,([tblOnliners].
[Region]) Like "*",[Forms]![frmLA_Control_Panel].[cboRegions]) (this
doen't work)

IIf([Forms]![frmLA_Control_Panel].[chkAll]=True,"*",[Forms]!
[frmLA_Control_Panel].[cboRegions]) (this doesn't work either)
 
J

Jeff Boyce

"doesn't work" doesn't give us much to go on ... can you be a bit more
specific? Do you get an error message? What does it say?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
S

Sylvain Lafontaine

IIf() is a function returning a value, not a conditional statement; so
probably that you are trying to write something like:

[tblOnliners].[Region]) Like
IIf([Forms]![frmLA_Control_Panel].[chkAll]=True,"*",[Forms]![frmLA_Control_Panel].[cboRegions])

This is something close to your second attempt so maybe this is already what
you have wrote with QBE but I don't know it; so I'm not sure. A much better
solution would be to write something like directly in SQL:

WHERE (Forms]![frmLA_Control_Panel].[chkAll]=True)
OR ([tblOnliners].[Region] = [Forms]![frmLA_Control_Panel].[cboRegions])

You should forget about using the QBE and learn to write your queries
directly in SQL. QBE is, at best, a bad tool with which you can only write
simple expressions and that will quickly mix up your stuff if you trow
anything at it that is not plain simple. You'll go nowhere with this (bad)
tool if you insist to work with it.

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Blog/web site: http://coding-paparazzi.sylvainlafontaine.com
Independent consultant and remote programming for Access and SQL-Server
(French)
 

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