I want to pass a variable to another form which opens with OpenForm. My form open event does not seem to be called. Maybe I am not referring to it correctly. The print statement in the first subroutine is correct, but the Debug.Print "A" never happens. Also, once this variable is passed to the new form, how do I use it in an SQL statment?
Private Sub DataObjectsWhereUsed_Click()
Dim dataId As String
dataId = Me.DataObjectsList.Column(2)
Debug.Print dataId
DoCmd.OpenForm FormName:="ProcessByDataObject", OpenArgs:=dataId
End Sub
Public Sub ProcessByDataObject_Open()
Dim dataObject As Variant
Debug.Print "A"
If Not IsNull(Me.OpenArgs) Then
dataObject.Value = Me.OpenArgs
End If
End Sub
Your Public Sub ProcessByDataObject_Open()
is never called.
Use the Form_Open
event of the ProcessByDataObject form:
Private Sub Form_Open(Cancel As Integer)
Dim dataObject As Variant
Debug.Print "A"
If Not IsNull(Me.OpenArgs) Then
dataObject.Value = Me.OpenArgs
End If
End Sub