J
JimS
I have a form that uses a class module to insert rows into a table. The class
(clsPicklist) is properly instantiated, opens 4 ADO recordsets, then proceeds
to add the first row to the table just fine. When it goes to add the second
record, it finds a duplicate key (as it should), and goes to update the
quantity rather than adding a new row. At this point, it gets an error
indicating that the record "may have been modified since it was last read",
and fails. Any ideas what I'm doing wrong?
Herewith the relevant code:
(Initialize time...)
rstPickListDetail.Open "tblPickListDetail", cnn, adOpenDynamic,
adLockOptimistic
..
..
..
(part of the AddDetail method...)
Public Function AddNewDetail(BoMDetailID As Long, Quantity As Double) As Long
..
..
..
With rstPickListDetail
.Filter = "PLPicklistID=" & m_lngPicklistID
.Find "PLBoMDetailID=" & BoMDetailID, , adSearchForward, 1
If .EOF Then
.AddNew
!PLPicklistID = m_lngPicklistID
!PLBoMDetailID = BoMDetailID
!PLDetailQtytoPick = Quantity
Else
!PLDetailQtytoPick = !PLDetailQtytoPick + Quantity
End If
.Update
AddNewDetail = !PLDetailID
.Filter = adFilterNone
End With
..
..
..
(clsPicklist) is properly instantiated, opens 4 ADO recordsets, then proceeds
to add the first row to the table just fine. When it goes to add the second
record, it finds a duplicate key (as it should), and goes to update the
quantity rather than adding a new row. At this point, it gets an error
indicating that the record "may have been modified since it was last read",
and fails. Any ideas what I'm doing wrong?
Herewith the relevant code:
(Initialize time...)
rstPickListDetail.Open "tblPickListDetail", cnn, adOpenDynamic,
adLockOptimistic
..
..
..
(part of the AddDetail method...)
Public Function AddNewDetail(BoMDetailID As Long, Quantity As Double) As Long
..
..
..
With rstPickListDetail
.Filter = "PLPicklistID=" & m_lngPicklistID
.Find "PLBoMDetailID=" & BoMDetailID, , adSearchForward, 1
If .EOF Then
.AddNew
!PLPicklistID = m_lngPicklistID
!PLBoMDetailID = BoMDetailID
!PLDetailQtytoPick = Quantity
Else
!PLDetailQtytoPick = !PLDetailQtytoPick + Quantity
End If
.Update
AddNewDetail = !PLDetailID
.Filter = adFilterNone
End With
..
..
..