【发布时间】:2017-04-21 21:36:50
【问题描述】:
我正在使用 Excel VBA。我有两个用户表单: ClientInfo 和 ClientSearch
在 ClientSearch 中,我在 Excel 工作表中搜索以列出所有具有相同姓氏的客户。从那里,我选择我想要的客户端(通过突出显示列表中的名称并单击命令按钮 cmdOpenClientInfo)并确定它们的 ClientID(也在工作表中)。 然后,我想将此 ClientID 传递给 ClientInfo 表单,以便使用工作表中的相关数据填充此表单上的所有文本框:
在 ClientSearch 表单中编码:
Private Sub cmdOpenClientInfo_Click()
Dim ClientID As Integer
ClientID = textSrchClientID.value
'user msgbox to check to make sure I get the correct ClientID ... and I do
msgbox(ClientID)
Me.Hide
frmClientInfo.show
Call frmClientInfo.PopulateClientInfo(ClientID) 'this is where it fails
End Sub
在 ClientInfo 表单中编码:
Sub PopulateClientInfo(ClientID As Integer)
'this is where I would populate the text field
End Sub
例程总是卡在 调用 frmClientInfo.PopulateClientInfo(ClientID)
在上述情况下,我得到运行时错误“424”需要对象。
我尝试了这个论坛中提出的各种解决方案,但没有找到解决方案。
【问题讨论】: