1
votes

I have an Access database with a Form that, once the EmployeeID is double-clicked, then it opens another form that contains a subform with employee information. I obtain the EmployeeID from the original form with this code...

myID = CInt(Me.OpenArgs)

I use this string on my secondary form and the subform contained within, however, it is not picking up the EmployeeID. The main form has this code for the Double-Click event...

Private Sub EmployeeID_DblClick(cancel As Integer)
Dim myID As Variant 
myID = Me.EmployeeID

DoCmd.OpenForm "subformEmployeeInfo",,,,,,myID
DoCmd.OpenForm "frm_EmployeeInformation",,,,,,myID
End Sub

When I step through the code I notice that my ID is there on the OpenForm Command but when it switches to the subform code I get an "Invalid Use of Null" error.

1
That is a little confusing. A subform has very little life of its own, it is a child of the parent form and cannot be referred to by name. What are you trying to do? - Fionnuala
I need the code in my subform to recognize the EmployeeID from my parent form in order to make the subform work properly - designspeaks

1 Answers

0
votes

With a subform, you can refer to the Parent OpenArgs,:

ID= Me.Parent.OpenArgs

These are the OpenArgs of the form on which the subform resides.