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/
 
Back
Top