Empty combobox values when access form loads vba

svuyyuru

Registered User.
Local time
Today, 08:56
Joined
Feb 10, 2014
Messages
33
I want to empty the combobox every time when form loads. Using the below code
Code:
Private Sub Form_Load() 
 
combo1.RowSource = ""
 
       End Sub

But Combobax is not emptying.
 
You will need to refresh the combobox thus:
Code:
[COLOR="Navy"]Private Sub[/COLOR] Form_Load()

    combo1.RowSource = ""
    [B][I]combo1.Requery[/I][/B]

[COLOR="navy"]End Sub[/COLOR]
 
No luck. Still i see values in combo
 
Is the combox RowSource being set by any other code in your access project?
 
yeah, OnEnter event of combo1 sets the Rowsource.
Code:
[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Private Sub Combo1_Enter()[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]Me.Combo1.RowSourceType = "Table/Query"
Me.Select_CM.RowSource = "Select F1 from Dropdownvalues ;" [/FONT][/SIZE]
[SIZE=3][FONT=Calibri][/FONT][/SIZE][SIZE=3][FONT=Calibri]
 
Wait a minute, your OnEnter code is referencing two different comboboxes, Combo1 and Select_CM. What is the name of the actual combobox with which you are concerned?
 
I forgot to change that name in post. Actually it looks like this
Code:
Private Sub Combo1_Enter()
Me.Combo1.RowSourceType = "Table/Query"
Me.Combo1.RowSource = "Select F1 from Dropdownvalues ;"
 
That explains it. When the form opens, the Form_Load code sets the combobox Rowsource to blank. However, the moment that the combobox gets the focus (i.e. User clicks on the combobox), the Combo1_Enter code is triggered, which populates the combobox Rowsource. Consequently, the combobox always displays the list of values from the Dropdownvalues query.
 

Users who are viewing this thread

Back
Top Bottom