use field list from form to specify query fields

J

jrizzo77

Hello,

I want to have the user select a field on a form via combo box and use
it to define the fields in a query.

The combo will show the field list from the table. The user will
select the field they want to search by and type the criteria in a
text box on the same form. I need the query to filter the table by
the field and criteria the user has chosen in the form.

example:
combo box is linked to the table row source type is filed list. the
query will open outputting all fields filtered by the field and
criteria specified on the form. I know how to refer to the form in
the criteria that part is working fine. It's choosing the field that
I can not get to work. I'd like to keep this in query form rather
than vb code.

thanks in advance.
Joe
 
A

Allen Browne

This will require some VBA code.

See if this does what you need:
Find as you type - Filter forms with each keystroke
at:
http://allenbrowne.com/AppFindAsUType.html
There's a sample database to download. Copy the code into your database.
Copy the combo and text box onto your form, and set one property. When you
open the form, it loads the combo with the names of the fields that can be
filtered, and as you type in the text box, it filters on that field.
 
J

jrizzo77

This will require some VBA code.

See if this does what you need:
    Find as you type - Filter forms with each keystroke
at:
   http://allenbrowne.com/AppFindAsUType.html
There's a sample database to download. Copy the code into your database.
Copy the combo and text box onto your form, and set one property. When you
open the form, it loads the combo with the names of the fields that can be
filtered, and as you type in the text box, it filters on that field.

Actually I found that a simple Choose function in the query works very
well.

In the Field. Choose([forms]![myform]![combo],[field1],
[field2],etc...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top