Open mdb exclusive, permissions problem.
am 13.10.2007 00:11:07 von SaladA97. Split database. Frontend DB1.MDB. Backend DB1BE.MDB. Tables are
linked between DB1 and DB2.
From my testing, if I open DB1 exclusively using /excl the backend
DB1BE is not opened exclusively.
If I open DB1 but have no tables open and then open up DB1BE
exclusively, DB1BE will open exclusive. But if I then attempt to open a
linked table in the frontend DB1 I'm informed I can't use the table
because the file is in use.
If I open DB1 and also open a linked table in DB1 and then attempt to
open the backend DB1BE, it will inform me it can't open the backend
DB1BE exclusively.
OK, so the /excl switch is associated with the file it opens. Whatever
backend files are associated with the file are not affected. I learned
something today.
But I am having some problems. I guess its associated with security. I
don't know. I'm hoping you can tell me what's going on.
I have 2 subroutines below that I run that produces my confusion and
errors. I open up DB1. From the Debug window I run OpenBEExcl. I get
an error "3033. You don't have the permissions to use DB1BE..." This
happens EVERYTIME I open DB1. If I then enter
? IsDBExclusive(Currentdb.name)
and then rerun OpenBEExcl it works and no error 3033!
If I were to run
? IsDBExclusive("C:\Apps\DB1BE.MBB)
first instead of passing Currentdb.name it tells me DB1BE is not
exclusive. But that doesn't affect my OpenBEExcl problem. I will get
the error 3033. The ONLY way I don't get the 3033 error is to first run
IsDBExclusive on the currentdb. From then on I can run any routine
without error.
Can you tell me anything about error 3033 No permissions error? I've
checked the back end. I'm the owner of everything. I have all rights
for all objects. Why would it tell me I have no permissions on a
backend database that the front end is linked to?
Any clarification is appreciated.
Sub OpenBEExcl()
Dim dbs As Database
Set dbs = OpenDatabase("C:\Apps\DB1BE.MDB", True)
MsgBox "Open"
dbs.Close
Set dbs = Nothing
End Sub
Function IsDBExclusive(strDBName As String) As Integer
'Q117539 KB article
' Purpose: Determine if the current database is exclusive.
' Returns: 0 if database is not open exclusively.
' -1 if database is open exclusively.
' Err if any error condition is detected.
Dim db As Database
Dim hFile As Integer
hFile = FreeFile
If DIr$(strDBName) <> "" Then
On Error Resume Next
Open strDBName For Binary Access Read Write Shared As hFile
Select Case Err
Case 0
IsDBExclusive = False
Case 70
IsDBExclusive = True
Case Else
IsDBExclusive = Err
End Select
Close hFile
On Error GoTo 0
Else
MsgBox "Couldn't find " & db.name & "."
End If
End Function