7
77m.grub
Below is the code, but basically the code snippet compares a server
and local version of the database.... Note that the user has neither
the server or local versions of the database open when this code is
executed; it is executed from a third, separate database file that
executes this code automatically when the user clicks to open the it
(the third database). \
Problem is that both the server and local database files are database
password protected (database password NOT user-level password
security). I cannot figure out how to open the databases if they have
a database password. Any ideas? Thanks! Mike
Dim rst As DAO.Recordset
Dim ServerDir As String
Dim LocalDir As String
Dim ServerFile As String
Dim LocalFile As String
Dim ServerVersion As Integer
ServerDir = "\\myserver\serverdb"
LocalDir = "C:\Program Files\localdb"
ServerFile = ServerDir & "\serverdb.mdb"
LocalFile = LocalDir & "\localdb.mdb"
On Error GoTo Err_Handler
Set rst = CurrentDb.OpenRecordset("SELECT Version FROM tblAdmin IN
'" & ServerFile & "'", dbOpenSnapshot)
ServerVersion = rst!Version
rst.Close
Set rst = CurrentDb.OpenRecordset("SELECT Version FROM tblAdmin IN
'" & LocalFile & "'", dbOpenSnapshot)
LocalVersion = rst!Version
rst.Close
If ServerVersion > LocalVersion Then
MsgBox "An update to the database is available. Press OK to
apply update."
Kill LocalFile
FileCopy ServerFile, LocalFile
MsgBox "Update complete. Click OK to continue."
End If
Set rst = Nothing
Me.TimerInterval = 10
Exit Sub
Err_Handler:
MsgBox " Microsoft Access encountered an error." &
vbCrLf & "You may not have the most recent version of the database." &
vbCrLf & " Please contact your system administrator."
Form_Timer
Exit Sub
End Sub
and local version of the database.... Note that the user has neither
the server or local versions of the database open when this code is
executed; it is executed from a third, separate database file that
executes this code automatically when the user clicks to open the it
(the third database). \
Problem is that both the server and local database files are database
password protected (database password NOT user-level password
security). I cannot figure out how to open the databases if they have
a database password. Any ideas? Thanks! Mike
Dim rst As DAO.Recordset
Dim ServerDir As String
Dim LocalDir As String
Dim ServerFile As String
Dim LocalFile As String
Dim ServerVersion As Integer
ServerDir = "\\myserver\serverdb"
LocalDir = "C:\Program Files\localdb"
ServerFile = ServerDir & "\serverdb.mdb"
LocalFile = LocalDir & "\localdb.mdb"
On Error GoTo Err_Handler
Set rst = CurrentDb.OpenRecordset("SELECT Version FROM tblAdmin IN
'" & ServerFile & "'", dbOpenSnapshot)
ServerVersion = rst!Version
rst.Close
Set rst = CurrentDb.OpenRecordset("SELECT Version FROM tblAdmin IN
'" & LocalFile & "'", dbOpenSnapshot)
LocalVersion = rst!Version
rst.Close
If ServerVersion > LocalVersion Then
MsgBox "An update to the database is available. Press OK to
apply update."
Kill LocalFile
FileCopy ServerFile, LocalFile
MsgBox "Update complete. Click OK to continue."
End If
Set rst = Nothing
Me.TimerInterval = 10
Exit Sub
Err_Handler:
MsgBox " Microsoft Access encountered an error." &
vbCrLf & "You may not have the most recent version of the database." &
vbCrLf & " Please contact your system administrator."
Form_Timer
Exit Sub
End Sub