组合框重新查询不起作用 [英] Combo Box Requery Not Working

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

问题描述




我在表单上有一个组合框,其中包含一个基于单个字段城市表的城市列表。我还在此表单上有一个命令按钮,打开另一个表单,允许用户在新城市中输入到城市表。现在,在我将新城市推向市场之后,当我回到城市组合框中时,我添加的新城市不在列表中。我研究了教程,发现需要重新组合组合框以反映更新的表。以下是我在组合框的On Click事件的事件过程中放置​​的代码行:

Private Sub cboCity_Click()


Me.cboCity.Requery


结束子


我也尝试过:

我!cboCity.Requery

但这行代码也不起作用。我没有得到任何代码错误,但它并不重要。


现在我在After Update事件中尝试了这个,但没有运气。在我修改了城市桌子后,桌子不想重新查询。我能够反映变化的唯一方法是,如果我完全关闭表单并重新启动它,这不是我每次添加新城市时都想做的事情。


有什么建议吗?


谢谢你,

Wayne。

Hi,

I have a combo box on a form with a list of cities in it based on a single field city table. I also have a command button on this form that opens up another form that allows the user to enter in new cities to the city table. Now, after i dd new cities to the table, and when I go back to drop down the city combo box, the new cities I added aren''t in the list. I researched tutorials and found that combo boxes need to be requeried in order to reflect the updated table. Here is the line of code that I put in the event procedure for the On Click event of the combo box:

Private Sub cboCity_Click()

Me.cboCity.Requery

End Sub

I also tried:
Me!cboCity.Requery
but this line of code doesn''t work either. I get no code errors, but it doesn''t requery.

Now I tried this in the After Update event as well with no luck. The table just doesn''t want to requery itself after I''ve modified the city table. The only way I can get it to reflect the changes is if I close down the form completely and restart it, which is not something I want to do every time I add a new city.

Any suggestions?

Thank you,

Wayne.

推荐答案





我在表单上有一个组合框,其中包含一个基于单个字段城市表的城市列表。我还在此表单上有一个命令按钮,打开另一个表单,允许用户在新城市中输入到城市表。现在,在我将新城市推向市场之后,当我回到城市组合框中时,我添加的新城市不在列表中。我研究了教程,发现需要重新组合组合框以反映更新的表。以下是我在组合框的On Click事件的事件过程中放置​​的代码行:

Private Sub cboCity_Click()


Me.cboCity.Requery


结束子


我也尝试过:

我!cboCity.Requery

但这行代码也不起作用。我没有得到任何代码错误,但它并不重要。


现在我在After Update事件中尝试了这个,但没有运气。在我修改了城市桌子后,桌子不想重新查询。我能够反映变化的唯一方法是,如果我完全关闭表单并重新启动它,这不是我每次添加新城市时都想做的事情。


有什么建议吗?


谢谢,

Wayne。
Hi,

I have a combo box on a form with a list of cities in it based on a single field city table. I also have a command button on this form that opens up another form that allows the user to enter in new cities to the city table. Now, after i dd new cities to the table, and when I go back to drop down the city combo box, the new cities I added aren''t in the list. I researched tutorials and found that combo boxes need to be requeried in order to reflect the updated table. Here is the line of code that I put in the event procedure for the On Click event of the combo box:

Private Sub cboCity_Click()

Me.cboCity.Requery

End Sub

I also tried:
Me!cboCity.Requery
but this line of code doesn''t work either. I get no code errors, but it doesn''t requery.

Now I tried this in the After Update event as well with no luck. The table just doesn''t want to requery itself after I''ve modified the city table. The only way I can get it to reflect the changes is if I close down the form completely and restart it, which is not something I want to do every time I add a new city.

Any suggestions?

Thank you,

Wayne.



我也遇到过这个,但我不知道为什么它不起作用。所以我通常最终使用Me.Refresh。

I''ve come across this too but I don''t know why it won''t work. So I usually end up using a Me.Refresh.


在Add Cities窗体的On Close事件中,当你需要重新查询组合框时。
In the On Close event of the Add Cities form is when you need to requery the combobox.
展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号


你好兔子,


是的,这很奇怪。我甚至在我的代码中尝试了你的.Refresh。我在我的组合框中输入了我的点击事件,所以当我点击打开组合列表选项时,它应该立即刷新列表。嗯,你把你的Me.Refresh连接到什么事件?


Wayne。

Hi Rabbit,

Yeah it is strange. I even tried your Me.Refresh in my code. I put in in my click event on my combo box so when I click to open the combo list options, it should refresh the list immediately. hmmm, what event are you linking your Me.Refresh to?

Wayne.


我''我也遇到过这个,但我不知道为什么它不起作用。所以我通常最终使用Me.Refresh。
I''ve come across this too but I don''t know why it won''t work. So I usually end up using a Me.Refresh.


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

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