OpenDatabase - Error 3031 - Not a valid password

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #1

    OpenDatabase - Error 3031 - Not a valid password

    In my code :
    Code:
        strConnect = Replace("MS Access;PWD=%P", "%P", Scramble(conLinkPW))
        Set dbThat = wsVar.OpenDatabase(Name:=strDBPath, _
                                        Options:=True, _
                                        Connect:=strConnect)
    the variable strConnect is set up with a perfectly valid string - correctly formatted. My code doesn't use visible password strings but I was able to test the value and it matched the database password exactly :
    Code:
    MS Access;PWD=XXXXX
    The code above kept failing with the error :
    Code:
    Run-time error 3031:
    Not a valid password.
    I've tried all sorts of variations of the string, but all with the same results.
    How to use the OpenDatabase method to open password-protected databases in Access 2000 indicates how this string should be formatted, and mine matches that perfectly.
    Last edited by NeoPa; Feb 10 '13, 05:28 AM.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    I did some more Googling (I'd already done a fair bit before posting of course.) and found myself back at the same link (How to use the OpenDatabase method to open password-protected databases in Access 2000). This time though, I noticed something very important that wasn't well highlighted (No surprise - It was pointing out an error in the Help file) :
    Originally posted by Link
    Link:
    NOTE: Even though the Options and Read-Only arguments of the OpenDatabase method are documented in Help as being optional arguments, you must provide them when you use the Connect argument.
    The following code therefore works perfectly :
    Code:
        strConnect = Replace("MS Access;PWD=%P", "%P", Scramble(conLinkPW))
        Set dbThat = wsVar.OpenDatabase(Name:=strDBPath, _
                                        Options:=True, _
                                        ReadOnly:=False, _
                                        Connect:=strConnect)
    Last edited by NeoPa; Feb 10 '13, 05:29 AM.

    Comment

    • jimatqsi
      Moderator Top Contributor
      • Oct 2006
      • 1293

      #3
      Just want to let you know this has been helpful to me today :)

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Very pleased to hear it Jim. This has caught me a couple of times that I'm aware of. I hope now it's here I'll never need to work it all out again.

        Comment

        Working...