I have written an MS-Access application and split the database. In order to improve performance when it is being used by multiple concurrent users on a network (as suggested by this), the front-end creates a persistent connection to the back-end using the following routine:
Public theOpenDb As dao.Database
Public Sub OpenTheDatabase(pfInit As Boolean, Optional databasePath As Variant)
' Open a handle to a database and keep it open during the entire time the application runs.
' Params : pfInit TRUE to initialize (call when application starts)
' FALSE to close (call when application ends)
' Source : Total Visual SourceBook
Dim strMsg As String
If pfInit Then
On Error Resume Next
Set theOpenDb = OpenDatabase(databasePath)
If Err.number > 0 Then
strMsg = "Trouble opening database: " & databasePath & vbCrLf & _
"Make sure the drive is available." & vbCrLf & _
"Error: " & Err.Description & " (" & Err.number & ")"
End If
On Error GoTo 0
If strMsg <> "" Then
MsgBox strMsg
End If
Else
On Error Resume Next
theOpenDb.Close
Set theOpenDb = Nothing
End If
End Sub
Some of my users report repeatedly receiving "unrecognized database format" errors in their back-end databases. The databases have all been recoverable via compact and repair, but this problem is still very frustrating to them.
I read here:
Do not hold connections open: Always remember to close the Microsoft Access database connections after finishing your work. Open Access database connections always have the chance of becoming corrupt if network connections are lost.
Does maintaining a persistent connection between my front-end and back-end increase the risk of database corruption?