Function OpenProtectedDB(strDBPath As String, _
                         strPwd As String)
   Dim cnnDB As ADODB.Connection   Set cnnDB = New ADODB.Connection   ' Open database for shared (by default), read/write access, and 
   ' specify database password.
   With cnnDB
      .Provider = "Microsoft.Jet.OLEDB.4.0"
      .Properties("Jet OLEDB:Database Password") = strPwd
      .Mode = adModeReadWrite
      .Open strDBPath
   End With
   ' Code to work with database goes here.
   cnnDB.Close
   Set cnnDB = Nothing
End Function