OpenArgs
The OpenArgs property gives you a way to pass information to a form as it's being opened. The OpenArgs argument of the OpenForm method is used to populate a form's OpenArgs property at runtime. It works like this:DoCmd.OpenForm "frmPaymentMethods", _
Datamode:=acFormAdd, _
WindowMode:=acDialog, _
OpenArgs:=NewData
This code is found in the time and billing application's frmPayments form. It opens the frmPaymentMethods form when a new method of payment is added to the cboPaymentMethodID combo box. It sends the frmPaymentMethods form an OpenArg of whatever data is added to the combo box. The Load event of the frmPaymentMethods form looks like this:Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me.txtPaymentMethod.Value = Me.OpenArgs
End If
End Sub
This code sets the txtPaymentMethod text box value to the value passed as the opening argument. This occurs only when the frmPaymentMethods form is opened from the frmPayments form.