Re: building a search form
Please don't post duplicate threads... that creates much more confusion than the alternative (a thread being moved if needed). Your thread in Office Dev has been deleted.
The Where clause you have got is the kind of thing you should be using - but it should be applied to your main query, rather than as a separate query.
It should run quickly, because the check for the form value (and nz) should only run once for the whole query. If the form value is Null the rest of the condition should actually be ignored (because it will be productType=productType ), otherwise it will be treated as a direct comparison between the field and the form value for each row.
Quote:
running the query over all the products takes a long time, since I need to calculate and show per each result its total purchases.
I'm not sure what you meant by that part.. can you clarify?