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
Try something like this:
' ...
Dim ServerPW As String
Dim LocalPW As String
ServerPW = "YourPW"
LocalPW = "YourOtherPW"
Set rst = CurrentDb.OpenRecordset( _
"SELECT Version FROM [MS Access;Database=" & _
ServerFile & ";pwd=" & ServerPW & "].tblAdmin",
dbOpenSnapshot)
ServerVersion = rst!Version
rst.Close
Set rst = CurrentDb.OpenRecordset( _
"SELECT Version FROM [MS Access;Database=" & _
LocalFile & ";pwd=" & LocalPW & "].tblAdmin",
dbOpenSnapshot)
LocalVersion = rst!Version
rst.Close
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Worked! Thanks!
Mike