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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking a Form 1

Status
Not open for further replies.

Maquis

Programmer
Jul 19, 2001
934
US
I'm sure there must be a very simple way to do this, I just don't know the appropiate code.

What I would like to do is lock a form in a multi-user database so that only 1 user can open it at a time.

Thanks in advance
 
Just a thought. I haven't actually tried it.

1. Create a table with a Yes/No field.
2. Place an invisible field on the form with the Yes/No field as it's ControlSource.
3. In the form's On Load event check the value of the field.
4. If it is No then proceed as normal and set the value to Yes.
5. If Yes, then MSGBOX and CLOSE.
6. When you close it set the value back to No.

Just a thought...

B-) ljprodev@yahoo.com
ProDev, MS Access Applications
 
Thanks, Lonnie.

I think I'll go with that idea. I was already toying with the idea of creating a "lock" table, but instead I had gone off on a tangent of putting a user name in the table and it was just getting too messy.

I like having a simple yes/no boolean though. Short and to the point.
 
An added thought. You may want to do the checking and setting of the Yes/No at the point the user clicks the button to open the form. This way you don't get into a mess when closing and resetting the value.

For example, if you open the form the flag is Yes.
Next person opens it and the form automatically closes, but this closing also sets the flag to No, now another attempt at opening the form will get a user in.

Just another thougth.

B-) ljprodev@yahoo.com
ProDev, MS Access Applications
 
Yep, that's just what I was thinking. (GMTA)

I plan on checking the flag on the click event of the button calling the form and actually flipping the flag in the open/close events of the form.

But, knowing my users, 2 of them will try to open the stupid thing at the exact same second. X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top