D
Desert Bear
can someone tell me how to get a newly created primary key into the foreign key field of relate records? Here's the code
Private Sub cmdCopyPlanVersion_Click(
'Make a complete copy of the Plan Version in tblVersion and tblPlanTask
On Error GoTo Err_cmdCopyPlanVersion_Clic
Dim stDocName As Strin
Dim intpverID As Intege
'Run an update query to set all of current person's versions to no. Works
stDocName = "qupdActiveVersionNo
DoCmd.OpenQuery stDocName, acNormal, acEdi
DoCmd.Close acQuery, stDocName, acSaveYe
'Run an append query to make a new VERSION recor
stDocName = "qryCopyPlanVersionRecord" 'Do NOT change this query's name
DoCmd.OpenQuery stDocName, acNormal, acEdi
Me.pverPlanVersionActive =
intpverID = Me.pverPlanVersionID.Valu
intpverID = LastPlanVersion.Value 'LastPlanVersion is a correctly set 'text' field in the form
DoCmd.Close acQuery, stDocName, acSaveYe
DoCmd.RunCommand acCmdSaveRecord 'force save of new version recor
'Run an append query to make a copy of all Plan Tasks for the new Plan Version recor
stDocName = "qryCopyPlanTaskRecords" 'Do NOT change this query's name
DoCmd.OpenQuery stDocName, acNormal, acEdi
'pverPlanVersionID.Value = DMax("pverPlanVersionID", "tblVersion") 'field not update
'pverPlanVersionID.Value = intpverID ' error, field not update
DoCmd.Close acQuery, stDocName, acSaveYe
Exit_cmdCopyPlanVersion_Click
Exit Su
Private Sub cmdCopyPlanVersion_Click(
'Make a complete copy of the Plan Version in tblVersion and tblPlanTask
On Error GoTo Err_cmdCopyPlanVersion_Clic
Dim stDocName As Strin
Dim intpverID As Intege
'Run an update query to set all of current person's versions to no. Works
stDocName = "qupdActiveVersionNo
DoCmd.OpenQuery stDocName, acNormal, acEdi
DoCmd.Close acQuery, stDocName, acSaveYe
'Run an append query to make a new VERSION recor
stDocName = "qryCopyPlanVersionRecord" 'Do NOT change this query's name
DoCmd.OpenQuery stDocName, acNormal, acEdi
Me.pverPlanVersionActive =
intpverID = Me.pverPlanVersionID.Valu
intpverID = LastPlanVersion.Value 'LastPlanVersion is a correctly set 'text' field in the form
DoCmd.Close acQuery, stDocName, acSaveYe
DoCmd.RunCommand acCmdSaveRecord 'force save of new version recor
'Run an append query to make a copy of all Plan Tasks for the new Plan Version recor
stDocName = "qryCopyPlanTaskRecords" 'Do NOT change this query's name
DoCmd.OpenQuery stDocName, acNormal, acEdi
'pverPlanVersionID.Value = DMax("pverPlanVersionID", "tblVersion") 'field not update
'pverPlanVersionID.Value = intpverID ' error, field not update
DoCmd.Close acQuery, stDocName, acSaveYe
Exit_cmdCopyPlanVersion_Click
Exit Su