Resume Next doesn't trap error 
Author Message
 Resume Next doesn't trap error

I have just installed Office 2000 Service Pack 2 and have found that
On Error Resume Next no longer traps errors. The code below
illustrates the problem. I am using code which deliberately generates
an error code to test whether an object is a form control or a form.
This code has worked on Access 97 and Access 2000 inc SR1 but since
installing O2K SP2 I now get an untrapped runtime error 2465 if the
object is a Form. Has anyone else encountered this behaviour and
anyone any idea what I need to do to fix it? I've tried all the usual
decompiling etc but the problem seems to be machine specific rather
than dB specific. I appreciate that I can rewrite this function to
avoid deliberately generating an error, but I'm more concerned about
the fact that "On Error Resume Next" seems to have become broken on my
PC.

Public Function fIsControl(obj As Object) As Boolean
  ' Comments     : determines if the passed object is a control
  ' Parameters   :
  ' Returns      : True if object is a control, false otherwise
  '
  Const ErrInvalidFieldName As Integer = 2465
  Dim varTemp As Variant

  On Error Resume Next

  ' This line will trigger error 2465 (Invalid Field Name)
  ' if the object is a form rather than a control
  varTemp = obj.ControlType

  fIsControl = (Err <> ErrInvalidFieldName)

  On Error GoTo 0

End Function

Ian Thomson



Mon, 14 Jul 2003 20:21:18 GMT  
 Resume Next doesn't trap error
Try removing "Next"!


Quote:
> I have just installed Office 2000 Service Pack 2 and have found that
> On Error Resume Next no longer traps errors. The code below
> illustrates the problem. I am using code which deliberately generates
> an error code to test whether an object is a form control or a form.
> This code has worked on Access 97 and Access 2000 inc SR1 but since
> installing O2K SP2 I now get an untrapped runtime error 2465 if the
> object is a Form. Has anyone else encountered this behaviour and
> anyone any idea what I need to do to fix it? I've tried all the usual
> decompiling etc but the problem seems to be machine specific rather
> than dB specific. I appreciate that I can rewrite this function to
> avoid deliberately generating an error, but I'm more concerned about
> the fact that "On Error Resume Next" seems to have become broken on my
> PC.

> Public Function fIsControl(obj As Object) As Boolean
>   ' Comments     : determines if the passed object is a control
>   ' Parameters   :
>   ' Returns      : True if object is a control, false otherwise
>   '
>   Const ErrInvalidFieldName As Integer = 2465
>   Dim varTemp As Variant

>   On Error Resume Next

>   ' This line will trigger error 2465 (Invalid Field Name)
>   ' if the object is a form rather than a control
>   varTemp = obj.ControlType

>   fIsControl = (Err <> ErrInvalidFieldName)

>   On Error GoTo 0

> End Function

> Ian Thomson



Tue, 15 Jul 2003 17:00:49 GMT  
 Resume Next doesn't trap error
Thanks for the suggestion. It turned out that somehow my VBA config
had changed to "Break on All Errors" rather than "Break on Unhandled
Errors". Setting it to break on Unhandled Errors solved the problem.

Ian



Quote:
>Try removing "Next"!



>> I have just installed Office 2000 Service Pack 2 and have found that
>> On Error Resume Next no longer traps errors. The code below
>> illustrates the problem. I am using code which deliberately generates
>> an error code to test whether an object is a form control or a form.
>> This code has worked on Access 97 and Access 2000 inc SR1 but since
>> installing O2K SP2 I now get an untrapped runtime error 2465 if the
>> object is a Form. Has anyone else encountered this behaviour and
>> anyone any idea what I need to do to fix it? I've tried all the usual
>> decompiling etc but the problem seems to be machine specific rather
>> than dB specific. I appreciate that I can rewrite this function to
>> avoid deliberately generating an error, but I'm more concerned about
>> the fact that "On Error Resume Next" seems to have become broken on my
>> PC.

>> Public Function fIsControl(obj As Object) As Boolean
>>   ' Comments     : determines if the passed object is a control
>>   ' Parameters   :
>>   ' Returns      : True if object is a control, false otherwise
>>   '
>>   Const ErrInvalidFieldName As Integer = 2465
>>   Dim varTemp As Variant

>>   On Error Resume Next

>>   ' This line will trigger error 2465 (Invalid Field Name)
>>   ' if the object is a form rather than a control
>>   varTemp = obj.ControlType

>>   fIsControl = (Err <> ErrInvalidFieldName)

>>   On Error GoTo 0

>> End Function

>> Ian Thomson



Wed, 16 Jul 2003 06:42:51 GMT  
 Resume Next doesn't trap error
Ian,  glad it happened to someone else, too. Your misfortune has saved
me many hours of hair tearing. :-)  Out of interest, do you use VBA for
any other apps eg Excel.  I think I ended up in this position because
I'm debugging Excel and Access simultaneously.

Chris


Quote:

> Thanks for the suggestion. It turned out that somehow my VBA config
> had changed to "Break on All Errors" rather than "Break on Unhandled
> Errors". Setting it to break on Unhandled Errors solved the problem.

> Ian



> >Try removing "Next"!



> >> I have just installed Office 2000 Service Pack 2 and have found
that
> >> On Error Resume Next no longer traps errors. The code below
> >> illustrates the problem. I am using code which deliberately
generates
> >> an error code to test whether an object is a form control or a
form.
> >> This code has worked on Access 97 and Access 2000 inc SR1 but since
> >> installing O2K SP2 I now get an untrapped runtime error 2465 if the
> >> object is a Form. Has anyone else encountered this behaviour and
> >> anyone any idea what I need to do to fix it? I've tried all the
usual
> >> decompiling etc but the problem seems to be machine specific rather
> >> than dB specific. I appreciate that I can rewrite this function to
> >> avoid deliberately generating an error, but I'm more concerned
about
> >> the fact that "On Error Resume Next" seems to have become broken
on my
> >> PC.

> >> Public Function fIsControl(obj As Object) As Boolean
> >>   ' Comments     : determines if the passed object is a control
> >>   ' Parameters   :
> >>   ' Returns      : True if object is a control, false otherwise
> >>   '
> >>   Const ErrInvalidFieldName As Integer = 2465
> >>   Dim varTemp As Variant

> >>   On Error Resume Next

> >>   ' This line will trigger error 2465 (Invalid Field Name)
> >>   ' if the object is a form rather than a control
> >>   varTemp = obj.ControlType

> >>   fIsControl = (Err <> ErrInvalidFieldName)

> >>   On Error GoTo 0

> >> End Function

> >> Ian Thomson

Sent via Deja.com
http://www.deja.com/


Sun, 27 Jul 2003 21:32:04 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Resume Next doesn't work in Access 2.0 application

2. On local error resume next Vs on error resuem next

3. onerror trap doesn't trap error!

4. What's with On Error Resume Next???

5. On Error Don't Resume Next

6. On Error Resume Next - I still don't get it :(

7. On Error Resume Next Won't

8. ADO duplicate trap/resume next

9. On Error doesn't trap error!

10. On Error Resume Next (but Only with Specific Error, like Err.Number = 70)

11. cmd.Errors.Count Not Working (On Error Resume Next)

12. Runtime error(3012): On error resume next

 

 
Powered by phpBB® Forum Software