Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2004
    Location
    Terrapin Nation
    Posts
    205

    Unanswered: Checking for dB Passwords

    Hello,

    I have some code that loops through a directory structure searching for access databases. When it finds one it opens the dB then looks to see if a specific table exists within that database.

    When the code finds a dB that has security on it (usernam/pwd) an error pops up. The issue is that the code will not resume or be handled. I manually press debug and it returns to the code that I am having an issue with:

    Set dB = OpenDatabase(strPath)

    Anyone have any ideas on how I can work this out? Do I need to use a system object instead of the dao dB object?

    THanks,



    Terp.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if its gpoing to debug, then there must be an error code attached
    find out waht the error is and then trap for that error.
    Alternbatively if you believe error handling is for wimps place an on error resume next in the relevant function

  3. #3
    Join Date
    Jun 2004
    Location
    Terrapin Nation
    Posts
    205
    unfortunatly, the error hangs and does not go to debug. The system waits for the user to click debug (which takes you back to the line causing the issue) or end.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    [applause]gotta admire the "error handling is for wimps"[/applause]

    anyhoooo, assuming we can put our macho pride aside for a second....
    immediately after the Dims in your Set dB = OpenDatabase(strPath) routine put
    on error goto wimpStuff

    and before the end sub/function put
    wimpExit:
    exit sub 'or exit function if that is what it is
    wimpStuff:
    msgbox err.number & ": " & err.description,vbinformation,"only wimps see this!"
    resume wimpExit


    and... ????

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by izyrider
    [applause]gotta admire the "error handling is for wimps"[/applause]
    praise indeed form izyrider, whythankyou....

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by TerpInMD
    Hello,

    I have some code that loops through a directory structure searching for access databases. When it finds one it opens the dB then looks to see if a specific table exists within that database.

    When the code finds a dB that has security on it (usernam/pwd) an error pops up. The issue is that the code will not resume or be handled. I manually press debug and it returns to the code that I am having an issue with:

    Set dB = OpenDatabase(strPath)

    Anyone have any ideas on how I can work this out? Do I need to use a system object instead of the dao dB object?
    Lol - I have an app that does just this. You will find, with Izys error trap, that the error number for an unsupplied password is 3031 (that is a password protected rather than mdw protected db specifically).

    I would pop a test for this error number (and any others that appear for mdw related password problems) in the error trap and resume to an appropriate line in your code rather than exit the proc if it is this error. An appropriate line might beright at the end of, but still inside, your loop. e.g. (pseudocode)

    Code:
    On Error Goto wimpError
     
    Do While CleverExpression = True
     
    Set Db = Workspace(0).OpenDatabase(MyPath)
     
    'Do stuff with DB
     
    HighWimpFactor:
    Loop
     
    wimpExit:
     
    Exit Sub
     
    wimpError:
     
    If Err.Number = 3031 Resume HighWimpFactor
     
    msgbox "Error etc."
     
    Resume wimpExit
     
    End Sub
    HTH
    Last edited by pootle flump; 01-06-06 at 09:14.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •