由于这是我第一次这样做,所以我想知道获得结果的最佳方法或正确方法。
我有一个表单(报价),其中有一个列表框用于添加项目。我还有另一种形式(搜索项目),可以在其中找到数据库中的所有项目。我想做的是从“搜索项目”框中获取一个项目,并将其放入“报价单列表”框中。
我当时正在考虑放置一个全局变量,该变量将存储项目的ID,并将其用作定位参考,以粘贴到报价列表框中。
这是正确的方法还是我在这里错过了什么?
答案 0 :(得分:0)
要引用您当前使用的表单:
Me
要以您当前使用的形式引用文本框控件:
Me.txtbox_name_here
要引用其他表单中的表单:
Dim frm As Form
'first you need to open the form to reference it
DoCmd.OpenForm "form name here", acNormal
'references the form the form
Set frm = Forms("form name here")
'when you're done remember to close the form with this
DoCmd.Close acForm, "form name here", acSaveYes
要使用我之前创建的frm变量来引用另一个表单的文本框控件:
frm.txtbox_name_here
这应该是足够的信息,供您入门。