Searle
Searle

Reputation: 361

MS Access - Atomic Function

There are two fields which may change before my VBA function completes, and I would like a way to prevent this from happening.

I know Java has object locks, synchronization blocks, etc. that can be used to assist with this, but I haven't been able to find mention of this in MS Access.

Does anyone know of any tricks in MS Access to accomplish the same task?


ANSWER:

Set rs = db.OpenRecordset("tblOptions", dbOpenTable, dbDenyWrite, dbPessimistic)
rs.Edit
pNum = rs!lastPolicyNumber
...
rs!lastPolicyNumber = pNum
rs.Update
rs.Close

Upvotes: 1

Views: 179

Answers (1)

4dmonster
4dmonster

Reputation: 3031

You can open recordset with dbPessimistic and call .Edit at line you want to lock. So unlees you call .Update or .CancelUpdate record(page with record) will be locked.

Upvotes: 1

Related Questions