Refresh / Inquire Problems with Combobox

After noon,

I am having problems updating my ComboBox while the form is open.

My data changes when the form is open, so the ComboBox needs to be updated as such, but I can't figure out how to do this. Seems to be the only way to close and then reopen the form, but I'm not real

The original source of the ComboBox is a Simple Select request. I've tried using requery, but it doesn't do anything.

Sub ComboBox_GotFocus()

Me.ComboBox.Requery

End Sub

      

Any ideas?

Cheers, Michael

+2


source to share


1 answer


Clear and repopulate the combo box.
The easiest way:

sSQL_Select = "SELECT * FROM SOMETABLE" 

Me.lstListBox.RowSource = "" 
Me.lstListBox.RowSource = sSQL_Select

      

Instead of using SQL Query, you can also explicitly add values ​​to the list.
In this, you can do something like:

Dim iList_Cnt As Integer
Dim iCnt As Integer

iList_Cnt = Me![lstListBox].ListCount

For iCnt = 0 To iList_Cnt - 1
    Me![lstListBox].RemoveItem 0
Next

      



After that, the list is updated:

lstListbox.AddItem("Smtg_Col1;Smtg_Col2;Smtg_Col3")

      

Scroll through the dropdown list to add multiple lines.

+4


source







All Articles