J
john
I have a default recordset of 24 records that are part of a contract that I
need to be able to duplicate and then just change its ID field to a new
value in all 24 records, so that I can then make the some other ajustments
to the new contract and have them as a saved recordset.
I've tried using the menu command codes to duplicate each record one at a
time through a loop with then following code, but it fails to duplicate the
record and returns an error code stating a "BeforeUpdate or ValidationRule
for the field is preventing Access from saving the Data"
I have checked all the fields and there are no ValidationRules set for them
and I have no BeforeUpdate events running either.
1st question is there a way to program a copy of the entire recordset at
once with only the EstimateItemID field being changed to TheNewValue, which
is a Variable.
If not, how do I make this code work to navigate through the "Default"
recordset, copy each record and update it with the TheNewValue.
Dim db As Database, RS As Recordset
Dim strSQL, MatrixID As String
Set db = CurrentDb
MatrixID = TheNewValue
Set db = CurrentDb
strSQL = "SELECT * FROM [EstimatingMatrixInfoQuery] WHERE [EstimateItemID] =
'Default' and [EstimateCostItemFormQueue] = " & Me.ComboMatixFormQ & ""
Set RS = db.OpenRecordset(strSQL)
RS.MoveFirst
Do Until RS.EOF
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
'I've also tried using the runcommand series of copy and paste append with
the same errors.
'Modify Data
With RS
.Edit
!EstimateItemID = MatrixID
.Update
End With
RS.MoveNext
Loop
RS.Close
Set db = Nothing
need to be able to duplicate and then just change its ID field to a new
value in all 24 records, so that I can then make the some other ajustments
to the new contract and have them as a saved recordset.
I've tried using the menu command codes to duplicate each record one at a
time through a loop with then following code, but it fails to duplicate the
record and returns an error code stating a "BeforeUpdate or ValidationRule
for the field is preventing Access from saving the Data"
I have checked all the fields and there are no ValidationRules set for them
and I have no BeforeUpdate events running either.
1st question is there a way to program a copy of the entire recordset at
once with only the EstimateItemID field being changed to TheNewValue, which
is a Variable.
If not, how do I make this code work to navigate through the "Default"
recordset, copy each record and update it with the TheNewValue.
Dim db As Database, RS As Recordset
Dim strSQL, MatrixID As String
Set db = CurrentDb
MatrixID = TheNewValue
Set db = CurrentDb
strSQL = "SELECT * FROM [EstimatingMatrixInfoQuery] WHERE [EstimateItemID] =
'Default' and [EstimateCostItemFormQueue] = " & Me.ComboMatixFormQ & ""
Set RS = db.OpenRecordset(strSQL)
RS.MoveFirst
Do Until RS.EOF
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append
'I've also tried using the runcommand series of copy and paste append with
the same errors.
'Modify Data
With RS
.Edit
!EstimateItemID = MatrixID
.Update
End With
RS.MoveNext
Loop
RS.Close
Set db = Nothing