Discussion Locked

Access Lock/Unlock statement

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a form that is used to add/edit employee timesheets. When the record(s) have been verified by the supervisor all the fields are disabled so that the operator can no longer edit the record. (This is done under the on Current Event.) Currently I'm setting in the forms property "Record Locks" to "Edited Records"

What I need to know is how can I unlock a record that the employee is viewing when it shows that it has already been verified by the supervisor. It's locking the reocord if the employee is in the form and keeping the supervisor from using that record in other update processes.

I would like to be able to under the current event when checking for "if verified" to disable all fields from being edited to also keep the record unlocked.

In advance I thank all of you for taking the time to help out people like me.

5 replies

by sankulpune

Hello meares,

1) Create a new 'dummy' database on the Supervisor's PC. Link all the components of the original database to this database. Create a new form in this local database that is exactly similar to the existing form with only change that the value of 'Enabled' property for all fields on this form is 'Yes'.

Using this form, that is available only on the Supervisor's PC, he can edit any record while the same record appears 'Locked' for the users.

You have to ensure that the value of 'Record locking' property for both the forms is preferably 'No locks', but in no case it is 'All records'.

Record locking works only when same record is accessed simultaneously by more than one user. It won't prevent a single user from editing a record. So, disabling fields is essential for 'locking' the records.

2) You can add a 'IsVerified' field to each record using a checkbox. This will be checked by the Supervisor when he verifies the record. When viewed by the user, you can 'lock(disable fields)' or 'unlock(enable fields)' the record based on whether 'IsVerified' check-box is checked or not.

I would be happy to provide any help / clarifications you may need to implement the above solution successfully.

I am assuming here that the database is on network server and you want:
a) users
a1) to add new records,
a2) to edit records as long as they are not verified by the Supervisor,
a3) only to view but not modify verified records.
b) the Supervisor
b1) to verify and then 'lock' the records,
b2) to edit any record whether verified or not.

Hope all these are taken care by appropriately.

An alternative solution using VBA can be developed if it interests you.

Your early feedback will be highly appreciated.

With best regards,

SanganakSakha,
Your Friend In Need.

by meares

Thanks for the input. Tell me could I look at the 'IsVerified' field and then lock the current record in VB if it is not checked. This way if the user is editing the record and the supervisor tries to check the box they won't be able to until theemployee is finished editing. I would perfer not to the 'dummy' database on the Supervisor's PC since I have multiple Supervisor's and maintaining them could turn into a nightmare. It's easier to have the one database on the network to maintain for everyones use.

by sankulpune

Hello meares,

1) If you want to allow users to modify data until it is verified and locked, this collision, I think, is unavoidable. In my opinion, you can only safeguard from it, but not avoid it altogether.
How else can the point of locking be defined?
2) You can assign user level passwords to the database. Depending upon who is logged in (User or Supervisor), define the properties of the form in the open event and control who can do what.
You can find out the user name using 'Application.UserName'.

Hope these suggestions help.
I would appreciate your feedback.

SanganakSakha
The Friend In Need

by meares

Thank You. I can lock the record by checking the verify flag on the "On Current" of the form. Thank you so much for your time in helping me.

Meares

This discussion is closed to new replies.