我一直在尝试了解如何从不同的模块引用子表单控件。许多论坛都指向以下链接: http ://access.mvps.org/access/forms/frm0031.htm
我还没有成功地将它添加到我的代码中。不确定我是否失踪了。
从第一个表单开始,当用户单击命令按钮时,将运行以下代码:
Private Sub Command3_Click()
policyid = Me.PolicyList
Call openpolicy(policyid)
End Sub
从模块 1:
Public Sub openpolicy(policyid)
DoCmd.OpenForm ("frmPolicyDetails")
Dim dbs As DAO.Database
Dim rcd As DAO.Recordset
Set dbs = CurrentDb
Set rcd = dbs.OpenRecordset("Select * from Policy Inner join client on client.clientid = policy.clientid where Policy.id = " & policyid)
Forms!Frmpolicydetails.selectedpolicy = rcd("PolicyNumber")
Forms!Frmpolicydetails.selectedName = rcd("FirstName") & " " & rcd("LastName")
'Trying to update subform textbox
Forms!frmpolicydetails!frmpolicyInfo.policynumber = rcd("PolicyNumber")
End Sub
“FrmPolicyInfo”是导航表单指向的“目标名称”,“PolicyNumber”是子表单上的控件名称
有任何想法吗?