Click to See Complete Forum and Search --> : Controlling app ending crash.
SME
Jan 4th, 2000, 07:58 AM
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!!!!
MartinLiss
Jan 4th, 2000, 08:24 AM
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.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
SME
Jan 4th, 2000, 09:21 AM
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.
MartinLiss
Jan 4th, 2000, 10:07 AM
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.