"无效使用null"调用OpenForm

时间:2015-08-18 09:01:56

标签: vba ms-access ms-access-2010

我找不到原因,但在使用OpenArgs

时,我一直无效使用null

代码设置为

Private Sub cmdContactDetails_Click()
    Dim ArgsString As String

    ArgsString = Forms!LeadList![Entrepreneur Name] & "," & Forms!LeadList![Telephone Number] & "," & Forms!LeadList![Email Address]
    DoCmd.OpenForm "ContactDetails", , , , , , ArgsString
End Sub

这导致字符串" X,123456789,test @ test"

在Form_Open的联系方式中,我有:

Dim SaveString As String  
SaveString = Forms!ContactDetails.OpenArgs

但是这给了我一个"无效使用Null"即使没有任何东西是空的。

1 个答案:

答案 0 :(得分:0)

假设您有一个名为: - " LeadList"

的表单

并且表单还有一个名为的文本框: - " Entrepreneur_Name"

,此表单包含以下代码: -

Option Compare Database
Option Explicit

Private Sub cmdContactDetails_Click()
Dim ArgsString As String

    ArgsString = Me.Entrepreneur_Name
    DoCmd.OpenForm "ContactDetails", , , , , , ArgsString

End Sub

上面的代码是通过名为" cmdContactDetails"的命令按钮调用的。在名为的表格上: - " LeadList"然后表格" ContactDetails"将打开(表单" ContactDetails"必须先关闭)并且on open事件将运行此代码: -

Option Compare Database
Option Explicit

Private Sub Form_Open(Cancel As Integer)
Dim SaveString As String

    SaveString = Forms!ContactDetails.OpenArgs
    MsgBox " >>> " & SaveString

End Sub

消息框将显示通过打开的args函数从表格" LeadList"中传输的文本内容。文本框" Entrepreneur_Name"