P
PHisaw
Hi,
Using the following code, can anyone please tell me why "Module" field is
copied with "forms_fsparepartsmainform" in the new record? All others are
duplicating properly. I can't seem to find error with this field.
Private Sub Command36_Click()
'On Error GoTo Err_Handler
'Purpose: Duplicate the main form record and related records in the
subform.
Dim strSql As String 'SQL statement.
Dim lngID As Long 'Primary key value of the new record.
'Save and edits first
If Me.Dirty Then
Me.Dirty = False
End If
'Make sure there is a record to duplicate.
If Me.NewRecord Then
MsgBox "Select the record to duplicate."
Else
'Duplicate the main record: add to form's clone.
With Me.RecordsetClone
.AddNew
!Customer = Me.Customer
!Date = Date
!Model = Me.Model
!SerialNumber = Me.SerialNumber
!Multiplier = Me.Multiplier
!Manufacturer = Me.Manufacturer
!Module = Me.Module
!CustomerItem = Me.CustomerItem
'etc for other fields.
.Update
'Save the primary key value, to use as the foreign key for the
related records.
.Bookmark = .LastModified
lngID = !QuoteNumber
'Duplicate the related records: append query.
If Me.[fSparePartsSubform3].Form.RecordsetClone.RecordCount > 0
Then
strSql = "INSERT INTO [tsparepartssubform3] ( QuoteNumber,
Model, Module, PartIDNumber, Qty, Class1, Class2, Class3, DelWks ) " & _
"SELECT " & lngID & " As NewID, Model, Module,
PartIDNumber, Qty, Class1, Class2, Class3, DelWks " & _
"FROM [tsparepartssubform3] WHERE QuoteNumber = " &
Me.QuoteNumber & ";"
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
End If
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, ,
"command36_Click"
Resume Exit_Handler
End Sub
Thanks in advance for your help.
Phisaw
Using the following code, can anyone please tell me why "Module" field is
copied with "forms_fsparepartsmainform" in the new record? All others are
duplicating properly. I can't seem to find error with this field.
Private Sub Command36_Click()
'On Error GoTo Err_Handler
'Purpose: Duplicate the main form record and related records in the
subform.
Dim strSql As String 'SQL statement.
Dim lngID As Long 'Primary key value of the new record.
'Save and edits first
If Me.Dirty Then
Me.Dirty = False
End If
'Make sure there is a record to duplicate.
If Me.NewRecord Then
MsgBox "Select the record to duplicate."
Else
'Duplicate the main record: add to form's clone.
With Me.RecordsetClone
.AddNew
!Customer = Me.Customer
!Date = Date
!Model = Me.Model
!SerialNumber = Me.SerialNumber
!Multiplier = Me.Multiplier
!Manufacturer = Me.Manufacturer
!Module = Me.Module
!CustomerItem = Me.CustomerItem
'etc for other fields.
.Update
'Save the primary key value, to use as the foreign key for the
related records.
.Bookmark = .LastModified
lngID = !QuoteNumber
'Duplicate the related records: append query.
If Me.[fSparePartsSubform3].Form.RecordsetClone.RecordCount > 0
Then
strSql = "INSERT INTO [tsparepartssubform3] ( QuoteNumber,
Model, Module, PartIDNumber, Qty, Class1, Class2, Class3, DelWks ) " & _
"SELECT " & lngID & " As NewID, Model, Module,
PartIDNumber, Qty, Class1, Class2, Class3, DelWks " & _
"FROM [tsparepartssubform3] WHERE QuoteNumber = " &
Me.QuoteNumber & ";"
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
End If
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " - " & Err.Description, ,
"command36_Click"
Resume Exit_Handler
End Sub
Thanks in advance for your help.
Phisaw