open encrypted database programatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • n8kindt
    New Member
    • Mar 2008
    • 221

    #1

    open encrypted database programatically

    i'm trying to create a secure scenario where no one will be able to know our encrypted database passcode. BUT if they login to a form in another database successfully, it will open the encrypted database and systematically plug in the passcode thru vba (kind of like a user on a website logging into a secure SQL database i suppose). i may be going about this whole situation completely wrong but here is what i have for the code that i need to create to open the encrypted database.

    Code:
    Dim appAccess As Access.Application
    
    Sub DisplayForm()
    On Error GoTo errorhandler
        Dim strDB As String
        Dim Password As String
        Password = gg123
    
        ' Initialize string to database path.
        Const strConPathToSamples = "\\ggserver\SharedDocs\Access DB\"
    
        strDB = strConPathToSamples & "encryptedtest.accdb"
        ' Create new instance of Microsoft Access.
        
        Set appAccess = CreateObject("Access.Application")
        ' Open database in Microsoft Access window.
        
        
        appAccess.OpenCurrentDatabase strDB, "false", Password
        
    
    
    End Sub
    unfortunately, the "enter database password" still pops up when the new database opens and i have to type in the password TWICE. if i type in an incorrect password, the original code bounces back and gives me error #3031: "Not a valid password." i'm starting to wonder if by password, access means the old passwords used in access 2003 and earlier and the OpenCurrentData base function has nothing to do with encrypted databases. i have access 2007 and there are no such logins like that--just encrypted passwords.

    so if anyone has any idea why this code is not working correctly or what an alternative might be then please let me know! thanks guys

    --nate
  • n8kindt
    New Member
    • Mar 2008
    • 221

    #2
    LOL i am still googling for the answer and i got all excited when google found a thread in bytes.com entitled "open encrypted database programatically " but when i clicked on it i realized it was my own post! LOL still could use some help on this one!! thanks!!

    Comment

    • n8kindt
      New Member
      • Mar 2008
      • 221

      #3
      figured it out myself! i didn't have any business stumbling into the answer but i got lucky. here's the new code:

      Code:
      Sub DisplayForm()
      'On Error GoTo errorhandler
          Dim strDB As String
          Dim Password As String
          Password = gg123
          
      
      
      
      
          ' Initialize string to database path.
          Const strConPathToSamples = "\\ggserver\SharedDocs\Access DB\"
      
          strDB = strConPathToSamples & "encryptedtest.accde"
          ' Create new instance of Microsoft Access.
          
          Set appAccess = CreateObject("Access.Application")
          ' Open database in Microsoft Access window.
      [u]    appAccess.Visible = True
          appAccess.UserControl = True
          appAccess.AutomationSecurity = 1 ' = msoAutomationSecurityLow[/u]
          appAccess.OpenCurrentDatabase "\\ggserver\shareddocs\access DB\encryptedtest.accde", False, "gg123"
          Set appAccess = Nothing
          
          
          
      Exit Sub

      Comment

      • danisoje
        New Member
        • Jun 2011
        • 1

        #4
        May God personnaly bless you. You solved my tomorrow problem yesterday.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          I would suggest that is a highly doubtful approach to Access security - Turning it off (or down) to get past it is dodgy enough on your own systems, but if it were to run on someone else's you may be liable to being sued for damages if they were to allow some other dodgy code to run because your code had reduced the security level. That could be a serious responsibility.

          Comment

          Working...