What about using an error handler?
....
On error GOTO ErrHndlr
....
Exit sub
ErrHndlr:
Select Case Err
Case 'whatever err you anticipate
'get out of whatever loop or tell the user what happened
'so you can handle groups or single errors
....
err.clear
Case Else
MsgBox "An unanticipated error has occurred: " & vbcrlf &
"ERROR#: " & Err.Number & _
vbCRLF & Err.Description",
vbInformation,App.Title,Err.HelpFile, Err.HelpContext
'Comment out the STOP and RESUME before distribution, these will
let you locate the error
Stop
Resume
'Do whatever you want to do with unknown errors, I usually END
the application after writing to a textfile 'the info of the
error, date, and where it happened - I don't usually trust the User for this
WriteErrorToTextfile
Err.Clear
End
End Select
I hope this helps....
Dean R. LaMana
Quote:
> The most annoying part about data access in VB is the fact that VB will
> stop the program at the slightest hint of trouble, even when such
> problems are not even slightly "life-threatening" to the application.
> Okay, it's good that VB is so intuitive, but when running for real, a
> lot of so called "errors" are just facts of data access life (like
> records being temporarily locked). Things like this shouldn't halt
> execution of a program, it should merely continue, but return a value
> saying that the operation was unsuccessful.
> Yet I can't seem to find a way of switching this off (short of putting
> On Error Resume Next everywhere, which doens't make debugging easy). The
> closest I've got so far, is to create a class object that mimics all the
> recordset functions and returns error values instead of stopping the
> program.
> Does anyone else have any better solutions.
> Steven Palmer