use drop down box to search table

C

chad

i have a table that I would like to search using a drop down box. I can
create the form and and box, I just can not get the command button to use
what I selected in the drop down box to search the table ?
 
A

Arvin Meyer [MVP]

Use the AfterUpdate event of the combo (drop down) box to do the search.
There is even a wizard to give you a hand. Just make sure the wizards are
turned on when you place the combo on the form.
 
B

BruceM

Typically you would use the combo box After Update event to find the record
or whatever exactly you need to do. What exactly do you mean by "search the
table"? Are you trying to go to a particular record, or find all records
that meet certain criteria, or what? What is the command button code you
are using? What is the combo box Row Source?
 
C

chad

I have Lease Sale number that I would like to select from the combo box and
from that selction run a query to displayed for the user. There is currently
nothing coded on the command button. The After Update property, should this
have a macro to run a parameter query ?
 
A

Arvin Meyer [MVP]

chad said:
I have Lease Sale number that I would like to select from the combo box and
from that selction run a query to displayed for the user. There is
currently
nothing coded on the command button. The After Update property, should
this
have a macro to run a parameter query ?

Follow these instructions:

1. Open your form in Design View
2. Make sure the yoolbox is turned on (View >>> Toolbox)
3. Make sure the Wizard is on (the little magic wand icon)
4. Click on combo box icon and click on the form.
5. The wizard will pop up.
6. Choose the 3rd choice (Find a record ...)
7. Click Next
8. Choose the Primary Key field and the search criteria field.
9. Click Next.
10. Accept the defaults. Click Next.
11. Type a name (like Search) and click Finish.

You're done, except for any cosmetics.
 
C

chad

I can create the combo box and populate it with the data from a column in a
table, the problems is dispalying those results after I select the lease sale
number I need to be able to click a button and view those results in a
table/Report. When I use the wizard to create the combo bax there is no 3rd
option I get 2 options and the one I select says to use a table to populate
the combo box.
 
A

Arvin Meyer [MVP]

You have 2 options because your form is not bound to the data. There is no
way to display data on an unbound form using a lookup. Make sure that the
form has a control source of a table or query.

If you want to display the data in a report, change the recordsource of the
report to read the data from a query that sees the combo box, like:

Select * From MyTable Where ID = Forms!SearchForm!ComboBoxName
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
Top