Rats!

M

MikeB

Oh man,
I've been working for hours on this and I never hit save.

So I wrote something that put the program in a loop and when I ran it
that was it, I had to kill the entire Access window.

Lost everything. :(

I couldn't find a way to interrupt a program that was in a tights
loop running in Debug mode. Did I miss something?

My problem came with error handling.

I had (more or less) the following code:

Sub SubFunc()
on Error GoTo ErrorHandler
for each pty in Object
do stuff
next pty
ErrorHandler:
print error mesage
Resume <=====


that Resume was the killer.
I tried Resume Next but got an error.

How should I have coded it to handle the error and skip on to the next
element in the Object collection?

Thanks.
 
D

Dirk Goldgar

MikeB said:
Oh man,
I've been working for hours on this and I never hit save.

So I wrote something that put the program in a loop and when I ran it
that was it, I had to kill the entire Access window.

Lost everything. :(

I couldn't find a way to interrupt a program that was in a tights
loop running in Debug mode. Did I miss something?

My problem came with error handling.

I had (more or less) the following code:

Sub SubFunc()
on Error GoTo ErrorHandler
for each pty in Object
do stuff
next pty
ErrorHandler:
print error mesage
Resume <=====


that Resume was the killer.
I tried Resume Next but got an error.

How should I have coded it to handle the error and skip on to the next
element in the Object collection?


Ctrl+Break usually breaks into code.

If you want your loop to resume at the next iteration of the loop, you need
to label the statement you want to resume at, and name that label when you
Resume. Like this:

Sub SubFunc()

On Error GoTo ErrorHandler

For Each pty In Object
' do stuff
Next_Loop:
Next pty

Exit Sub

ErrorHandler:
' print error mesage
Resume Next_Loop

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top