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

checking for exclusive access to the back-end db

ARC
Hello all,

When a user starts my app, I run re-attaching code if the links are not
valid, etc. In this routine, I then check the version of the back-end
database. If the version is off, I run code that then upgrades their
back-end db by adding new fields, etc.

However, if new fields are needed, I do run a function that I wrote that is
supposed to determine if there are other user's in the back-end database. If
so, it tells them to exit all other users out, and retry the upgrade. This
code used to work in access 97, but for whatever reason, doesn't work with
access 2007. If there is a better way to check for exclusive access, that
would be good too.

I'm including my function below. And by the way, I also use this function to
make sure they are not exceeding the number of users that they are licensed
for.

Here's a snippet from my upgrade / reattaching code, then the function I
call is below that:

Thanks all!
If NumUsersU(Trim(datapath)) 1 Then 'datapath= back-end database
MsgBox "You cannot upgrade your database until all other user's exit
the program. Exclusive use of the database is required for upgrades
that add new fields / tables to your database." & Chr(10) & Chr(10) & "The
program will now be shutdown. Please exit all users from the
system.", vbCritical, "Exit all users prior to upgrading"
Application.Quit acQuitSaveNone
Exit Function
End If
----------------------------------------------------------------------------

Public Function NumUsersU(DBName As String) As Integer
On Error GoTo ErrRtn
Dim UserName As String, UserRight As String, UserList As String
Dim ldbName As String
ldbName = Left(DBName, Len(DBName) - 6)
ldbName = Trim(ldbName & ".laccdb") 'check the ldb file for users, rather
than the accdb file
NumUsersU = 0
Open ldbName For Input Shared As #1
Do While Not EOF(1)
UserName = Input(31, #1)
NumUsersU = NumUsersU + 1
UserRight = Input(5, #1)
'if char = asc(32)
'Debug.Print Trim$(UserName)
UserList = UserList & Trim$(UserName) & ";"
Loop
'Debug.Print Chr(10) & Chr(13)
'Debug.Print "Number of users is: " & NumUsers
Close #1
Exit Function
ErrRtn:
NumUsersU = 1
If Err = 53 Then '.ldb file not found
'MsgBox "There are no user's in this .ldb file"
'Forms!fLoggedIn.Form!lstUsers.RowSource = ""
'Forms!fLoggedIn.Form!lstUsers.Requery
'Forms!fLoggedIn.Form!lblMsg.Caption = "Number Logged In: 0"
ElseIf Err = 62 Then
Close #1
Exit Function
Else
MsgBox Err.Number & " - " & Err.Description & ", Function: NumUsers"
End If
End Function

Sep 12 '08 #1
2 6185
Private Function CanBeOpenedExclusively(ByVal FullPath$) As Boolean
Dim d As Database
Dim p As PrivDBEngine
Set p = New PrivDBEngine
On Error Resume Next
Set d = p(0).OpenDatabase(FullPath, True)
CanBeOpenedExclusively = Not (d Is Nothing)
p(0).Close
Set d = Nothing
Set p = Nothing
End Function
--
-
lyle fairfield
Sep 12 '08 #2
ARC
Perfect! Thanks, Lyle. I'll switch to your function.

Andy
"lyle fairfield" <ly******@yah00.cawrote in message
news:Xn**********************@216.221.81.119...
Private Function CanBeOpenedExclusively(ByVal FullPath$) As Boolean
Dim d As Database
Dim p As PrivDBEngine
Set p = New PrivDBEngine
On Error Resume Next
Set d = p(0).OpenDatabase(FullPath, True)
CanBeOpenedExclusively = Not (d Is Nothing)
p(0).Close
Set d = Nothing
Set p = Nothing
End Function
--
-
lyle fairfield
Sep 13 '08 #3

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

Similar topics

1
by: Alan Jones | last post by:
Access 2000 onwards introduced a restriction that only allows you to edit and save forms, reports and macros when you have exclusive access to the database, i.e. no other user has the database...
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. ...
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...
9
by: shades234 | last post by:
When i go to open my Access database from certain computers, i get multiple popup messages stating the same thing. They all say "You do not have exclusive access to the database at this time. If...
4
GrandMaster
by: GrandMaster | last post by:
Hi all When I used Access 97, I could edit reports and forms whilst other users had it open, the only problem was that the users had to close and reopen a form or report to see the form/report in...
3
by: jjstevens | last post by:
Is there a way to make design changes to an access database using 2003 while not having exclusive access?
1
by: PW | last post by:
Hi, All of a sudden one of our clients can't use her application. She gets "You don't have exclusive access to your database at this time" when trying to open our application. The only thing...
3
by: freeskier | last post by:
hello, i have a split ms access database with front ends distributed to several users. it is a real pain to have to wait until everyone signs off for the day to make design changes to the backend....
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
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
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...
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.