B
Ben
I have the following code that duplicates the main form, but not the subform.
With Me.RecordsetClone
.AddNew
!ProjectName = Me.ProjectName
!DEASRALeads = Me.DEASRALeads
!Phase1 = Me.Phase1
!Phase2 = Me.Phase2
!Phase3 = Me.Phase3
!Phase4 = Me.Phase4
!Phase5 = Me.Phase5
!Phase1Status = Me.Phase1Status
!Phase2Status = Me.Phase2Status
!Phase3Status = Me.Phase3Status
!Phase4Status = Me.Phase4Status
!Phase5Status = Me.Phase5Status
!Other = Me.Other
'etc for other fields.
.Update
'Save the primary key value, to use as the foreign key for the
related records.
.Bookmark = .LastModified
lngID = !WebFarmID
'Duplicate the related records: append query.
If Me.[frmWebFarmAIs].Form.RecordsetClone.RecordCount > 0 Then
strSql = "INSERT INTO [tblWebFarmAIs] ( WebFarmAIID,
ActionItemsNew, Owner, WebFarmID ) " & _
"SELECT " & lngID & " As NewID, WebFarmAIID,
ActionItemsNew, Owner, WebFarmID " & _
"FROM [tblWebFarmAIs] WHERE WebFarmID = " & Me.WebFarmID
& ";"
'DBEngine(0)(0).Execute strSql, dbFailOnError
Else
MsgBox "Main record duplicated, but there were no related
records."
End If
'Display the new duplicate.
Me.Bookmark = .LastModified
End With
Please help
Ben
With Me.RecordsetClone
.AddNew
!ProjectName = Me.ProjectName
!DEASRALeads = Me.DEASRALeads
!Phase1 = Me.Phase1
!Phase2 = Me.Phase2
!Phase3 = Me.Phase3
!Phase4 = Me.Phase4
!Phase5 = Me.Phase5
!Phase1Status = Me.Phase1Status
!Phase2Status = Me.Phase2Status
!Phase3Status = Me.Phase3Status
!Phase4Status = Me.Phase4Status
!Phase5Status = Me.Phase5Status
!Other = Me.Other
'etc for other fields.
.Update
'Save the primary key value, to use as the foreign key for the
related records.
.Bookmark = .LastModified
lngID = !WebFarmID
'Duplicate the related records: append query.
If Me.[frmWebFarmAIs].Form.RecordsetClone.RecordCount > 0 Then
strSql = "INSERT INTO [tblWebFarmAIs] ( WebFarmAIID,
ActionItemsNew, Owner, WebFarmID ) " & _
"SELECT " & lngID & " As NewID, WebFarmAIID,
ActionItemsNew, Owner, WebFarmID " & _
"FROM [tblWebFarmAIs] WHERE WebFarmID = " & Me.WebFarmID
& ";"
'DBEngine(0)(0).Execute strSql, dbFailOnError
Else
MsgBox "Main record duplicated, but there were no related
records."
End If
'Display the new duplicate.
Me.Bookmark = .LastModified
End With
Please help
Ben