Running a query from a combo box

G

Guest

On my form I have a combo box pulls data from a table (table1) and saves it
to another table. I have a 2nd combo box that does the same thing but from a
differnt table (table2). I want to filter the 2nd combo box depending on my
1st combo box's selection.

ex: I select "Site A" (from table1) for combo box 1, I want combo box 2 to
filter everything that says "Site A" (from table2) and display it for me to
select to input it into table3.

I have been trying for hours to ge tthis to work so any help would be
greatly appreciated! Thanks
 
G

Guest

Build a query for the 2nd combo box source. Use the first combo box as
criteria for the query.
You will need to refresh the query on opening the 2nd combo box.
 
G

Guest

Would you mind explaining how to do that for me? (sorry im still new to access)
Thanks
 
G

Guest

Build a query with criteria --
[Forms]![YourForm]![YourComboBox1]

Create a macro named RequeryComboBox2 with action Requery.

Open your form in DESIGN view. Right click the 2nd combobox. Select
Properties.
For Row Source select your query.
For On Enter select Macro.RequeryComboBox2.

Save.
 
G

Guest

Ok well I got from Karl's reply.

Here is what I did.
1st I made a Query For everything I needed

Then

In the 1st combo box I used the after update function and wrote this code:

Private Sub Combo1_AfterUpdate()
If combo1 = "Site A" then
combo2.RowSource = "QuerySiteA"
Else
End If
End Sub

If anyone knows a better/easier way to do this, Please let me know =)

Thank You Karl
 
G

Guest

When I make the macro with the Requery action, what do I put as the control
name? No matter what I put in there, whenever I got back to my form and click
on combobox 2 it says "There is no field named "(whatever is in the control
name)" in the current record" and if i leave it blank then I cant even click
on combobox 2.

And suggestions?

Thanks

KARL DEWEY said:
Build a query with criteria --
[Forms]![YourForm]![YourComboBox1]

Create a macro named RequeryComboBox2 with action Requery.

Open your form in DESIGN view. Right click the 2nd combobox. Select
Properties.
For Row Source select your query.
For On Enter select Macro.RequeryComboBox2.

Save.

Joel said:
Would you mind explaining how to do that for me? (sorry im still new to access)
Thanks
 

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