Problem linking 2 Forms(Not Subforms) with primary key (1 Viewer)

DaaAgent

Registered User.
Local time
Yesterday, 23:16
Joined
Dec 5, 2005
Messages
49
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?
 

Users who are viewing this thread

Top Bottom