How can I use * in query

snowsride

Registered User.
Local time
Today, 23:48
Joined
Nov 29, 2001
Messages
33
I want to use the * wildcard in a query if a forms control has been checked to return all records but somehow I haven't got the syntax right.

This returns all records with X as the category

IIf([FORMS]![Main]![CategoryX]=True,"X")

but

IIf([FORMS]![Main]![CategoryX]=True,Like "*") does not return any records.

Grateful for any help
 
Can't you simply put 'True' as a criteria in the query?

(Or am I missing something?)
kh
 
I think LIKE "*phrase*" might be what you're looking for? For example if you want to search for "red" then you say.

like "*red*"

Not sure if that's it though.
 
how can I use wildcard

Thanks for the feedback but regret I may not have explained properly. I just want to return all records if the value of a control is true.
 
Snow,

You don't need an IIf function or a Like operator.

Just put True or -1 in the CRITERIA for the [CategoryX] field.

Wayne
 
Use * in query

Wayne

My form has many check boxes - Option 1, Option 2, Option 3, Option 4 etc which the user can select. What I need is the syntax for the criteria so that if Option 1 is true then all records are selected. Obviously if there were no options then the criteria could be blank and all records would get returned by the query. Alternatively if * is entered under the criteria then all records are returned. I need all records returned if Option 1 is true. Just entering true or -1 as a criterion makes no reference to whether the user has made a selection and it won't return all the records either.

Snowsride
 
Code:
IIf([FORMS]![Main]![CategoryX]=True,True)

???
kh

Edit:

or just:

Code:
[FORMS]![Main]![CategoryX]

???
 
Last edited:
Build the Sql statement up via code and use instead. Then you can have true, false, included excluded etc on the form and the code interprets it and creates as required.

For example
Searching for * (all records) means no filter required, but if you put a true in then a filter is required and added to the where clause.


Start off with an sql statement to return all the fields you need.
I suggest a checkbox to include in the search with a text/combo box (your choice here) for the criteria.
If you want to get really flexible, you'd have a list of criteria and add to/remove from it... Perhaps later huh?
 

Users who are viewing this thread

Back
Top Bottom