Reset a combobox rowsource to it's default value

Saphirah

Active member
Local time
Today, 21:39
Joined
Apr 5, 2020
Messages
162
Hello everyone,

i have a combobox in an access form. The rowsource is set to a table in my database.
Now whenever the user does a specific action i change the row source using VBA to display different values.
Whenever i close the form and reopen it again, the rowsource is set back to it's default value.

Now is there a possibility to "reset" the row source to it's default value using VBA without closing the form?

I know i can simply store the rowsource in a variable when opening the form, so this is more of a "good to know".
But there might be an easier solution!

Thanks for your help everyone ;)
 
Now whenever the user does a specific action i change the row source using VBA to display different values.
I recommend that you make one of the different values the "default". And based on your logic set the rowsource to that value as appropriate.
 
I recommend that you make one of the different values the "default". And based on your logic set the rowsource to that value as appropriate.
I think you misunderstood my intentions. What i wanted to do is reset the row source to it's default value.
So i change the Row Source SQL String, to show different data using VBA. How do i revert back to it's default value/state?
How do i revert back to the row source that is set when i opened the form?
 
when the Form Load event, save the rowsource of the combo to variable:
you can add a command button to reinstate the combo:

option compare database
option explicit

Dim combo_rowsource as string

private form_load()
combo_rowsource = me!combo.rowsource
end sub

'say your command button is named button1:

private sub button1_click()
me!combo.rowsource = combo_rowsource
end sub
 
when the Form Load event, save the rowsource of the combo to variable:
you can add a command button to reinstate the combo:

option compare database
option explicit

Dim combo_rowsource as string

private form_load()
combo_rowsource = me!combo.rowsource
end sub

'say your command button is named button1:

private sub button1_click()
me!combo.rowsource = combo_rowsource
end sub
Alright, guess i will go with that :)
 

Users who are viewing this thread

Back
Top Bottom