A2007 ADO Update

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
..
..
..
 
T

Tom van Stiphout

On Mon, 21 Dec 2009 08:37:01 -0800, JimS

Not sure. Your code looks decent, except for the .Filter line which is
not needed. Comment it out. I might replace it with a .MoveFirst line.

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Addnew 4
A2007 ADO Recordset Clone 1
More Fun with Classes 2
Runtime errors: ADO (80040e21), DAO (3001) 6

Top