473,524 Members | 3,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4432
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
3030
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 LIMIT to control how many rows from one table are returned, independent of how many rows there are in a second table that is joined to the first. ...
2
2151
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 users. We have created all 20 logins in the new server (exact names) but when we restore the database I do not see the users anymore! Is there...
1
2840
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, Level 16, State 1, Procedure sp_grantdbaccess, Line 160 All user IDs have been assigned. All of the MSSQL procedures eventually call...
6
12336
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 disappear from the ldb-file, before every user has closed the mdb-file. I have heard that there will be problems if the amount of users will be over...
8
4010
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 able to run at each client machine by just double-clicking the application executable through a network share. The program supports user logins....
6
1419
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 check if it is the same computer. How can this be done without using cookies?
6
3334
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 as to the maximum number of concurrent users they will need. We do this because, so far, we have not been able to come up with any mechanism for...
4
3333
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 "Session_End". However, the "Session_End" will only work for InProc session. So, is there any other approach? Thanks, Paul.
6
15395
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 time(datetime, not null), SessionEnd time (datetime,null), SessionID(int,not null) and ConnectGUID(uniqueidentifier, not null) etc can any one help me in...
0
7251
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7226
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7600
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5774
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5173
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1697
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
541
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.