Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

open dao dbsnapot in password protected database

1 view
Skip to first unread message

77m....@gmail.com

unread,
Jun 14, 2007, 9:13:39 AM6/14/07
to
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

Dirk Goldgar

unread,
Jun 14, 2007, 12:25:52 PM6/14/07
to
In news:1181826819.0...@d30g2000prg.googlegroups.com,

77m....@gmail.com <77m....@gmail.com> wrote:
> 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 MVP
www.datagnostics.com

(please reply to the newsgroup)


77m....@gmail.com

unread,
Jun 14, 2007, 1:34:01 PM6/14/07
to
On Jun 14, 12:25 pm, "Dirk Goldgar" <d...@NOdataSPAMgnostics.com>
wrote:
> Innews:1181826819.0...@d30g2000prg.googlegroups.com,
> (please reply to the newsgroup)- Hide quoted text -
>
> - Show quoted text -

Worked! Thanks!

Mike

0 new messages