473,405 Members | 2,272 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,405 software developers and data experts.

Testing for exclusive access

5
I have a database thats is used by about 20 people. I want the first person in that database to run a series of Macros. Is there an easy way to tell if they are the only one in the database?

Thanks.
Sep 30 '08 #1
4 2133
NeoPa
32,556 Expert Mod 16PB
I have a database which logs the Date/Time of running my once-a-day code in a single record table.

Before logging anything it compares the logged date with the current Date(). If the dates are different (not the times - just the date portions), then it goes on to check another flag in the same record which indicates whether someone already has the database open and is running the once-a-day code.

If this flag is set to True, then a message pops up telling the operator that the database is currently unavailable due to once-a-day processing.

If set to False, then the flag is set to True and the once-a-day code is executed. When it is completed, the flag is reset to False and the Date/Time is logged.
Sep 30 '08 #2
ADezii
8,834 Expert 8TB
Is there an easy way to tell if they are the only one in the database?
We can do one better that that. The following code will tell how many Users are logged on to a Database, and also display their Names in the form of a Message Box. The code is extremely flexible and can be used in any manner you so desire: in a Function, Click() Event of a Command Button, Open() Event of a Form, etc. Just Copy and Paste:
Expand|Select|Wrap|Line Numbers
  1. Dim cnn As ADODB.Connection
  2. Dim strUser As String
  3. Dim rst As ADODB.Recordset
  4. Dim intUser As Integer
  5. Dim varValue As Variant
  6. Const conUsers = "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
  7.  
  8. Set cnn = CurrentProject.Connection
  9. Set rst = cnn.OpenSchema(Schema:=adSchemaProviderSpecific, SchemaID:=conUsers)
  10.  
  11. With rst
  12.   Do Until .EOF
  13.     intUser = intUser + 1
  14.       varValue = .Fields(1).Value
  15.       If InStr(varValue, vbNullChar) > 0 Then
  16.         varValue = Left(varValue, InStr(varValue, vbNullChar) - 1)
  17.       End If
  18.       strUser = strUser & varValue & vbCrLf
  19.       .MoveNext
  20.   Loop
  21. End With
  22.  
  23. strUser = Left$(strUser, Len(strUser) - 2)
  24.  
  25. MsgBox "There are currently " & intUser & " User(s) logged on to this " & _
  26.        "Database, and they are:" & vbCrLf & vbCrLf & strUser, _
  27.        vbInformation, "Logged On Users"
  28.  
  29. 'Routine cleanup chores
  30. Set fld = Nothing
  31. Set rst = Nothing
  32. Set cnn = Nothing
P.S. - This code is actually a subset of more comprehensive code relating to Generating a User List ==> How to Generate a User List
Sep 30 '08 #3
slynn
5
We can do one better that that. The following code will tell how many Users are logged on to a Database, and also display their Names in the form of a Message Box. The code is extremely flexible and can be used in any manner you so desire: in a Function, Click() Event of a Command Button, Open() Event of a Form, etc. Just Copy and Paste:
Works perfectly. Thanks!
Oct 1 '08 #4
ADezii
8,834 Expert 8TB
Works perfectly. Thanks!
You are quite welcome.
Oct 1 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Uwe C. Schroeder | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. I have the following little stored proc: CREATE OR REPLACE FUNCTION public.ib_nextval(varchar) RETURNS varchar AS 'DECLARE
1
by: Chuck Van Den Corput | last post by:
I have encountered a problem that I am hoping someone can shed some light on. I have a multi-user A97 app. All users have a personal front-end MDE accessing a shared back-end. There is no...
0
by: Bill | last post by:
I have three databases running, all with a slightly different function: 1) Shared Database where data entry is done 2) Data Inventory where information from the Shared Database is loaded to...
0
by: Wayne | last post by:
Can someone please help with this problem. When referring to opening a database in Exclusive mode the Access 2003 help says: "Under Default open mode, do one of the following: If you want others...
1
by: JohnC | last post by:
I have this exact same scenario. It is new and seems to be related to when we installed Adobe 7.0 Standard/Professional. We have an MDB on a LAN file server. Using Access 2K and Windows 2K. ...
1
by: University of Toronto | last post by:
Hi gang, Hopefully someone can help us out. In short - Access 2002, db split into a front end and back end. It appears that our backend db is locked. Our form bound to one table won't allow...
18
by: Andre Laplume via AccessMonster.com | last post by:
I have inherited a bunch of dbs which are are shared among a small group in my dept. We typically use the dbs to write queries to extract data, usually dumping it into Excel. Most dbs originated...
0
by: MSDN | last post by:
Hi can anybody help me. I am trying to access a database I have created, using ADO. The code is fine but the Jet Engine returns an exclusive Access error Error tells me that the database is...
1
by: CJJ | last post by:
hi Folks, I am opening my access database file (Access 2003) from a C# application. The connection string specifies mode=Share Exclusive The intent is that the application have exclusive...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...

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.