473,769 Members | 7,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Qui t acQuitSaveNone
Exit Function
End If
----------------------------------------------------------------------------

Public Function NumUsersU(DBNam e 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!fLoggedI n.Form!lstUsers .RowSource = ""
'Forms!fLoggedI n.Form!lstUsers .Requery
'Forms!fLoggedI n.Form!lblMsg.C aption = "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 6231
Private Function CanBeOpenedExcl usively(ByVal FullPath$) As Boolean
Dim d As Database
Dim p As PrivDBEngine
Set p = New PrivDBEngine
On Error Resume Next
Set d = p(0).OpenDataba se(FullPath, True)
CanBeOpenedExcl usively = 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 CanBeOpenedExcl usively(ByVal FullPath$) As Boolean
Dim d As Database
Dim p As PrivDBEngine
Set p = New PrivDBEngine
On Error Resume Next
Set d = p(0).OpenDataba se(FullPath, True)
CanBeOpenedExcl usively = 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
2050
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 open. Is there any way to overcome this behaviour to allow these objects to be edited while other users have the database open?
1
3920
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. When the application is opened by someone, it seems that if one of the Adobe 7.0 (Standard or Professional) users susequently open the application, they get the error - "...You do not have exclusive permissions to the database. Changes that you...
18
7346
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 in MsAccess 97 or prior and have been converted to 2003. On occassion user 1 will open a db. When user 2 opens the db it will not let user 2 modify macros and what not. I can understand this and realize we could split the db; it is not worth ...
0
1350
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 alkready exclusively open by another, yet i have not opened it. Have tried altering the access permissions, but still to no avail..
1
3682
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 access to the database file. No other instance of MS Access or this particular C# application (or any other app) should be able to open the access database file concurrently.
9
7374
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 you proceed to make changes, you may not be able to save them later " Now, when I open the db from different computers, I don't get the error on open, but if I try to open a form in Design Mode. There is a program running that has "control"...
4
1704
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 it's new, edited state. With Access 2003 I cannot do that as if anyone has got the database open I get this message . Is there anyway to avoid this?
3
1784
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
2602
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 she did today, according to her, was to download and install an Avery label wizard. She has rebooted and there are no other versions of Access running.
3
2659
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. i was wondering what techniques people have used to gain exclusive access to the backend when tables, modules, etc. need to be saved/edited. i have seen several clever methods but am not enamored with any yet. thanks in advance for the help!
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9414
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10197
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9977
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9848
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8860
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6661
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3549
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.