multi-field queries

  • Thread starter Thread starter Bill Stone
  • Start date Start date
B

Bill Stone

I have a report writer application in which the user can
select data in several fields (comboboxes/listboxes on a
form) and then create a report of all data that meets the
selected values, via a query. Currently there are only a
few combinations of fields that they select and I
have "hard coded" a query for each combo.

What I want to do is put each field on the form and let
the user select data in the one's that apply. And if he
does not select a certain field, I do not want that field
to be used in the query. What I envision is a
combobox/listbox that has each record listed and then
an "All" record. If they select "All" then they do not
want this field used in the query.

Can I set up a query in access to handle this or will I
have to query the query on the fly using VBA code?


Thanks,

Bill
 
Bill

If I were faced with what you've described (as a requirement), and I have
been, I would create a procedure "behind the form" that dynamically built a
SQL statement, then ran THAT as the query.

If you can have any number of fields selected (or not), and any criterion
value(s) (or not), creating a query to handle any possible combination could
be, ... challenging! Just creating the code to build the SQL statement on
the fly will be challenging enough.
 
Back
Top