Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 09:58 AM
mgPA
Guest
 
Posts: n/a
Default How to limit concurrent users/logins

Short: How can I limit the number of concurrent logins to Access
(2000) DB?

Long: I seem to be having the problem discussed in previous postings
of having more than 9 or 10 concurrent logins. If I can limit the
number of concurrent logins to 8 or 9, that would satisfy our needs.

Thanks

  #2  
Old November 13th, 2005, 09:59 AM
Phil Stanton
Guest
 
Posts: n/a
Default Re: How to limit concurrent users/logins

As you have had no replies, I will give you 1 clue to a solution, but it's a
lot of work.

You will need a form that is opened when the db is opened that has a command
button "CloseDb" to close the db. It also needs a hidden text box called
"CloseOK". I use a modified Switchboard for this. you then set the OnUnload
of this form to
Private Sub Form_Unload(Cancel As Integer)

If CloseOK = 0 Then ' Must keep the switchboard open
DoCmd.CancelEvent
End If
End Sub

So this means that the Db can not be closed unless the "CloseOK" Text Box
is set to true. This palaver ensures that if a user has logged in, they will
also by default log off.

I am going about this a bit arse about face, but never mind.

You need a table of Users
UserID PK
UserName No duplicates
LoggedOn True/False

Set up the users who are entitled to use the DB

you then need something like this on the open of the Switchboard (or
whatever the initial form is)

Function LogOn() ' Check who is logged on

Dim MyDb As Database
Dim UserSet As Recordset
Dim SQLStg As String

On Error GoTo LogOn_Err

SQLStg = "SELECT Count(Users.UserID) AS CountOfUserID "
SQLStg = SQLStg & "FROM Users "
SQLStg = SQLStg & "GROUP BY Users.LoggedOn "
SQLStg = SQLStg & "HAVING (((Users.LoggedOn)=true));"

Set MyDb = CurrentDb
Set UserSet = MyDb.OpenRecordset(SQLStg) ' See how many using
program

With UserSet
If !CountOfUserID > 7 then
' maximum 8 users
MsgBox "You have exceeded the number of users licensed",
vbExclamation
RunCommand acCmdExit
End If
.Close
End With
Set UserSet = Nothing

SQLStg = "SELECT Users.* "
SQLStg = SQLStg & "FROM Users WHERE (Users.UserName = '" & CurrentUser()
& "');"
Set UserSet = MyDb.OpenRecordset(SQLStg)

If UserSet.BOF Then GoTo NoUser ' Not a valid
user

With UserSet
.Edit
!LoggedOn = True
.Update
.Close
End With
Set UserSet = Nothing
Exit Function

LogOn_Err:
If Err = 3021 Then ' No Current Record
UserSet.Close ' Close the query
Set UserSet = Nothing
Else
MsgBox Err.Description
End If
Exit Function

NoUser:
MsgBox "You have no permission to use this program", vbExclamation
'RunCommand acCmdExit

End Function

On pressing the "CloseDB" button you want something like

Function LogOff()

Dim MyDb As Database
Dim UserSet As Recordset
Dim SQLStg As String

On Error GoTo LogOff_Err

SQLStg = "SELECT Users.UserName, Users.LoggedOn "
SQLStg = SQLStg & "FROM Users WHERE (Users.UserName = '" & CurrentUser()
& "');"

Set MyDb = CurrentDb
Set UserSet = MyDb.OpenRecordset(SQLStg)

If UserSet.BOF Then Exit Function ' Can't find

With UserSet
.Edit
!LoggedOn = False
.Update
.Close
End With
Set UserSet = Nothing

Forms!Switchboard!CloseOK = 1 ' OK to
close database
RunCommand acCmdExit
End Function
Have fun

Phil
"mgPA" <mark.girshovich@gmail.com> wrote in message
news:1113581166.516954.25850@l41g2000cwc.googlegro ups.com...[color=blue]
> Short: How can I limit the number of concurrent logins to Access
> (2000) DB?
>
> Long: I seem to be having the problem discussed in previous postings
> of having more than 9 or 10 concurrent logins. If I can limit the
> number of concurrent logins to 8 or 9, that would satisfy our needs.
>
> Thanks
>[/color]


  #3  
Old November 13th, 2005, 09:59 AM
Arno R
Guest
 
Posts: n/a
Default Re: How to limit concurrent users/logins

Phil gave you an answer that will work well.

Another possibility is to read the ldb-file. (No need for an extra table)
Google on 'WhosOn' and you will find the code. Works beautiful.
Maybe you need to slightly adapt the function (or the way to use it) to your situation.

--
Hope this helps
Arno R


"mgPA" <mark.girshovich@gmail.com> schreef in bericht news:1113581166.516954.25850@l41g2000cwc.googlegro ups.com...[color=blue]
> Short: How can I limit the number of concurrent logins to Access
> (2000) DB?
>
> Long: I seem to be having the problem discussed in previous postings
> of having more than 9 or 10 concurrent logins. If I can limit the
> number of concurrent logins to 8 or 9, that would satisfy our needs.
>
> Thanks
>[/color]
  #4  
Old November 13th, 2005, 10:02 AM
mgPA
Guest
 
Posts: n/a
Default Re: How to limit concurrent users/logins

Thank you both.

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles