Set a Maximum Locking Interval for a Record
Problem
You’ve employed pessimistic locking on your application’s forms to prevent two users from making changes to the same record at the same time. Sometimes, a user will lock a record for an excessive period of time; for example, he might start to edit a record and then get a long phone call or leave for lunch without saving or canceling his edits. Is there any way to limit how long a user can lock a record and time out the user when the locking time limit has been exceeded?
Solution
There’s no built-in database or form option for “maximum record lock interval,” but you can create your own record lock timeout feature by making use of the form’s Timer event. This solution shows you how to create such a facility using an event procedure attached to the form’s Timer event.
To add a record lock timeout feature to your own application, follow these steps for each form for which you wish to enable this feature:
Open the form in design mode, and add to the form an unbound text box named txtMessage that will be used to display the countdown message. This control should be at least 3.45” wide and 0.1667” high. On the sample form, we have placed txtMessage in the form’s footer, but you can place it anywhere you’d like.
Change the form’s TimerInterval property to 1000. This will cause any code attached to the form’s Timer event to be executed every 1,000 ms (or 1 second).
Create an event procedure attached to the form’s Timer event. Figure ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access