Err.Raise causes Error 
Author Message
 Err.Raise causes Error

I am trying to throw an error when the user clicks the
cancel button on a progress bar but I get an "Automation
Error" everytinte.  I have tried defining the error number
as a constant of vbObjectError+1002 and I have tried using
the number as in the following;

    If frmProressBar.Canceled then Err.Raise
vbOpjectError+1002
    End If

I have also tried this;

If frmProressBar.Canceled then Err.Raise
Number:=vbOpjectError+1002
    End If

Thanks for looking at this,

Scott



Sat, 02 Jul 2005 23:13:45 GMT  
 Err.Raise causes Error

Scott,
Of course Err.Raise is suppose to cause an error! ;-)

But I suspect you are referring to the syntax error, based on your example.

    If frmProressBar.Canceled Then
        Err.Raise vbObjectError+1002
    End If

You had Err.Raise on the same line as the Then, which is fine if you do not
include the End If. Also you had vbObjectError mistyped...

NOTE: Any error that is not predefined is an 'Automation Error', if you want
another message, use the message parameter of Err.Raise

        Err.Raise vbObjectError+1002, "Error Source", "Scott Stewart's Error
Message"

Hope this helps
Jay


Quote:
> I am trying to throw an error when the user clicks the
> cancel button on a progress bar but I get an "Automation
> Error" everytinte.  I have tried defining the error number
> as a constant of vbObjectError+1002 and I have tried using
> the number as in the following;

>     If frmProressBar.Canceled then Err.Raise
> vbOpjectError+1002
>     End If

> I have also tried this;

> If frmProressBar.Canceled then Err.Raise
> Number:=vbOpjectError+1002
>     End If

> Thanks for looking at this,

> Scott



Sun, 03 Jul 2005 11:31:29 GMT  
 Err.Raise causes Error
Thanks for your reply Jay,

Operator_Canceled = vbObjectError + 1002
On Error GoTo MsgClassError
If frmProgressBar.Canceled Then Err.Raise
Number:=Operator_Canceled

This generates the error "Invalid procedure call or
argument".  

And so does this: Err.Raise Operator_Canceled

And so does this: Err.Raise 278

MS reference and the VB help have this as the syntax

Err.Raise 6    ' Generate an "Overflow" error.

I checked the spelling of vbObjectError and used paste to
set Operator_Canceled so that wouldn't be a problem.

I should be getting to this handler.

MsgClassError:
         Select Case Err.Number
          Case Is = Operator_Canceled
                MsgBox "You have canceled the process."
                frmProgressBar.Hide
                Exit Sub
            Case Else
                ErrorTrap = MsgBox("Unhandled Error In " &
Err.Source & vbCrLf _
                    & " Error " & Err.Number & vbCrLf _
                    & Err.Description, vbCritical +
vbOKCancel, "Error Trap")
                If ErrorTrap = vbCancel Then Err.Clear
        End Select
    On Error GoTo 0
End Sub



Sun, 03 Jul 2005 23:25:28 GMT  
 Err.Raise causes Error
Scott,
Which version of Outlook?

I'm on Outlook XP running on Windows XP, I'm not seeing a real problem
here...

How is Operator_Canceled defined, it should be a Long.

What line are you receiving the "Invalid procedure call or argument" on.
Specifically?

This works in the VBIDE within Outlook XP:

Sub Test()
    Dim Operator_Canceled As Long
    Operator_Canceled = vbObjectError + 1002
    On Error GoTo MsgClassError
    If Operator_Canceled Then
        Err.Raise Number:=Operator_Canceled, Description:="Scott's Error"
    End If
    Exit Sub

MsgClassError:
    MsgBox Err.Number & " : " & Err.Description
End Sub


Quote:
> Thanks for your reply Jay,

> Operator_Canceled = vbObjectError + 1002
> On Error GoTo MsgClassError
> If frmProgressBar.Canceled Then Err.Raise
> Number:=Operator_Canceled

> This generates the error "Invalid procedure call or
> argument".

> And so does this: Err.Raise Operator_Canceled

> And so does this: Err.Raise 278

> MS reference and the VB help have this as the syntax

> Err.Raise 6    ' Generate an "Overflow" error.

> I checked the spelling of vbObjectError and used paste to
> set Operator_Canceled so that wouldn't be a problem.

> I should be getting to this handler.

> MsgClassError:
>          Select Case Err.Number
>           Case Is = Operator_Canceled
>                 MsgBox "You have canceled the process."
>                 frmProgressBar.Hide
>                 Exit Sub
>             Case Else
>                 ErrorTrap = MsgBox("Unhandled Error In " &
> Err.Source & vbCrLf _
>                     & " Error " & Err.Number & vbCrLf _
>                     & Err.Description, vbCritical +
> vbOKCancel, "Error Trap")
>                 If ErrorTrap = vbCancel Then Err.Clear
>         End Select
>     On Error GoTo 0
> End Sub



Mon, 04 Jul 2005 08:19:48 GMT  
 Err.Raise causes Error
Hi Jay

Outlook 2000 SR-1 Version 9.0.0.5414
Windows 98

In the Declarations Section -

Const Operator_Canceled = vbObjectError + 1002

I had this in one line without the end if and broke it
down to make sure everything was clean.

If frmProgressBar.Canceled Then
-----> Err.Raise Number:=Operator_Canceled <------- This
is the line
End If

Hope you can shed some light on this.

Scott

Quote:
>-----Original Message-----
>Scott,
>Which version of Outlook?

>I'm on Outlook XP running on Windows XP, I'm not seeing a
real problem
>here...

>How is Operator_Canceled defined, it should be a Long.

>What line are you receiving the "Invalid procedure call
or argument" on.
>Specifically?

>This works in the VBIDE within Outlook XP:

>Sub Test()
>    Dim Operator_Canceled As Long
>    Operator_Canceled = vbObjectError + 1002
>    On Error GoTo MsgClassError
>    If Operator_Canceled Then
>        Err.Raise Number:=Operator_Canceled,

Description:="Scott's Error"

- Show quoted text -

Quote:
>    End If
>    Exit Sub

>MsgClassError:
>    MsgBox Err.Number & " : " & Err.Description
>End Sub



>> Thanks for your reply Jay,

>> Operator_Canceled = vbObjectError + 1002
>> On Error GoTo MsgClassError
>> If frmProgressBar.Canceled Then Err.Raise
>> Number:=Operator_Canceled

>> This generates the error "Invalid procedure call or
>> argument".

>> And so does this: Err.Raise Operator_Canceled

>> And so does this: Err.Raise 278

>> MS reference and the VB help have this as the syntax

>> Err.Raise 6    ' Generate an "Overflow" error.

>> I checked the spelling of vbObjectError and used paste
to
>> set Operator_Canceled so that wouldn't be a problem.

>> I should be getting to this handler.

>> MsgClassError:
>>          Select Case Err.Number
>>           Case Is = Operator_Canceled
>>                 MsgBox "You have canceled the process."
>>                 frmProgressBar.Hide
>>                 Exit Sub
>>             Case Else
>>                 ErrorTrap = MsgBox("Unhandled Error
In " &
>> Err.Source & vbCrLf _
>>                     & " Error " & Err.Number & vbCrLf _
>>                     & Err.Description, vbCritical +
>> vbOKCancel, "Error Trap")
>>                 If ErrorTrap = vbCancel Then Err.Clear
>>         End Select
>>     On Error GoTo 0
>> End Sub

>.



Mon, 04 Jul 2005 21:17:37 GMT  
 Err.Raise causes Error
Scott,
I'm really not sure what to offer here.

I tried your sample in Outlook 2000, and it worked fine.

It works in Outlook XP fine also.

I suspect there is something else going on here, but I do not know what that
would be.

Remember that you should give both the description and number when you use
the Err.Raise method.

Good Luck!

Hope this helps
Jay


Quote:
> Hi Jay

> Outlook 2000 SR-1 Version 9.0.0.5414
> Windows 98

> In the Declarations Section -

> Const Operator_Canceled = vbObjectError + 1002

> I had this in one line without the end if and broke it
> down to make sure everything was clean.

> If frmProgressBar.Canceled Then
> -----> Err.Raise Number:=Operator_Canceled <------- This
> is the line
> End If

> Hope you can shed some light on this.

> Scott

> >-----Original Message-----
> >Scott,
> >Which version of Outlook?

> >I'm on Outlook XP running on Windows XP, I'm not seeing a
> real problem
> >here...

> >How is Operator_Canceled defined, it should be a Long.

> >What line are you receiving the "Invalid procedure call
> or argument" on.
> >Specifically?

> >This works in the VBIDE within Outlook XP:

> >Sub Test()
> >    Dim Operator_Canceled As Long
> >    Operator_Canceled = vbObjectError + 1002
> >    On Error GoTo MsgClassError
> >    If Operator_Canceled Then
> >        Err.Raise Number:=Operator_Canceled,
> Description:="Scott's Error"
> >    End If
> >    Exit Sub

> >MsgClassError:
> >    MsgBox Err.Number & " : " & Err.Description
> >End Sub



> >> Thanks for your reply Jay,

> >> Operator_Canceled = vbObjectError + 1002
> >> On Error GoTo MsgClassError
> >> If frmProgressBar.Canceled Then Err.Raise
> >> Number:=Operator_Canceled

> >> This generates the error "Invalid procedure call or
> >> argument".

> >> And so does this: Err.Raise Operator_Canceled

> >> And so does this: Err.Raise 278

> >> MS reference and the VB help have this as the syntax

> >> Err.Raise 6    ' Generate an "Overflow" error.

> >> I checked the spelling of vbObjectError and used paste
> to
> >> set Operator_Canceled so that wouldn't be a problem.

> >> I should be getting to this handler.

> >> MsgClassError:
> >>          Select Case Err.Number
> >>           Case Is = Operator_Canceled
> >>                 MsgBox "You have canceled the process."
> >>                 frmProgressBar.Hide
> >>                 Exit Sub
> >>             Case Else
> >>                 ErrorTrap = MsgBox("Unhandled Error
> In " &
> >> Err.Source & vbCrLf _
> >>                     & " Error " & Err.Number & vbCrLf _
> >>                     & Err.Description, vbCritical +
> >> vbOKCancel, "Error Trap")
> >>                 If ErrorTrap = vbCancel Then Err.Clear
> >>         End Select
> >>     On Error GoTo 0
> >> End Sub

> >.



Fri, 08 Jul 2005 04:27:48 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Err.Raise Causes Automation Error

2. Err.Raise causing automation errors in COM+ application

3. err.raise in Class_initialize cause an error

4. err.raise in COM components causing Error 438 in client

5. Err.Raise in OLE Server EXE not raising error in calling program

6. Err.Raise - error not being re-raised all the way to top of the call stack

7. Err.Raise : Automation Error

8. Automation Err 440 when raising error in Class_Initialize

9. Automation Err 440 when raising error in Class_Initialize

10. using err.raise method, as to generate app error

11. Automation Err 440 when raising error in Class_Initialize

12. On Error / Err.Raise

 

 
Powered by phpBB® Forum Software