Hi All
In the past I have always used the code below to open Form B from Form A
dropping the NewRec if not required.
Started a new .mdb today and the PrimaryKey wouldn’t transfer when adding a new record in form B in the past the PrimaryKey was always already entered
Private Sub AddMedicalDetailsBT_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_ClientMedicalDetails"
stLinkCriteria = "[PAXID]=" & Me![PAXID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End Sub
Searched and got the answer http://www.access-programmers.co.uk/forums/showthread.php?t=69917&highlight=link+forms+add+record
Pat advised
“In the popup form, you need to add a line of code to the BeforeInsert event -
Me.YourKeyField = Forms!TheFirstForm!YourKeyField”
Added the extra Code worked perfectly but I am still puzzled what must I have done before ?
Any ideas?
In the past I have always used the code below to open Form B from Form A
dropping the NewRec if not required.
Started a new .mdb today and the PrimaryKey wouldn’t transfer when adding a new record in form B in the past the PrimaryKey was always already entered
Private Sub AddMedicalDetailsBT_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_ClientMedicalDetails"
stLinkCriteria = "[PAXID]=" & Me![PAXID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
End Sub
Searched and got the answer http://www.access-programmers.co.uk/forums/showthread.php?t=69917&highlight=link+forms+add+record
Pat advised
“In the popup form, you need to add a line of code to the BeforeInsert event -
Me.YourKeyField = Forms!TheFirstForm!YourKeyField”
Added the extra Code worked perfectly but I am still puzzled what must I have done before ?
Any ideas?