Breaks on error even when error trapping set to break on unhandled 
Author Message
 Breaks on error even when error trapping set to break on unhandled

Hi

Have an app that has error trapping around an ADO recordset.open statement,
and I have set the environment to break only on unhandled errors, yet it
still breaks if an error occurs here - but nowhere else on other errors.

Any ideas.

Thanks

Steven Segal



Sun, 01 Aug 2004 23:46:01 GMT  
 Breaks on error even when error trapping set to break on unhandled

released on Wed, 13 Feb 2002 17:46:01 +0200 bearing the
following fruit:

Quote:
>Hi

>Have an app that has error trapping around an ADO recordset.open statement,
>and I have set the environment to break only on unhandled errors, yet it
>still breaks if an error occurs here - but nowhere else on other errors.

An the error is....

You may need to post code, for example you are not using
'goto' in the error trap to return to the code?

J



Sun, 01 Aug 2004 23:59:40 GMT  
 Breaks on error even when error trapping set to break on unhandled


Quote:
> Hi

> Have an app that has error trapping around an ADO

recordset.open statement,
Quote:
> and I have set the environment to break only on unhandled
errors, yet it
> still breaks if an error occurs here - but nowhere else on

other errors.

What line does it break on, and what does the surrounding code
look like?



Mon, 02 Aug 2004 00:00:41 GMT  
 Breaks on error even when error trapping set to break on unhandled


Fri, 19 Jun 1992 00:00:00 GMT  
 Breaks on error even when error trapping set to break on unhandled
Hi

Herewith the code snippet.  It bombs on the .Open "Insert ..." because of
violating a key constraint.  That's fine, but why does VB break when it's
set to do so only on unhandled errors?

Thanks

Steven
Johannesburg, RSA

                With mrsImport
                    On Error GoTo insert_err
                    .Open "INSERT INTO Register ..." _   ******* BOMBS HERE
**********

                    Debug.Print "insert ok> " & sHolderId
                    GoTo insert_done
insert_err:
                    Debug.Print "error on insert> " & sHolderId
insert_done:
                    On Error GoTo 0
                End With



Mon, 02 Aug 2004 15:38:33 GMT  
 Breaks on error even when error trapping set to break on unhandled
Is it possible that you are generating two errors within this procedure? Vb
can handle only one error at a time. For example vb will break on the second
error in the below code.

Sub Foo()
    Dim i as Integer
    On Error GoTo err_handler
    i = i  / 0
Test:
    i = i  / 0
    Exit Sub
err_handler:
    GoTo Test
End Sub

The solution in this case is to change GoTo Test to Resume Test, which
resets the error handler.

David


Quote:
> Hi

> Herewith the code snippet.  It bombs on the .Open "Insert ..." because of
> violating a key constraint.  That's fine, but why does VB break when it's
> set to do so only on unhandled errors?

> Thanks

> Steven
> Johannesburg, RSA

>                 With mrsImport
>                     On Error GoTo insert_err
>                     .Open "INSERT INTO Register ..." _   ******* BOMBS
HERE
> **********

>                     Debug.Print "insert ok> " & sHolderId
>                     GoTo insert_done
> insert_err:
>                     Debug.Print "error on insert> " & sHolderId
> insert_done:
>                     On Error GoTo 0
>                 End With



Mon, 02 Aug 2004 19:45:30 GMT  
 Breaks on error even when error trapping set to break on unhandled
Hi

Thanks - I'll test this possibility - for the moment I got around it by
rewriting the SQL query.

Thanks

Steven


Quote:
> Is it possible that you are generating two errors within this procedure?
Vb
> can handle only one error at a time. For example vb will break on the
second
> error in the below code.

> Sub Foo()
>     Dim i as Integer
>     On Error GoTo err_handler
>     i = i  / 0
> Test:
>     i = i  / 0
>     Exit Sub
> err_handler:
>     GoTo Test
> End Sub

> The solution in this case is to change GoTo Test to Resume Test, which
> resets the error handler.

> David



> > Hi

> > Herewith the code snippet.  It bombs on the .Open "Insert ..." because
of
> > violating a key constraint.  That's fine, but why does VB break when
it's
> > set to do so only on unhandled errors?

> > Thanks

> > Steven
> > Johannesburg, RSA

> >                 With mrsImport
> >                     On Error GoTo insert_err
> >                     .Open "INSERT INTO Register ..." _   ******* BOMBS
> HERE
> > **********

> >                     Debug.Print "insert ok> " & sHolderId
> >                     GoTo insert_done
> > insert_err:
> >                     Debug.Print "error on insert> " & sHolderId
> > insert_done:
> >                     On Error GoTo 0
> >                 End With



Sat, 07 Aug 2004 19:35:36 GMT  
 Breaks on error even when error trapping set to break on unhandled
I think you need a Resume statement to get VB to consider the
error handled.

From MSDN "On Error" help:

"An "enabled" error handler is one that is turned on by an On
Error statement; an "active" error handler is an enabled handler
that is in the process of handling an error. If an error occurs
while an error handler is active (between the occurrence of the
error and a Resume, Exit Sub, Exit Function, or Exit Property
statement)...

...Once an error is handled by an error handler in any
procedure, execution resumes in the current procedure at the
point designated by the Resume statement."

--
________________________________________________________________

Falls Church, {*filter*}ia                        703-560-7380
________________________________________________________________

Quote:
> Hi

> Herewith the code snippet.  It bombs on the .Open "Insert ..."
because of
> violating a key constraint.  That's fine, but why does VB
break when it's
> set to do so only on unhandled errors?

> Thanks

> Steven
> Johannesburg, RSA

>                 With mrsImport
>                     On Error GoTo insert_err
>                     .Open "INSERT INTO Register ..." _
******* BOMBS HERE
> **********

>                     Debug.Print "insert ok> " & sHolderId
>                     GoTo insert_done
> insert_err:
>                     Debug.Print "error on insert> " &

sHolderId

Try this: >>>>>>>     Resume insert_done

Quote:
> insert_done:
>                     On Error GoTo 0
>                 End With

...


Mon, 23 Aug 2004 01:33:46 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. broken error trap

2. replace page breaks with section breaks

3. Line Break vs. Paragraph Break

4. Break Word with section breaks and pagesetup changes

5. Ctrl+Break in VB6 breaks in calling module!

6. stop breaking into code after error

7. Break on all Errors.

8. Find break line after runtime error?

9. Find line of break after error

10. page section breaks error ?

11. Breaks/error for statement "UserForm1.Show"

12. No break on errors in secondary projects - Confused

 

 
Powered by phpBB® Forum Software