updating record with form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,

I am having errors that more than 1 person is trying to modify records.
What i am trying to do is update a record in a function using ADODB, that is
the same record the user is using. I have the db settings to no record locks.

Is there a way to lock the form record while the update on the record is
occuring.

Thanks in advance.
David
 
Hi,

When you open your ADO Recordset use adLockOptimistic for the Lock Type,
this should lock a row as soon a field value is changed. The lock will be
released when the Update Method is called or the Recorset moves to a new
row.

Note this does not work with the CurrentProject.Connection. You will need
to open a new connection.

e.g.

Dim c As New ADODB.Connection
Dim r As New ADODB.Recordset
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=d:\msoffice\access\" & _
"ng.mdb;"
'Open a recordset with a keyset cursor using Pessimistic Locking
r.Open "Select * From tblTest", c, adOpenKeyset, adLockPessimistic


--
HTH

Mark Phillipson

Free Add-Ins at; http://mphillipson.users.btopenworld.com/
 

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

Back
Top