ADO start lock record at which line ?

S

S.L.

Hi, I'm testing locking in MS Access XP with ADO 2.1. My testing code is
below :

Set cnn = CurrentProject.Connection
rst.Open "select * from MTR1 where MTR1_CD = 'A' ", cnn, adOpenKeyset,
adLockPessimistic
rst!MTR1_No = rst!MTR1_No + 1 ' <------ Line 1

Do While mkLock ' mkLock is set to false when UPDATE button on form
is clicked.
DoEvents
Loop

rst.Update ' <----- Line 2

I have 2 identical forms with the same above code run when I click RUN
button and has a UPDATE button that set mkLock to false to update a record.
When click RUN on both form, the second form does not display the error msg
about locking until first form is click UPDATE and second form click UPDATE
also. It means error msg is detected at Line 2. What I expect is error msg
from second form should be detected when record is being edited at Line 1.

My question is : with ADO programming, Record editing start at which line (1
or 2) ?
If Line 1, Why no error when Line 1 is executed ?
If Line 2, Pessimistic does like Optimistic, Which I don't think it's
correct ?

TIA
 

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

Top