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
"TC" wrote:
> Show us the line of code on which you get that error (and the dozen or
> so lines around it).
>
> TC
>
>
|