error handling

S

sheetal

My macro runs 8 reports and exports them to excel. this is don
everyday. The reports contain daily numbers.

My problem is, when there are no numbers in one of the reports, I ge
an error message, and then taken to the "halt" macro window, and th
whole macro has collapsed.

What code do I put into my macro to stop it collapsing, and to continu
to run even when there are no numbers in any of my reports?

Please help

Thanks

Sheeta
 
?

___

Here'e an example of how to clear any errors.

Code
-------------------

Private Sub YourButton_Click()
On Error GoTo Err_YourButton_Click

Run Your Converted Macro Here

Exit_YourButton_Click:
Exit Sub

Err_YourButton_Click:
Err.Clear
Resume Exit_YourButton_Click

End Sub
 
S

sheetal

Hey, thanks for that code, how do I go into a VB window in Access, so
can test this out? let me know - Thank
 
?

___

The first thing you need to do is convert your macro. Highlight th
macro you want to convert, goto Tools >> Covert macro to visual Basi
and deselect "Add error handling" and "Include Macro Comments". Onc
it's complete goto the module tab and double click the converted macro
The code in the middle (between "Function Macro1()" and "End Function
is the code you need to place instead of the line "Run Your Converte
Macro Here" in my code). To get to the VB editor, open your form i
design view, right click your button that runs the macro and got
properties. Scroll down and select 'OnClick' and change the dropdow
from the name of tour macro to 'EventProcedure'. Now click the "...
button next to the dropdown. This is where you need to place my cod
and the converted macro code, leaving the first line, "Private Su
YourButton_Click()" and the last line "End Sub" as it is in the editor
Exit and save.
Post back if you need more help.
HT
 

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