Why does it not work properly, Didier? Are you getting error messages? Other
than not having broken the message string properly, it worked fine for me.
You must let the concept of "modules" go when using VBScript. What you can
do is write a general function or subroutine that will display an error
message when an error occurs, and call this function/sub after each line in
your code where you think an error might occur. So add a function like this
to your code
Sub CheckForErrors
Dim Message
Dim Answer
If Err.number <> 0 Then
Message= "Error N° " & Err.number & " of type " & Err.Source & "
appeared: " & Chr(13) & Err.Description & " Please contact your admin."
Answer = MsgBox(Message ,48,"error was detected in your form")
End If
Err.Clear
End Sub
Remember to use proper line continuation characters (&_) when constructing
the string for the "Message". Then you can call this sub after each line in
your code like this
Dim obj
On Error Resume Next
Set obj = CreateObject("Foo")
CheckForErrors
---
S.Y.M. Wong-A-Ton
> Thx a lot SYM
>
[quoted text clipped - 48 lines]
> > >
> > > Thx a lot
Didier Maignan - Interprojet - 23 Oct 2006 12:18 GMT
Thx SYM
We tried that. Thansk la lot.
If there is an error (Foo or databse connection or whatelse ) this is OK
But in case of no error : there is an ... error on the line :
If Err.number <> 0 Then
so this procedure is not applicable for all cases , except if there IS an
error.
So this is not convenient.
Didier
> Why does it not work properly, Didier? Are you getting error messages? Other
> than not having broken the message string properly, it worked fine for me.
[quoted text clipped - 80 lines]
> > > >
> > > > Thx a lot
S.Y.M. Wong-A-Ton - 24 Oct 2006 07:01 GMT
Let me see if I understood you correctly. If you add "If Err.number <> 0
Then" etc. in your code and no error occurred, the line causes an error? If
so, what is the error message?
I tried it and it worked fine on my end. Try creating a new form (a clean
start) with a button that has only that line of code (including and End If of
course) in it and test it. The only error that I can imagine taking place is
that the "Err" object could be "Nothing", but according to me this object is
always defined.
---
S.Y.M. Wong-A-Ton
> Thx SYM
>
[quoted text clipped - 93 lines]
> > > > >
> > > > > Thx a lot