Database Rights HAve Changed

G

Guest

I have a split database. I wrote a routine in the front end that adds two
tables in the back end, sets links to the front end and then creats a
relationship in the backend between the two tables. After I do this, I no
longer have exclusive rights to the front end database. I get an error
message of:
"You no longer have exclusive access to the database. Your design changes
cannot be saved at this time. Do you want to close without saving your
changes ?"

When I click yeas to close without changes, I get another error which reads:
"The save operation failed" and can't close the fdatabase without the
windows task manager.

From this point on, the database is unusable.

Any help willl be gratly appreciated.
 
T

TC

Show us the line of code on which you get that error (and the dozen or
so lines around it).

TC
 
G

Guest

I Have included the two subroutines that call the code. I played with the
database some more. The problem occurs even before I create the tables in
the backend database. It occurs even after I just check to see if the tables
exist. Also, it seems that once the error occurs, MS Access has that
database locked by name. For example if I create a blank database and import
all the objects from the locked dtaabase (then delete the locked database), I
can modify the objects as long as I don't run the code that opens the backend
database. However, if I rename that database to the one that was corrupted
(the one I just deleted), It then gives the same error (I no longer have
exclusive rights).

Sub CheckInitialUpgrade()

On Error GoTo Err_CheckInitialUpgrade
Dim strdbPath As String, strNewTable As String, strdbName As String
Dim dbRemote As DAO.Database

'Set the path for the database (use the system default path)
strdbPath = DLookup("HomePath", "tblSystemDefaults", "RecordID = 1")

strdbName = strdbPath & "\dbOMSData.mdb" ' Don't rename remote database name

strNewTable = "tblVersionTracking"
Set dbRemote = OpenDatabase(strdbName)

'Check if new Table Exists, if not initial version upgrade hasn't been done
If funcTableExists(strNewTable, dbRemote) = False Then
If FormattedMsgBox("This database is still Version 2.0.1@Do you wish to
perform the intial " _
& "upgrade to version 3.0.1?@", vbYesNo, "Initial Upgrade Not
Performed") = vbYes Then
Call VersionUpgradeOne(dbRemote) ' Doesn't need to get here for
error to happen
End If
End If
'
Exit_CheckInitialUpgrade:
Exit Sub

Err_CheckInitialUpgrade:
MsgBox Err.Description
Resume Exit_CheckInitialUpgrade

End Sub
Public Function funcTableExists(strTable As String, dbRemote As Database) As
Boolean
On Error GoTo ErrorPoint

' This function will check to see if a
' table exists within the backend database
Dim doc As DAO.Document

With dbRemote.Containers!Tables
For Each doc In .Documents
If doc.Name = strTable Then
funcTableExists = True
Exit For
End If
Next doc
End With

ExitPoint:
On Error Resume Next
Exit Function

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Function
 
T

TC

I've mentioned a few points about your code; see below.

But I'm not clear exactly what error you are getting on or after
exactly what lines. Can you clarify that please?

HTH,
TC


' I suggest that you temporarily comment-out the following line. Then,
if a runtime error occurs, you will see exactly /where/ it occurs.

On Error GoTo Err_CheckInitialUpgrade


' This line should say DBENGINE.OpenDatabase. You can get all kinds of
weird errors if you use methods of the dbengine object without the
dbengine qualifier; for example, DAO licencing errors, and the
inability to create an MDE.

Set dbRemote = OpenDatabase(strdbName)


Public Function funcTableExists(strTable As String, dbRemote As
Database) As Boolean

Overly complex. All you need is:

dim s as string
on error resume next
s = dbRemote.tabledefs(strTable).name
funcTableExists = (err.number = 0)
end function

HTH,
TC
 
G

Guest

Thanks for the help. The problem was definitely in not using the DBengine
qualifier. I declared a workspace object ws as DBengine.workspaces(0) and
then used ws.OpenDatabase and everything worked after that.

Thanks again!

JimB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top