刷新/重新查询组合框的问题 [英] Refresh/Requery Combobox problems

查看:261
本文介绍了刷新/重新查询组合框的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午,

我也有问题,让我的组合框更新而形式,它是对是开放的。

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

组合框的原始来源是一个简单的SELECT查询。我已经使用重新查询尝试,但它似乎并没有做任何事情。

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

任何想法?

干杯, 迈克尔

推荐答案

清空并重新填充组合框。
最简单的是:

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

sSQL_Select = "SELECT * FROM SOMETABLE" 

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

而不是使用SQL查询,还可以明确值添加到列表框。
在此,你可以这样做:

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.

这篇关于刷新/重新查询组合框的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆