Refresh/Requery Combobox problems

时光怂恿深爱的人放手 提交于 2019-12-11 00:10:00

问题


Afternoon,

I have having problems getting my ComboBox to update while the form it is on is open.

My data changes while the form is open, so the ComboBox needs to be refreshed as such but I can't work out how. It seems the only way is to close and then reopen the form, but I don’t real

The ComboBox's raw source is a Simple Select query. I have tried using requery, but it doesn’t seem to do anything.

Sub ComboBox_GotFocus()

Me.ComboBox.Requery

End Sub

Any ideas?

Cheers, Michael


回答1:


Empty and re-fill the combobox.
The easiest would be:

sSQL_Select = "SELECT * FROM SOMETABLE" 

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

Instead of using the SQL Query, you can also explicitly add values to a listbox.
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

Followed by refilling the listbox:

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

Loop through the combobox for adding multiple rows.



来源:https://stackoverflow.com/questions/14471679/refresh-requery-combobox-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!