I've got a weird situation that I can't figure out what is happening. On Form1, I have a button to open another form using the following code:
Since I don't like to count on the openargs variable for a long time with the form open, I created a module level variable to store the value in OpenArgs.
So I put the break point on the Docmd.OpenForm. With that highlighted, I entered the following in the immediate window and ran it.
Since the form isn't opened yet, I get the invalid use of null error as I would expect. I then step to the setting of the variable and that runs fine. So with the End Sub from the On_Open event highlighted, I run my immediate window command again and I know get the value that I passed through the OpenArgs parameter. Again, as I would expect. I press F8 once more and now I have the End Sub from the button's event highlighted and I run my immediate window again and now it returns 0. Why did the value of lngCustomerID change? frmAuthorizedPe ople is a split form, it isn't modal, isn't popup. I can't think of any other details that might help solve this. I have done this many times and never had a problem. I also checked to see what the form's openargs value was and it stayed correct even while the variable changed to 0.
Code:
DoCmd.OpenForm FormName:="frmAuthorizedPeople", _
WhereCondition:="CustomerID_fk = " & Me!CustID_pk, _
OpenArgs:=Me!CustID_pk
Code:
Private Sub Form_Open(Cancel As Integer) lngCustomerID = Me.OpenArgs End Sub
Code:
?Form_frmAuthorizedPeople.lngCustomerID
Comment