Access 2007 VBA - Open new form with values
Hi All,
Below is the example to open new form by passing value to another form in ACCESS-2007 through Code Editor (VBA Programme)
In original form
FORM-A
Code:
Private Sub Go_To_2ndForm_Click()
If Not IsNull(Me.ID) Then
DoCmd.OpenForm "2ndFormName", , , , , , Me.ID
Else
MsgBox "All details must be entered first!"
End If
End Sub
In the called form (2ndFormName in this)
FORM-B
Code:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
DoCmd.GoToRecord , , acNewRec
Me.ID = Me.OpenArgs
End If
End Sub
Below is the example to open new form by passing value to another form in ACCESS-2007 through Code Editor (VBA Programme)
In original form
FORM-A
Code:
Private Sub Go_To_2ndForm_Click()
If Not IsNull(Me.ID) Then
DoCmd.OpenForm "2ndFormName", , , , , , Me.ID
Else
MsgBox "All details must be entered first!"
End If
End Sub
In the called form (2ndFormName in this)
FORM-B
Code:
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
DoCmd.GoToRecord , , acNewRec
Me.ID = Me.OpenArgs
End If
End Sub
Comments
Post a Comment