houseofturner
Registered User.
- Local time
- Today, 19:31
- Joined
- Dec 10, 2009
- Messages
- 37
I want to run a query that uses criteria specified in a series of fields on a form. However, not all the fields on the form will have data stored in each time the query is run.
So for example, the query has the fields Manufacturer, Model, Variant. The form has has the same fields.
If someone has entered "BMW" in the manufacturer field on the form, the query should only return BMW records.
But I need to put something in the criteria to say that if (for example) the manufacturer field on the form is empty then no criteria is applied and it should return all records.
I tried putting the following in the criteria field but it works if there is a value on the form but not when the form field is empty.
IIf(Not ([FormName].[Manufacturer])=IsNull([Forms]![FormName]![Manufacturer Filter]),[Forms]![FormName]![Manufacturer Filter])
I also tried
IIf(Not ([FormName].[Manufacturer])=IsNull([Forms]![FormName]![Manufacturer Filter]),[Forms]![FormName]![Manufacturer Filter],"Audi") to see if it was a lack of an alternative criteria but that didn't work either.
So for example, the query has the fields Manufacturer, Model, Variant. The form has has the same fields.
If someone has entered "BMW" in the manufacturer field on the form, the query should only return BMW records.
But I need to put something in the criteria to say that if (for example) the manufacturer field on the form is empty then no criteria is applied and it should return all records.
I tried putting the following in the criteria field but it works if there is a value on the form but not when the form field is empty.
IIf(Not ([FormName].[Manufacturer])=IsNull([Forms]![FormName]![Manufacturer Filter]),[Forms]![FormName]![Manufacturer Filter])
I also tried
IIf(Not ([FormName].[Manufacturer])=IsNull([Forms]![FormName]![Manufacturer Filter]),[Forms]![FormName]![Manufacturer Filter],"Audi") to see if it was a lack of an alternative criteria but that didn't work either.