Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    supress err.descirption message (Access 2000)

    Instead of having the default error fire, how can I get my own error msg to fire instead? right now, both of them fire. Basically, how I supress the default error message?

    Thanks

    My example:
    Dim SQLString As String
    On Error GoTo Err_MyError:

    SQLString = "INSERT INTO VHRV_Calendar (FrameColor, DealershipID, AddSalesRep," _
    & "SalesRepName, SalesRepPic)" _
    & "VALUES (" & FrameColor & ", " & DealerID & ", false, '" _
    & Me.txt_SalesName & "', '" & Me.txt_SalesLogo & "')"

    DoCmd.RunSQL SQLString

    Exit_MyError:
    Exit Function

    Err_MyError:
    If Err.Number = 2501 Then
    MsgBox "The 'Add Sales Rep' option is set to yes. " & vbCrLf _
    & "A file and/or photo is not attached.", vbCritical + vbOKOnly, "Data Required"
    PassBack = False
    Resume Exit_MyError
    End If

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

    Re: supress err.descirption message (Access 2000)

    You already have the answer in your code. You can display what you like in the code after the Err_MyError: label. You can show a generic, non-specific message:

    Err_MyError:
    MsgBox "Something went wrong, but don't ask me what exactly!", vbExclamation
    Resume Exit_MyError
    End Sub

    or you can handle some errors yourself, and the rest generically:

    Err_MyError:
    Select Case Err
    Case 53
    MsgBox "Can't find the stupid file", vbCritical
    Case 61
    MsgBox "Your disk has been filled to the very brim.", vbInformation
    Case Else
    MsgBox "Something unforeseen has gone wrong.", vbExclamation
    End Select
    Resume Exit_MyErr
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: supress err.descirption message (Access 2000)

    But I keep getting this error message posted below. I know why its happening, but I want my message to only show up, not both
    Attached Images Attached Images

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

    Re: supress err.descirption message (Access 2000)

    OK, I see what you mean. RunSQL displays the standard error message before your error handling kicks in. To avoid this, use

    CurrentDb.Execute SQLString, 128

    instead of DoCmd.RunSQL. If you have a reference to the Microsoft DAO 3.6 Object Library, you can use the symbolic constant dbFailOnError instead of the literal 128.

  5. #5
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: supress err.descirption message (Access 2000)

    OK that worked great. I noticed now though that now, all my err.number = 0. Before I was able to get an actual value like 2501 and use in my error handling. Is there a way that I could still use those err.number in my error handling since I am not using the docmd to insert the SQL now?

    Thanks

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

    Re: supress err.descirption message (Access 2000)

    I don't understand why that would happen. I get error # 3317 if there are values that violate validation rules, #3022 if there are duplicate values for a unique key etc.

  7. #7
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: supress err.descirption message (Access 2000)

    OK, your right, I had a mistake on my end. My line to display the err.number was not in the error function.

    Thanks for the help

Posting Permissions

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