Connecting Tech Pros Worldwide Help | Site Map

Form level error handling

  #1  
Old November 13th, 2005, 05:04 AM
John
Guest
 
Posts: n/a
Hi

Is it possible to handle errors at form level that are not caught by the
error handlers within the form subs?

Regards


  #2  
Old November 13th, 2005, 05:04 AM
Tom van Stiphout
Guest
 
Posts: n/a

re: Form level error handling


On Tue, 2 Nov 2004 12:45:58 -0000, "John" <John@nospam.infovis.co.uk>
wrote:

Will the Form_Error event work for you?
-Tom.
[color=blue]
>Hi
>
>Is it possible to handle errors at form level that are not caught by the
>error handlers within the form subs?
>
>Regards
>[/color]

  #3  
Old November 13th, 2005, 05:04 AM
deko
Guest
 
Posts: n/a

re: Form level error handling


> Is it possible to handle errors at form level that are not caught by the[color=blue]
> error handlers within the form subs?[/color]

What kind of error?

Here's an error handling routine that has worked nicely for me - I use it on
every sub in the project

[code on Form]
Public Sub cmdProcName_Click()
On Error GoTo HandleErr
[code omitted]
Exit_Here:
On Error Resume Next
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
modHandler.LogErr ("frm0"), ("cmdProcName_Click")
End Select
Resume Exit_Here
End Sub

[standard module modHandler]
Public Sub LogErr(fn, pn)
Dim strErrMsg As String
Dim strErrSrc As String
Dim strSql As String
strErrMsg = "Error Number " & Err.Number & ": " & Err.Description
strErrSrc = vbCrLf & vbCrLf & fn & "." & pn
MsgBox strErrMsg & strErrSrc, vbCritical, " Unexpected Error"
On Error GoTo Exit_Here
strSql = "INSERT INTO tblErrorLog ( [ErrMsg], [ErrFrm], [ErrPrc] )
VALUES (" & _
Chr(34) & strErrMsg & Chr(34) & ", " & Chr(34) & fn & Chr(34) & ", " &
Chr(34) & _
pn & Chr(34) & ")"
DoCmd.SetWarnings False
DoCmd.RunSQL strSql
DoCmd.SetWarnings True
Exit_Here:
Exit Sub
End Sub


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
CAlling another sub from a sub. hyperpau answers 14 August 28th, 2007 05:24 AM
When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected to the database. SQLSTATE=57030. alingsjtu@gmail.com answers 5 September 23rd, 2006 09:05 PM