|
-
Jun 24th, 2006, 06:15 AM
#1
Thread Starter
Frenzied Member
on error
VB Code:
Private Sub Form_Load()
On Error GoTo ErrorHandler
code here
code here
call function1
call function2
ErrorHandler:
MsgBox ErrorPrefix & "Error id: " & err & ", " & Error, vbCritical, version & " - error!"
end sub
function1 and function2 have error handling like that too
but whe i start my form up, it keeps msgboxing but the errorid and message are blank
-
Jun 24th, 2006, 06:27 AM
#2
-
Jun 24th, 2006, 06:30 AM
#3
Re: on error
Its cos you are missing the EXIT SUB..
do it like this:
Private Sub Form_Load()
On Error GoTo ErrorHandler
code here
code here
call function1
call function2
Exit Sub
ErrorHandler:
MsgBox ErrorPrefix & "Error id: " & err & ", " & Error, vbCritical, version & " - error!"
end sub
-
Jun 24th, 2006, 06:30 AM
#4
Re: on error
Put Exit Sub before the ErrorHandler. You see a blank Errnumber and description because there is no error, however you are still executing this statement
VB Code:
MsgBox ErrorPrefix & "Error id: " & err & ", " & Error, vbCritical, version & " - error!"
Your code should be like this
VB Code:
Private Sub Form_Load()
On Error GoTo ErrorHandler
code here
code here
call function1
call function2
'Make sure we don't execute the error handling code if there is no error
Exit Sub
ErrorHandler:
MsgBox ErrorPrefix & "Error id: " & err & ", " & Error, vbCritical, version & " - error!"
end sub
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jun 24th, 2006, 08:16 AM
#5
Thread Starter
Frenzied Member
Re: on error
ahh yeaa thanks, thats sorted it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|