Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2003
    Posts
    18

    Unanswered: Hit a major problem :s

    It is about Error Handlers...

    I have one to handle an error should the password be entered incorrectly, however, the same msgbox for that error appears for all errors. Why is this?

  2. #2
    Join Date
    Dec 2003
    Location
    WA, USA
    Posts
    51

    Re: Hit a major problem :s

    You need to supply more information, What does your procedure look like and how are you calling it?
    Bob

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    You're missing a Resume Next call ...

  4. #4
    Join Date
    Nov 2003
    Posts
    18
    Private Sub cmdOK_Click()
    On Error GoTo ErrHandler
    Dim Msg, Response
    Dim StrInput, StrMsg
    Dim PW As String
    PW = DLookup("Password", "tblPassword")
    Select Case frameCustomerOperations.Value
    Case 1
    StrMsg = "Please enter password"
    StrInput = InputBox(Title:="View Selection Menu", Prompt:=StrMsg)
    'Enter password to open selection menu

    If StrInput = PW Then

    cmdLeaveAuthorisedView.Visible = True
    Me.txtTab.Locked = False
    Me.txtTab.SpecialEffect = 2
    'If password is correct the relevant fields are unlocked and become sunken.

    Else

    GoTo PasswordErrHandler
    'Incorrect password so display error message

    End If
    Case 2
    DoCmd.OpenForm "frmAddTeam", acNormal, "", "", acAdd, acNormal

    Case 3
    DoCmd.OpenForm "frmAddCustomer", acNormal, "", "", acAdd, acNormal

    Case 4
    StrMsg = "Please enter password"
    StrInput = InputBox(Title:="View Selection Menu", Prompt:=StrMsg)
    'Window appears asking for password.

    If StrInput = PW Then

    cmdLeaveAuthorisedView.Visible = True
    Me.txtFirstName.Locked = False
    Me.txtFirstName.SpecialEffect = 2
    Me.txtSurname.Locked = False
    Me.txtSurname.SpecialEffect = 2
    Me.txtDateOfBirth.Locked = False
    Me.txtDateOfBirth.SpecialEffect = 2
    Me.txtAddressLine1.Locked = False
    Me.txtAddressLine1.SpecialEffect = 2
    Me.txtAddressLine2.Locked = False
    Me.txtAddressLine2.SpecialEffect = 2
    Me.txtTown.Locked = False
    Me.txtTown.SpecialEffect = 2
    Me.txtCounty.Locked = False
    Me.txtCounty.SpecialEffect = 2
    Me.txtPostalCode.Locked = False
    Me.txtPostalCode.SpecialEffect = 2
    Me.txtTelephoneNumber.Locked = False
    Me.txtTelephoneNumber.SpecialEffect = 2
    Me.txtE_MailAddress.Locked = False
    Me.txtE_MailAddress.SpecialEffect = 2
    'If password is correct, the relevant fields are unlocked and become sunken.
    'The button to "Leave Authorised View" also appears.

    Else

    GoTo PasswordErrHandler
    'If the password is incorrect the error handler is run.

    End If

    Case 5
    StrMsg = "Please enter password"
    StrInput = InputBox(Title:="Authorise", Prompt:=StrMsg)
    'Enter password to open selection menu

    If StrInput = PW Then

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    'If password is correct the relevant fields are unlocked and become sunken.

    Else

    GoTo PasswordErrHandler
    'Incorrect password so display error message

    End If
    End Select
    Exit Sub

    PasswordErrHandler:
    Msg = "Incorrect Password"
    Response = MsgBox(Msg)

    ErrHandler:
    'Code to handle errors.
    On Error Resume Next

    End Sub

    Where would the resume next go?

  5. #5
    Join Date
    Nov 2003
    Posts
    18
    Any input on this?

    I have to go to bed soon, and need to do this ASAP.

    Thank you

  6. #6
    Join Date
    Dec 2003
    Location
    WA, USA
    Posts
    51
    try replacing your Err handeler
    On Error Resume Next
    With
    a Msgbox stating the error
    vba.err.description

    and then try stepping through your code paying special attention to where you are when you get an error.
    Bob

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    OOPS! I was premature .... You do have Resume Next. Your problem is that you fall thru to the errhandler code and resume next incorrectly. Put something before your errhandler label to stop ( an Exit Sub or a goto someplaceelse ) ...

  8. #8
    Join Date
    Nov 2003
    Posts
    18
    As you can see, I do have an exit sub.

    The PASSWORD ERROR HANDLER runs when there are other errors, not just the password one. It shouldn't be doing this!

  9. #9
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Originally posted by TheGame7
    As you can see, I do have an exit sub.

    The PASSWORD ERROR HANDLER runs when there are other errors, not just the password one. It shouldn't be doing this!

    Did you try to trace your Sub, it is the best way to see yourself what happens when an error shines....

Posting Permissions

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