By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,139 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,139 IT Pros & Developers. It's quick & easy.

Conditional If

P: n/a
How do I write the conditional If statement for a query criteria where if
Forms!MyForm!MyCbx = "AllCategories" then Like "*" else Forms!MyForm!MyCbx ?

I can't get the Like "*" to work.

Thanks!

Steve
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,
Write a computed expression:

iif( Forms!MyForm!MyCbx = "AllCategories", True, Category LIKE
Forms!MyForm!MyCbx )
and set its criteria

<> false
Note that I assume the field you use for the comparison is named Category.
Hoping it may help,
Vanderghast, Access MVP
"Steve" <ss****@earthlink.net> wrote in message
news:CL*******************@newsread2.news.atl.eart hlink.net...
How do I write the conditional If statement for a query criteria where if
Forms!MyForm!MyCbx = "AllCategories" then Like "*" else Forms!MyForm!MyCbx ?
I can't get the Like "*" to work.

Thanks!

Steve

Nov 12 '05 #2

P: n/a
"Steve" <ss****@earthlink.net> wrote in message
news:CL*******************@newsread2.news.atl.eart hlink.net...
How do I write the conditional If statement for a query criteria where if
Forms!MyForm!MyCbx = "AllCategories" then Like "*" else Forms!MyForm!MyCbx

?

=Like iif(Forms!MyForm!MyCbx = "AllCategories", *, Forms!MyForm!MyCbx )
Nov 12 '05 #3

P: n/a
"Steve" <ss****@earthlink.net> wrote in message news:<CL*******************@newsread2.news.atl.ear thlink.net>...
How do I write the conditional If statement for a query criteria where if
Forms!MyForm!MyCbx = "AllCategories" then Like "*" else Forms!MyForm!MyCbx ?

I can't get the Like "*" to work.

Thanks!

Steve


"Like "*"" has no meaning. Why bother with that criterium?

Anyway, where do you want to use the results of this query? In a form,
report, recordset?

Can't you just build the query in VBA before running it? (that's what
I would do)

Or you could use the filter property of the form or report. Set the
..filter, set the .filteron property to true, and voila.
Nov 12 '05 #4

P: n/a
LIKE iif(Forms!MyForm!MyCbx = "AllCategories", "*", Forms!MyForm!MyCbx)

Pavel

Steve wrote:

How do I write the conditional If statement for a query criteria where if
Forms!MyForm!MyCbx = "AllCategories" then Like "*" else Forms!MyForm!MyCbx ?

I can't get the Like "*" to work.

Thanks!

Steve

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.