Wildcards in IIF statements

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

Guest

In Access 2003, I would like to include wildcards (eg "*") as part of some
iif functions (eg in queries) so that if (say) the option group number = 1
then all records will be shown, whereas if option group number = 2 only
records with a specific entry (in the field in question) will be shown.

When I try and do this I get a message "This expression is typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables. (Error 3071)"

What is the correct syntax to use / how else to solve?

Current expression reads:
=IIf([Forms]![F Current Proposals and
Inquiries]![OfficeSpecificSelector]=1,"*","Melbourne")
 
In Access 2003, I would like to include wildcards (eg "*") as part of some
iif functions (eg in queries) so that if (say) the option group number = 1
then all records will be shown, whereas if option group number = 2 only
records with a specific entry (in the field in question) will be shown.

When I try and do this I get a message "This expression is typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables. (Error 3071)"

What is the correct syntax to use / how else to solve?

Current expression reads:
=IIf([Forms]![F Current Proposals and
Inquiries]![OfficeSpecificSelector]=1,"*","Melbourne")

do you use it in a Where clause?

then you change the whole clause:
if group number =1 WHERE True
if group number =2 WHERE FieldName="Melbourne"
 
In Access 2003, I would like to include wildcards (eg "*") as part of some
iif functions (eg in queries) so that if (say) the option group number = 1
then all records will be shown, whereas if option group number = 2 only
records with a specific entry (in the field in question) will be shown.

When I try and do this I get a message "This expression is typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables. (Error 3071)"

What is the correct syntax to use / how else to solve?

Current expression reads:
=IIf([Forms]![F Current Proposals and
Inquiries]![OfficeSpecificSelector]=1,"*","Melbourne")

Where [YourTable].[FieldName] Like IIf([Forms]![F Current Proposals
and Inquiries]![OfficeSpecificSelector]=1,"*","Melbourne")
 
In Access 2003, I would like to include wildcards (eg "*") as part of some
iif functions (eg in queries) so that if (say) the option group number = 1
then all records will be shown, whereas if option group number = 2 only
records with a specific entry (in the field in question) will be shown.

When I try and do this I get a message "This expression is typed
incorrectly, or it is too complex to be evaluated. For example, a numeric
expression may contain too many complicated elements. Try simplifying the
expression by assigning parts of the expression to variables. (Error 3071)"

What is the correct syntax to use / how else to solve?

Current expression reads:
=IIf([Forms]![F Current Proposals and
Inquiries]![OfficeSpecificSelector]=1,"*","Melbourne")

An alternative is to use

WHERE (<fieldname> = "Melbourne" AND
[Forms]![F Current Proposals and Inquiries]![OfficeSpecificSelector]
<> 1)
OR
([Forms]![F Current Proposals and Inquiries]![OfficeSpecificSelector]
= 1)

John W. Vinson[MVP]
 

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

Similar Threads


Back
Top