Solved

Mutiple User Database - restrict access screen - 1 user at a time

Posted on 2000-03-10
6
312 Views
Last Modified: 2008-03-17
Hi there

Have multiple - user db - 10 users at any time.  One of the screen only 1 person can use it at any time.

Question - is there a mechanism where

i).Restrict use of screen 1 user - lock others out.
2).If you are locked out - able to tell who is using the screen ??

Is it possible and how you do it - any ideas ????

Thanks.


0
Comment
Question by:ImraneA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Expert Comment

by:dramaqueen
ID: 2605197
Not sure why you'd want to lock users out of a form if someone else is using it. Access will by default lock a RECORD, preventing two users from editing the same data simultaneously, but not a form.

If you really did want to stop two people accessing the same form then you could do something like this:

1. Have a table (eg "frmUsers") containing a field for each form that you might want to protect.

2. Edit the code for the button that will open the form so that it checks to see if the appropriate field in "frmUsers" contains the name of the person using it. If the field is empty then open the form. If the field is not empty display a MsgBox telling the user that "<contents of field> is currently looking at this form" and do not open the form.

3. When (if) the form opens, set the name in the table to the user's name. (This could be stored elsewhere (say) in the client front end, or, if you're really clever you could get the user's network login id - I'm sure someone here could tell you how to do that... I couldn't)

4. When the user closes the form, the appropriate field in "frmUsers" must be set to "".

Ok, techie boys and girls - now turn it into proper code!
0
 
LVL 10

Accepted Solution

by:
paasky earned 50 total points
ID: 2605262
Hello,

Good suggestion dramaqueen !

As requested here's little coding help (should be placed into form which is needed to be locked by single user):

Private Sub Form_Close()
    ' Release form lock
    CurrentDb.Execute ("UPDATE tblFormLock SET UserName='' WHERE FormName = " & Chr(34) & Me.Name & Chr(34))
End Sub

Private Sub Form_Open(Cancel As Integer)
Dim StrUserName As String
       
    StrUserName = Nz(DLookup("UserName", "tblFormLock", "FormName=" & Chr(34) & Me.Name & Chr(34)), "")
   
    If StrUserName <> "" Then
        ' form is currently opened by another user
        MsgBox "Can't open form because it's locked by user " & StrUserName & "."
        Cancel = True
    Else
        ' form can be opened, lock the form
        CurrentDb.Execute ("UPDATE tblFormLock SET UserName=" & Chr(34) & CurrentUser() & Chr(34) & " WHERE FormName = " & Chr(34) & Me.Name & Chr(34))
    End If
End Sub

Table which contains locking information is named "tblFormLock" and it contains the following fields:

FormName (text) PrimaryKey
Username (text)

Regards,
Paasky
0
 
LVL 10

Expert Comment

by:paasky
ID: 2605287
ImraneA, forgot to mention that you need to populate table tblFormLock with the form name(s). If you have many forms to add, you can use this SQL to fill the table easily:

INSERT INTO tblFormLock ( FormName )
SELECT MSysObjects.Name
FROM MSysObjects
WHERE MSysObjects.Type=-32768;

Paasky
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:BrianWren
ID: 2606130
CurrentDb.Execute ("UPDATE tblFormLock SET . . . . .

Clever.  I'll remember that one.
0
 

Author Comment

by:ImraneA
ID: 2619116
Spot on but, had to use recordset (i.e. .edit & .update) rather CurrentDb.Execute ("UPDATE tblFormLock  etc.. for close event.

To improve robustness of this .
0
 
LVL 10

Expert Comment

by:paasky
ID: 2619377
Happy to help you ImraneA.

dramaqueen,
I think you deserve half of the points, because the idea came from you. I've posted a question for you (Q.10311249).

Regards,
Paasky
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delete table fields 3 46
MS ACCESS VBA FORMATTING 9 60
Menus 6 53
Best way to get data into a database 12 54
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question