473,394 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

Nov 13 '05 #1
3 4418
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" <ma*************@gmail.com> wrote in message
news:11*********************@l41g2000cwc.googlegro ups.com...
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

Nov 13 '05 #2
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" <ma*************@gmail.com> schreef in bericht news:11*********************@l41g2000cwc.googlegro ups.com...
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

Nov 13 '05 #3
Thank you both.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Steve | last post by:
I've run in to a problem with a query I'm trying to write. I have attached a sample SQL script at the end of this post to show an overview of what I'm working with. I want to be able to use...
2
by: SD | last post by:
Hi, Quick question, I have about 20 users in my local server and database. We are looking to restore that database to a new server in a new network and still be able to retain the database...
1
by: Tom Ostberg | last post by:
There appears to be a limit of ~16378 user Id's possible per database. When adding users we eventually get the message: > exec sp_adduser 'testUser', 'testUser', 'user_group' Server: Msg 15065,...
6
by: Hannu | last post by:
Hi. In the ldb file you can see the users of the mdb-file. If you open the mdb-file your machine and username will be written in the lbd- file. Allthough you close the mdb-file your name won't...
8
by: pnp | last post by:
Hi all, I've developed a win C# app that is actually database driven using SQL server 2000. The idea is that only one application will be installed on a server in a network and the program will be...
6
by: Ross Lewis | last post by:
I would like to limit users from logging in to the website from more than one computer. I have a database that I use to check the username and password of the user, but I would also like to...
6
by: Bill Manring | last post by:
I have an ASP.NET application which my company sells comercially. We license on a concurrent user model, but we currently rely on the "honor" system for the customers to give us their best guess...
4
by: Paul | last post by:
I have an ASP.NET application that I want to limit # of concurrent logins. Has anyone done similar things before? I was trying to increment a counter in the application and decrement the counter in...
6
by: krvrk | last post by:
Hi, I am creating a report for which i need to query a table for total number of users and Concurrent users logged in. The table will contain Username(nvarcar,not null),SessionStart...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.