open dao dbsnapot in password protected database

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
 
D

Dirk Goldgar

In
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 [...]

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

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
 
7

77m.grub

In




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 [...]

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

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 MVPwww.datagnostics.com

(please reply to the newsgroup)- Hide quoted text -

- Show quoted text -

Worked! Thanks!

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top