Reputation: 173
I created a form where users can select a supplier from a list, then the user presses the refresh button, and a bunch of queries are run and show for transaction dates linked to that supplier. The user can then click on one of the generated transaction dates and then on the refresh button to run more queries that calculate spend data, lead time, etc. for that supplier on that transaction date.
It's quite tideous to press on the refresh button each time after selecting something when you want to run the queries. What I want is the user to select a supplier from the list, then simply click to run the queries, then selects a transaction date, and simply clicks again to run other queries. No more annoying button pressing.
Below is a listbox that shows the possible transaction dates after a certain supplier is selected from List1. [The dates are pulled via query from two different tables using the name of the supplier] The first image shows the data tab of the list's property sheet. The query is written in the "Row Source" field. The second picture shows the event tab of the list's property sheet.The "On Click" field is currently empty.
I've been playing around with the On Click field but had no luck. I put the query there, that did not work. I also tried the expression and macro builder but am struggling since I'm completely new to those access concepts.
Upvotes: 0
Views: 2370
Reputation: 744
Now I see the problem. All you have to do, is to assign the code of the "Run Query" button to event After Update
of every listbox you have on your form. The more clean way is to create some sort of sub like
Private Sub RunQueries()
--button code here
End Sub
And then create events for each listbox calling your sub
Private Sub List2_AfterUpdate()
Call RunQueries
End Sub
Upvotes: 2