Dynamic Criteria

J

jmenche

Hi,

I have a query with a Field called 'Vendor'.

I want to give a user the option on a form to filter the query by 'Vendor A'
or by All Vendors. There is literally two conditions (Vendor A or All
vendors). I am trying to pass criteria to a query through code and it is
easy to pass 'Vendor A' but I cannot find a way to pass through the All
condition.

Can anyone help?
 
F

fredg

Hi,

I have a query with a Field called 'Vendor'.

I want to give a user the option on a form to filter the query by 'Vendor A'
or by All Vendors. There is literally two conditions (Vendor A or All
vendors). I am trying to pass criteria to a query through code and it is
easy to pass 'Vendor A' but I cannot find a way to pass through the All
condition.

Can anyone help?

Here is one way.
As query criteria;
Like IIf(IsNull(forms!FormName!ControlName),"*",
forms!FormName!ControlName)

Leave the control on the form empty to get all.
 
J

jmenche

Thanks!!

fredg said:
Here is one way.
As query criteria;
Like IIf(IsNull(forms!FormName!ControlName),"*",
forms!FormName!ControlName)

Leave the control on the form empty to get all.
 
D

David

Another option is to place this in the criteria in the query, under the
Vendor field criteria...

like [Enter Vendor or Leave Blank for All ] & "*"
 
Top