G
Guest
I have a main form with a button on it that calls another form. The button
has the following code:
==================================
Private Sub Add_new_payment_Click()
On Error GoTo Err_Add_new_payment_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Frm_Payments"
stLinkCriteria = "[GroupID]=" & Me![GroupID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Add_new_payment_Click:
Exit Sub
Err_Add_new_payment_Click:
MsgBox Err.Description
Resume Exit_Add_new_payment_Click
End Sub
========================
Currently when there is already payments associated with the group ID it
will pull all those payments and the form will open on the first record it
found. However if there is no payments, the form opens with the group ID as
zero.
I need the button to do two things:
1. populate the "Group ID" field with the same group ID from the record I
was on when I hit the button.
2. when there are more than one record it should pull all the records and
automatically also go to a new record with the group ID populated (basically
add a new payment but also pull the existing ones as it does now).
Can anyone take a swing at adjusting the code to do that. I would greatly
appreciate it. Thank you in advance.
Wael.
has the following code:
==================================
Private Sub Add_new_payment_Click()
On Error GoTo Err_Add_new_payment_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Frm_Payments"
stLinkCriteria = "[GroupID]=" & Me![GroupID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Add_new_payment_Click:
Exit Sub
Err_Add_new_payment_Click:
MsgBox Err.Description
Resume Exit_Add_new_payment_Click
End Sub
========================
Currently when there is already payments associated with the group ID it
will pull all those payments and the form will open on the first record it
found. However if there is no payments, the form opens with the group ID as
zero.
I need the button to do two things:
1. populate the "Group ID" field with the same group ID from the record I
was on when I hit the button.
2. when there are more than one record it should pull all the records and
automatically also go to a new record with the group ID populated (basically
add a new payment but also pull the existing ones as it does now).
Can anyone take a swing at adjusting the code to do that. I would greatly
appreciate it. Thank you in advance.
Wael.