Solved: Triggering Combo Box Refresh
Hello everyone... First time post [please be gentle...]
I am hoping that someone can guide me to a mechanism that I can use to forcibly refresh a ComboBox content based on a form-related event. Right now I am quite unable to do this, but also 99% certain that my process for priming my ComboBox in the first place is also likely *really* bad practice [so a suggestion on improvement would also be very welcome].
Here's the context... [and in case this is relevant, I am using Access2013].
I am using a "Menu" form to act as a routing mechanism to allow a user to move between different forms within my Access App. One set of functions involves the creation, maintenance and potential deletion of Parameters, which are essentially simple rows in a "Name-Value Pair" table.
I have 2 activity-related Forms associated with these Parameter records [Update] and [Delete]. I could use a single form, but am splitting because my Menu form also allows me to apply role-based access control, so I am being quite atomic with the functionality I put on each form...
On both my "Mod Parameter" and "Delete Parameter" forms, I have some truly horrible code in my "Form_Load()" method:-
Now comes the crunch... If I go back to my "Mod" form and check my Combo box, the relevant item now shows as "#Deleted". I can quickly correct this at run-time by hitting F5, but that seems crude...
One more relevant piece of information.... Each time I move between forms, my VBA logic does something a bit like this:-
I'd be very grateful, therefore, for some advice... I can move the SQL logic for the Combo Boxes into a dedicated query and associate that with the boxes to do the initial data load, but I am struggling to see what Form-related event I can use to enable me to trigger a ".refresh" or ".reload" method... Specifically, does "DoCmd.OpenForm" pass an event handle to the Form in question? Can a Form that is opened like this "know" that it has been opened?
Any advice would be much appreciated. Congratulations on reading all the way to here...
Thanks in advance for any guidance!
Hello everyone... First time post [please be gentle...]
I am hoping that someone can guide me to a mechanism that I can use to forcibly refresh a ComboBox content based on a form-related event. Right now I am quite unable to do this, but also 99% certain that my process for priming my ComboBox in the first place is also likely *really* bad practice [so a suggestion on improvement would also be very welcome].
Here's the context... [and in case this is relevant, I am using Access2013].
I am using a "Menu" form to act as a routing mechanism to allow a user to move between different forms within my Access App. One set of functions involves the creation, maintenance and potential deletion of Parameters, which are essentially simple rows in a "Name-Value Pair" table.
I have 2 activity-related Forms associated with these Parameter records [Update] and [Delete]. I could use a single form, but am splitting because my Menu form also allows me to apply role-based access control, so I am being quite atomic with the functionality I put on each form...
On both my "Mod Parameter" and "Delete Parameter" forms, I have some truly horrible code in my "Form_Load()" method:-
Dim strSQL As String
strSQL = "SELECT nvpName, nvpID from tblNVP"
Me!nvpModSelect.RowSource = strSQL
OK, so far so good.... [No, not really... I know that's awful and as soon as I figure out how, I will fix that]. I can load the "Mod" Form, select, edit and save a Parameter record and all is good. I can then quit the "Mod" Form, go back via the Menu to the "Delete" Form, and delete the Parameter I've just modified. Everything is still working OK... strSQL = "SELECT nvpName, nvpID from tblNVP"
Me!nvpModSelect.RowSource = strSQL
Now comes the crunch... If I go back to my "Mod" form and check my Combo box, the relevant item now shows as "#Deleted". I can quickly correct this at run-time by hitting F5, but that seems crude...
One more relevant piece of information.... Each time I move between forms, my VBA logic does something a bit like this:-
Me.Visible = False
DoCmd.OpenForm "frmMenu"
Navigating around this application works perfectly, as do all my mechanisms to maintain the contents of this and other tables. I realise that my code is not working because the Form_Load() event only gets called on the initial load - and that using "Me.Visible = False" isn't un-loading the Form, just hiding it. I'm also aware that my initial logic to prime these ComboBoxes absolutely stinks...DoCmd.OpenForm "frmMenu"
I'd be very grateful, therefore, for some advice... I can move the SQL logic for the Combo Boxes into a dedicated query and associate that with the boxes to do the initial data load, but I am struggling to see what Form-related event I can use to enable me to trigger a ".refresh" or ".reload" method... Specifically, does "DoCmd.OpenForm" pass an event handle to the Form in question? Can a Form that is opened like this "know" that it has been opened?
Any advice would be much appreciated. Congratulations on reading all the way to here...
Thanks in advance for any guidance!
Last edited: