通过单独的表单添加新值后刷新ComboBox [英] Refresh ComboBox After Adding New Values via a Separate Form

查看:83
本文介绍了通过单独的表单添加新值后刷新ComboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我遇到的问题与刷新表格中描述的问题类似。使用在单独的表单上添加新值后未刷新的ComboBox发布。第二种形式是通过标准的DoCmd调用打开的。


我试过在AfterUpdate,Form_Current等中添加Requery无济于事....测试表格有组合框和命令按钮。


这是我的测试代码:

Hi,

I''ve been having a similar issue to what is described in the "refresh a form" post with a ComboBox that is not being refreshed after adding a new value on a seperate form. The second form is being opened via the standard DoCmd call.

I''ve tried adding Requery in AfterUpdate, Form_Current, etc. to no avail.... The test form has the combobox and a command button.

Here''s my test code:

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号

推荐答案





我遇到的问题类似于刷新表格使用在单独的表单上添加新值后未刷新的ComboBox发布。第二种形式是通过标准的DoCmd调用打开的。


我试过在AfterUpdate,Form_Current等中添加Requery无济于事....测试表格有组合框和命令按钮。


这是我的测试代码:

Private Sub cmdAddCatgCd_Click()

On Error GoTo Err_cmdAddCatgCd_Click


Dim stDocName As String

Dim stLinkCriteria As String


stDocName =" subfrmHierCatgCd"

DoCmd.OpenForm stDocName ,,, stLinkCriteria


Exit_cmdAddCatgCd_Click:

退出子


Err_cmdAddCatgCd_Click:

MsgBox Err.Description

恢复Exit_cmdAddCatgCd_Click

结束子

私有子Form_AfterUpdate()

Me.Combo21.Requery

End Sub

Private Sub Form_Current()

Me.Combo21.Requery

End Sub


cmdAddCatgCd_Click打开另一个表单以维护Combo21中填充的代码值。


到目前为止,我能够让这个工作的唯一方法是添加一个刷新&qu OT;命令按钮包含以下代码:

私有子Command25_Click()

错误GoTo Err_Command25_Click


Me.Combo21.Requery


Exit_Command25_Click:

退出子


Err_Command25_Click:

MsgBox Err.Description

恢复退出_Command25_Click


结束子


我更喜欢重新查询自动发生表格和子表格.....


谢谢,Ed。
Hi,

I''ve been having a similar issue to what is described in the "refresh a form" post with a ComboBox that is not being refreshed after adding a new value on a seperate form. The second form is being opened via the standard DoCmd call.

I''ve tried adding Requery in AfterUpdate, Form_Current, etc. to no avail.... The test form has the combobox and a command button.

Here''s my test code:

Private Sub cmdAddCatgCd_Click()
On Error GoTo Err_cmdAddCatgCd_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "subfrmHierCatgCd"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdAddCatgCd_Click:
Exit Sub

Err_cmdAddCatgCd_Click:
MsgBox Err.Description
Resume Exit_cmdAddCatgCd_Click
End Sub

Private Sub Form_AfterUpdate()
Me.Combo21.Requery
End Sub

Private Sub Form_Current()
Me.Combo21.Requery
End Sub

cmdAddCatgCd_Click opens another form to maintain the code values that are populated in Combo21.

So far, the only way I''ve been able to get this to work is by adding a "Refresh" command button with the following code:

Private Sub Command25_Click()
On Error GoTo Err_Command25_Click

Me.Combo21.Requery

Exit_Command25_Click:
Exit Sub

Err_Command25_Click:
MsgBox Err.Description
Resume Exit_Command25_Click

End Sub

I''d prefer having the requery happen automatically for both forms and subforms.....

Thanks, Ed.



您是否尝试过在该其他线程中发布的解决方案?

Have you tried the solutions that were posted in that other thread?



您是否尝试过在该其他线程中发布的解决方案?
Have you tried the solutions that were posted in that other thread?



是的。最初,我回复那篇文章暗示这一点,但NeoPa告诉我,我必须开始一个新线程,所以我做了。


我认为我遇到的部分问题是表格之间没有直接联系。打开第二个表单后,以主表单(DoCmd)执行的代码将继续完成。它不会等待用户关闭第二个表单....


命令按钮代码打开第二个表单:

Yes. Originally, I replied to that post to imply this but NeoPa told me I had to start a new thread so I did.

I think part of the problem I''m having is that there''s no direct link between the forms. Once the second form is opened, the code being executed in the main form (DoCmd) continues to completion. It doesn''t wait for the user to close the second form....

Code from Command Button to open second form:

展开 | 选择 | Wrap | 行号


如何将刷新/重新查询代码放在第二种形式中?也许在On Close事件中,它也可以刷新/重新查询第一个表单。
What about putting the refresh/requery code in the second form? Perhaps in the On Close event it can also refresh/requery the first form.


这篇关于通过单独的表单添加新值后刷新ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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