Hi
I've got 2 forms set up, in such a way as a user can click on a button on the first form, and it opens the second form showing data related to the first form.
This works ok. When a user tries to add in an extra record in the second form, there is a primary key violation error because the new record on the 2nd form does not automatically fill in the primary key value.
The code in the button that launches the second form is as follows
***************************
Private Sub Pcuttings_Click()
On Error GoTo Err_Pcuttings_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Press Cutting details Subform"
stLinkCriteria = "[Activity ID]=" & Me![Record Number]
DoCmd.OpenForm
Exit_Pcuttings_Click:
Exit Sub
Err_Pcuttings_Click:
MsgBox Err.Description
Resume Exit_Pcuttings_Click
End Sub
****************************
Can anyone tell me how to automatically set the primary key field for any new records added in the second form to relate to the primary key value on the record that the 2nd form was launched from.
I desperately need to fix this before tomorrow morning, so any ideas are most appreciated!
G
I've got 2 forms set up, in such a way as a user can click on a button on the first form, and it opens the second form showing data related to the first form.
This works ok. When a user tries to add in an extra record in the second form, there is a primary key violation error because the new record on the 2nd form does not automatically fill in the primary key value.
The code in the button that launches the second form is as follows
***************************
Private Sub Pcuttings_Click()
On Error GoTo Err_Pcuttings_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Press Cutting details Subform"
stLinkCriteria = "[Activity ID]=" & Me![Record Number]
DoCmd.OpenForm
Exit_Pcuttings_Click:
Exit Sub
Err_Pcuttings_Click:
MsgBox Err.Description
Resume Exit_Pcuttings_Click
End Sub
****************************
Can anyone tell me how to automatically set the primary key field for any new records added in the second form to relate to the primary key value on the record that the 2nd form was launched from.
I desperately need to fix this before tomorrow morning, so any ideas are most appreciated!
G