Function dbAvailable (strDatabase As String) As Integer ' 'This function checks to see if a database can 'be opened exclusively. ' 'NOTE: This procedure contains line break characters 'for readability. These characters are not supported 'in Access Basic. ' Dim DAO_WorkSpace As WorkSpace Dim DAO_Database As Database
On Error GoTo dbAvailable_Err
Set DAO_WorkSpace = DBEngine.Workspaces(0)
Set DAO_Database = _
DAO_WorkSpace.OpenDatabase(strDatabase, True, True)
'
'Return -1 on no errors.
'
dbAvailable = True
dbAvailable_Exit: ' 'If an object variable is Nothing it 'has not been Set or initialized. ' If Not (DAO_WorkSpace Is Nothing) Then DAO_WorkSpace.Close
If Not (DAO_Database Is Nothing) Then DAO_Database.Close
Exit Function
dbAvailable_Err: ' 'On error let the function return the error code. 'Recall that Err returns Integers. ' dbAvailable = Err GoTo dbAvailable_Exit
End Function