Criteria expression

G

Guest

I am attempting to do an expression correctly for the
Criteria line of a query.

For a particular field [Status] in the query I want it to
be based on a form which the user has open and to be equal
to the choice made in a combo box, EXCEPT if the use picks
“(Any)” as a choice from the combo box, in which case I
don’t want the field to be filtered on.

I thought something along the lines of the following would
work, but it doesn’t:

IIf([Forms]![ClassMailLabelPick]![Combo125]=”(Any)”,””,
[Forms]![ClassMailLabelPick]![Combo125])

Anybody got any ideas on how this should be written so that
if the user picks the (Any) choice from the drop-down, the
[Status] field criteria line will not have anything in it,
but if the use picks any of the other choices that text
will be used as a criteria??

Thanks,

Steve
 
J

John Spencer (MVP)

Try criteria of

[Forms]![ClassMailLabelPick]![Combo125] OR
[Forms]![ClassMailLabelPick]![Combo125] = "(Any)"

That will get All records if Combo125 is "(Any)", including those where Status
contains a null.


Like IIF([Forms]![ClassMailLabelPick]![Combo125] = "(ANY)","*",[Forms]![ClassMailLabelPick]![Combo125])

Will get those that match or those that have a value, BUT will exclude those
where the Status is Null
 
K

Ken Snell

Your post got "chomped" a bit in translation, but I think this criteria
expression will work for you (note: I'm not sure what “(Any)”
actually is -- perhaps "(Any)" ?):

[Forms]![ClassMailLabelPick]![Combo125] Or
[Forms]![ClassMailLabelPick]![Combo125]="(Any)"


--

Ken Snell
<MS ACCESS MVP>

I am attempting to do an expression correctly for the
Criteria line of a query.

For a particular field [Status] in the query I want it to
be based on a form which the user has open and to be equal
to the choice made in a combo box, EXCEPT if the use picks
“(Any)” as a choice from the combo box, in which case I
don’t want the field to be filtered on.

I thought something along the lines of the following would
work, but it doesn’t:

IIf([Forms]![ClassMailLabelPick]![Combo125]=”(Any)”,”&#822
1;,
[Forms]![ClassMailLabelPick]![Combo125])

Anybody got any ideas on how this should be written so that
if the user picks the (Any) choice from the drop-down, the
[Status] field criteria line will not have anything in it,
but if the use picks any of the other choices that text
will be used as a criteria??

Thanks,

Steve
 

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