Run 2 Queries on "On Click" event

QueenOfKings

Registered User.
Local time
Today, 14:01
Joined
Oct 13, 2014
Messages
11
Hi, I have a form with a combo box that is populated by (1) a union query, and (2) a make table query from that union query. The reason I have both is because I want to have an autonumber and I can't do that directly in the first query.

So any time I update any of the tables that are in the union query, then go back to the form, i want the the combo box to update the list which means I have to run (1) and then (2) to repopulate the combo box with the updates.

Does anybody know how to do this? Thanks.
 
If the make table is based on the union, you don't have to "run" the union. If it did, you can simply have a second line to run the second query.
 
That makes sense! Thanks!

But I am trying this to make the make table query refresh:

On the "On click" event, I have in code: Me.comboboxname.Requery

It is neither updating the make table table, nor the combobox list.

What exactly am I supposed to do?
 
To be honest, using a make table query is unusual, and probably a mistake. At the very least it would be more efficient to empty and repopulate a table. In any case, the requery will just make the combo get selections from the table. It sounds like you need to repopulate the table first.
 
That won't work because the whole point of making the table is have the auto numbers for the combobox. If I delete the table every time, then when I make edits to the underlying tables and Access makes a new table, the autonumbers will be different every time. I want the combobox entries to relate back to the table entries from the Union Query, not just to be random numbers.

Do you know what the syntax is to run both of those queries, the first one first, then the second one?
 
Again, you don't run the union. Look at the Execute method or DoCmd.OpenQuery
 

Users who are viewing this thread

Back
Top Bottom