skbhat03
07-06-2009, 05:16 AM
Dear Experts,
I have a very odd problem with error handling.
I want to have multipal error handlings inside a single module.
The problem is that the firt error is successfully read, but the next one not.
Will try to explain how my code is written.
Sub errors()
dim job_1, job_2, job_3 as boolean
job1:
On error goto errormsg1
job_1 = false
'my code'
job_1=true
job2:
on error gotto errormsg2
job_2 = false
'my code'
job_2=true
job3:
on error gotto errormsg3
job_3 = false
'my code'
job_3=true
Exit Sub
errormsg1:
if job_1 = false then
msg box "job1 didnot run"
go to job2
endif
errormsg2:
if job_2 = false then
msg box "job2 didnot run"
go to job3
endif
errormsg3:
if job_3 = false then
msg box "job3 didnot run"
go to job4
endif
End Sub
Now let us say that there is an error in job2 , system reads the code correctly and goes to errormsg2.
After reading errormsg2, it goes to job3. Now say if there is error in job3, it is not going to errormsg3, it is throwing up the debug error box.
Hope i have made my problem clear.
Thanks
Subbu.
I have a very odd problem with error handling.
I want to have multipal error handlings inside a single module.
The problem is that the firt error is successfully read, but the next one not.
Will try to explain how my code is written.
Sub errors()
dim job_1, job_2, job_3 as boolean
job1:
On error goto errormsg1
job_1 = false
'my code'
job_1=true
job2:
on error gotto errormsg2
job_2 = false
'my code'
job_2=true
job3:
on error gotto errormsg3
job_3 = false
'my code'
job_3=true
Exit Sub
errormsg1:
if job_1 = false then
msg box "job1 didnot run"
go to job2
endif
errormsg2:
if job_2 = false then
msg box "job2 didnot run"
go to job3
endif
errormsg3:
if job_3 = false then
msg box "job3 didnot run"
go to job4
endif
End Sub
Now let us say that there is an error in job2 , system reads the code correctly and goes to errormsg2.
After reading errormsg2, it goes to job3. Now say if there is error in job3, it is not going to errormsg3, it is throwing up the debug error box.
Hope i have made my problem clear.
Thanks
Subbu.