G
Guest
Hi, Allen. I used your suggested code (from your answer to 'Command Button Duplicate for Forms and Subforms' on 12/17/03) to duplicate some recods entered into a form along with the subform records. It will compile, and dupe the main form data, but not the subform data. Here is my code so far (it's long, but the only way I know to show you)
Private Sub DupeAppMerch_Click(
Dim sSQL As Strin
Dim db As DAO.Databas
Dim NewContNum As Strin
Set db = DBEngine(0)(0
If Me.Dirty Then 'Save firs
Me.Dirty = Fals
End I
If Me.NewRecord The
MsgBox "Select the record to duplicate.
Else 'Duplicate the main recor
With Me.RecordsetClon
.AddNe
!ContractNumber = Me.AppMerchContrac
!AppMerchContract = Me.ContractNumbe
!AppMerch = "M
!CoProgContract = Me.CoProgContrac
!DateEntered = Me.DateEntere
!DateOrdered = Me.DateOrdere
.Updat
.Bookmark = .LastModifie
NewContNum = !ContractNumbe
'Duplicate the related records from form App Contract Sub - Do I need another AddNew
If Me.[App Contract Sub].Form.RecordsetClone.RecordCount > 0 The
sSQL = "INSERT INTO [Contract Details](ContractNumber, " &
"StoreID, ArrivalDate) " &
"SELECT " & NewContNum & " AS ContractNumber, " &
"[Contract Details].StoreID, [Contract Details].ArrivalDate " &
"FROM [Contract Details]" &
"WHERE ([Contract Details].ContractNumber = " & Me.ContractNumber & ");
'Duplicate the related records from form Merch Contracts Sub - Do I need another AddNew
ElseIf Me.[Merch Contracts Sub].Form.RecordsetClone.RecordCount > 0 The
sSQL = "INSERT INTO [Contract Details](ContractNumber, " &
"StoreID) " &
"SELECT " & NewContNum & " AS ContractNumber, [Contract Details].StoreID " &
"FROM [Contract Details]" &
"WHERE ([Contract Details].ContractNumber = " & Me.ContractNumber & ");
db.Execute sSQL, dbFailOnErro
Els
MsgBox "Worksheet information duplicated, but there were no details for Appearances or Merchandise.
End I
'Display the duplicat
Me.Bookmark = .LastModifie
End Wit
End I
Set db = Nothin
End Su
Private Sub DupeAppMerch_Click(
Dim sSQL As Strin
Dim db As DAO.Databas
Dim NewContNum As Strin
Set db = DBEngine(0)(0
If Me.Dirty Then 'Save firs
Me.Dirty = Fals
End I
If Me.NewRecord The
MsgBox "Select the record to duplicate.
Else 'Duplicate the main recor
With Me.RecordsetClon
.AddNe
!ContractNumber = Me.AppMerchContrac
!AppMerchContract = Me.ContractNumbe
!AppMerch = "M
!CoProgContract = Me.CoProgContrac
!DateEntered = Me.DateEntere
!DateOrdered = Me.DateOrdere
.Updat
.Bookmark = .LastModifie
NewContNum = !ContractNumbe
'Duplicate the related records from form App Contract Sub - Do I need another AddNew
If Me.[App Contract Sub].Form.RecordsetClone.RecordCount > 0 The
sSQL = "INSERT INTO [Contract Details](ContractNumber, " &
"StoreID, ArrivalDate) " &
"SELECT " & NewContNum & " AS ContractNumber, " &
"[Contract Details].StoreID, [Contract Details].ArrivalDate " &
"FROM [Contract Details]" &
"WHERE ([Contract Details].ContractNumber = " & Me.ContractNumber & ");
'Duplicate the related records from form Merch Contracts Sub - Do I need another AddNew
ElseIf Me.[Merch Contracts Sub].Form.RecordsetClone.RecordCount > 0 The
sSQL = "INSERT INTO [Contract Details](ContractNumber, " &
"StoreID) " &
"SELECT " & NewContNum & " AS ContractNumber, [Contract Details].StoreID " &
"FROM [Contract Details]" &
"WHERE ([Contract Details].ContractNumber = " & Me.ContractNumber & ");
db.Execute sSQL, dbFailOnErro
Els
MsgBox "Worksheet information duplicated, but there were no details for Appearances or Merchandise.
End I
'Display the duplicat
Me.Bookmark = .LastModifie
End Wit
End I
Set db = Nothin
End Su