G
Guest
I have a main form (form Contracts TR, from table Contracts) w 2 subforms (both from table Contract Details). On main, I have Contract# (pk) and an AppMerchContract# for the corresponding contract. I want to copy all but 2 of the fields in main form along with its subform info into a new record, and switch the Contract# to become the AppMerchContract#, and take the AppMerchContract# and make it the Contract# of the new record, so I have the new record with all the similar data for a start.
I have this code which I've adapted, but I haven't done programming in years and am not too familiar w this, so please help. I'm getting compile error at the end of the WHERE, but I'm really not sure if I have this correct anyway, or backwards..
Private Sub Command98_Click(
Dim sSQL As Strin
Dim db As Acces
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.AppMerchContract 'Is this the correct way to swap
!AppMerchContract = Me.ContractNumbe
!AppMerch = Me.AppMerc
!AHEmail = Me.AHEmail
![4WeekPurchStart] = Me.[4WeekPurchStart] 'Will this [] work for name w a number
.... 'Blah, blah the rest of my fields in main for
.Updat
.Bookmark = .LastModifie
NewContNum = !ContractNumbe
If Me.[fContracts TR].Form.RecordsetClone.RecordCount > 0 Then 'Duplicate the related record
sSQL = "INSERT INTO [Contract Details](ContractNumber, " &
"StoreID, MerchSKU, ..., DelivInstr) &"
"SELECT " & NewContNum & " AS ContractNumber, " &
"[Contract Details].StoreID, [Contract Details].MerchSKU, " &
...................
"[Contract Details].SendPOP, [Contract Details].DelivInstr " &
"FROM [Contract Details]" &
"WHERE ([Contract Details].ContractNumber = " & Me.ContractNumber &");" 'Here was where the compile error showed u
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
Sorry to post so much of it, but I keep looking and am not too sure what for :
Thanks for all help; any explaination appreciated. Relearning...
I have this code which I've adapted, but I haven't done programming in years and am not too familiar w this, so please help. I'm getting compile error at the end of the WHERE, but I'm really not sure if I have this correct anyway, or backwards..
Private Sub Command98_Click(
Dim sSQL As Strin
Dim db As Acces
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.AppMerchContract 'Is this the correct way to swap
!AppMerchContract = Me.ContractNumbe
!AppMerch = Me.AppMerc
!AHEmail = Me.AHEmail
![4WeekPurchStart] = Me.[4WeekPurchStart] 'Will this [] work for name w a number
.... 'Blah, blah the rest of my fields in main for
.Updat
.Bookmark = .LastModifie
NewContNum = !ContractNumbe
If Me.[fContracts TR].Form.RecordsetClone.RecordCount > 0 Then 'Duplicate the related record
sSQL = "INSERT INTO [Contract Details](ContractNumber, " &
"StoreID, MerchSKU, ..., DelivInstr) &"
"SELECT " & NewContNum & " AS ContractNumber, " &
"[Contract Details].StoreID, [Contract Details].MerchSKU, " &
...................
"[Contract Details].SendPOP, [Contract Details].DelivInstr " &
"FROM [Contract Details]" &
"WHERE ([Contract Details].ContractNumber = " & Me.ContractNumber &");" 'Here was where the compile error showed u
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
Sorry to post so much of it, but I keep looking and am not too sure what for :
Thanks for all help; any explaination appreciated. Relearning...