Results 1 to 4 of 4
  1. #1
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Database Password in Linked DB (2000 and 2003)

    I have a database that links to a back end access db.
    The Back end has a database password.
    If the back end password is NOT changed through the front end then
    when the front end loads up it gets an error 3031 that is NOT trapped.
    The code that checks for the error is as below

    On Error GoTo ReLinkError
    Set rst = CurrentDb.OpenRecordset("tblXXXGoesHere") 'If it cannot open table then linking failed so go to error handler

    The error trap is

    ReLinkError:
    If Err.Number = 3031 Then
    MsgBox "Database Password has changed" & vbLf & "You need to relink", vbExclamation
    Else
    MsgBox "Database needs to relink", vbExclamation
    End If
    fLinkError = True
    Resume Next

    But although break on Unhandled Errors is set
    The trap NEVER triggers but gets a dialogue stating

    Runtime error 3031
    Not a valid password
    and only offering End or Debug

    Any ideas why the error trap fails?

    If it worked then an update password option would be enabled
    and the tables can be re-linked.
    Andrew

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Database Password in Linked DB (2000 and 2003)

    I tried it in a test database, and the error was trapped as intended when I changed the password on the backend: the custom MsgBox was displayed instead of the built-in error message.
    Check carefully whether there are other problems - try single-stepping through the code.

  3. #3
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Database Password in Linked DB (2000 and 2003)

    I did fix this problem but it was an odd one.

    If I did the test at the start of the routine it was trapped successfully.
    If I tried it nested inside another IF it appears to cause the problem.

    I have now re-organized the code so that it does not RUN AS A NESTED IF.

    I am going to check on another system if the issue is nested if's
    I'll post my results back

    The issue did occur on Access 2000, 2002 and 2003.
    Andrew

  4. #4
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Database Password in Linked DB (2000 and 2003)

    I checked this on another database and the nesting of IF's made no difference, the error trap still worked.
    Therefore I am not sure why moving the test earlier in the routine made it work ok.
    If I ever find out why it was happening I'll post the reason here.
    Andrew

Posting Permissions

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