Results 1 to 4 of 4

Thread: Controlling app ending crash.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 1999
    Posts
    21

    Post

    I need some help with how to code a generic error handler, or something to that affect that will display the error for the user, so they will know why a function did not happen, and then clear the error so that the user can continue working. I tried to implement this, but after my code displayed the error, and I tried to click or tab somewhere else on the form, the application will crash. HELP!!!!

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    By "clear the error" do you mean 1) correct the error and continue, or 2) set the error number back to 0? The first can be very tricky. In any case the following does both.
    Code:
    ErrorRoutine:
    
        Select Case Err.Number
            Case 3022 'Duplicate filename found
                Err.Clear
                gnStyle = vbYesNo + vbExclamation
                '...already exists. Do you want to replace it?"
                gnResponse = MsgBox(ResolveResString(resREPLACE, "|1", sSysName), gnStyle, gsTitle)
                If gnResponse = vbYes Then
                    Dim SQL As String
                    SQL = "DELETE FROM SavedSystems WHERE SystemName = " & "'" & sSysName & "'"
                    gdbRWTU.Execute SQL, dbFailOnError
                    Resume SaveTheSystem
                Else
                    bSaveAs = True
                    Resume GetName
                End If
            Case Is <> 0
                DisplayError "SaveSystem"
        End Select
    ------------------
    Marty

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 1999
    Posts
    21

    Post

    What I need to do is to be able to display what the error is so the user knows what happened (i.e. why they couldn't save), but then clear the error so that they can continue, and not have the application crash.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Well, then what you want to do is to display a MsgBox that contains information from the Err object (like Err.Description). To find out what things you want to include, put a break point in your error routine, cause an error to happen, and use the Immediate window to display such things as Err.Number, Err.Source, Err.Description.

    ------------------
    Marty

Posting Permissions

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



Click Here to Expand Forum to Full Width