LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Form Err.Raise error not trapped by entry procedure error handler

I am having trouble getting my error handling to trap custom errors
generated by the Err.Raise command. My application is composed of user
forms and class modules without any standard modules. The Error
Trapping option is set to "Break on Unhandled Errors". My error
handling system is very simple and is designed to terminate the
application if any custom errors are detected. The error handler is
placed in the entry procedure with all custom errors within the various
forms or classes to be handled by this routine. Here is the code for
the entry procedure which is located in ThisWorkbook and called from
the Workbook_Open() Sub procedu

Private Sub Workbook_Open()
Call OpenMainForm
End Sub

Public Sub OpenMainForm()
'
Dim frmMainForm As FMainForm

Set frmMainForm = New FMainForm

On Error GoTo ErrorTrap

Call frmMainForm.InitializeForm

frmMainForm.Show vbModal

Unload frmMainForm

Set frmMainForm = Nothing

Exit Sub

ErrorTrap:
MsgBox Err.Description, vbCritical, Err.Source

End Sub

Within the various user forms and class modules are validation checks
which raise errors if a problem is detected:

Err.Raise 1, "Sub HandleRunEditInfo", "Selection is not a valid
range."
Exit Sub

The expected behavior is for VBA to work up the Call Stack until it
encounters the error handler in the entry procedure located in
ThisWorkbook. Instead, VBA is displaying an unhandled error message.
There are no other error handlers (i.e. On Error statements) anywhere
within the forms or classes except for the entry procedure.

The unhandled error is being raise within the main form as a result of
a change in one of the controls but not being trapped by the error
handler contained in ThisWorkbook. I did try and move the above
routine to a standard module. This did not resolve the problem.

Any suggestion would be appreciated.

Thanks,

John C.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 7 March 7th 05 06:29 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM
Error not trapped - please help!!! Bura Tino Excel Programming 8 April 18th 04 09:27 PM
Can error 1004 be trapped???? Richard m Excel Programming 3 November 29th 03 02:55 PM
Raise Error from ActiveX dll to VBA Serge[_2_] Excel Programming 0 September 23rd 03 05:05 PM


All times are GMT +1. The time now is 03:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"