Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One way of Locking Records in a Multi-User Scenario

How to

One way of Locking Records in a Multi-User Scenario

by  Ogart  Posted    (Edited  )
Situation: You know there will be multiple users, and your application has some data entry forms. You don't want users to overwrite a record that someone else is editing.

Resolution: You want to set the Application to pessimistic Locking. This means that once a user looks at a record, it's locked up and only that user can make changes.

How To:
1. Stick this in your module.
Public Sub SetRecLocks()
'This command sets "Pessismistic" locking.
'If someone is poking around in a given record, no one else can edit it.
Application.SetOption "Default Record Locking", 2
End Sub

2. Presuming you've got a form that always opens at startup, stick this event driven piece in it
Private Sub Form_Load()
SetRecLocks
End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top