How do i reference a popup form in Access VBA

大憨熊 提交于 2020-07-23 11:12:32

问题


When I click on a button that creates a popup form, my VBA code Screen.ActiveForm still references the form containing the popup button, even when the popup form has focus. How do I reference the popup form in this case? So confused why Access doesn't register the popup with focus as the active form...


回答1:


You can use the Forms collection which lists all open forms

Forms!MyPopup

or, if you have invalid characters in the name of the form

Forms![My Popup]

or

Forms("My Popup")

You can access controls on it with

Forms![My Popup]!TextBox1



回答2:


when opening/creating the pop-up form, store the form name in a variable, then reference that variable when required.

dim sPopup$

sPopup="FRM_Popup"

docmd.openform sPopup

...reference popup form here using sPopup...


来源:https://stackoverflow.com/questions/34952388/how-do-i-reference-a-popup-form-in-access-vba

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