Stopping a Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

To print the same report several times with different criteria each time, I
set up a form with 16 textboxes and then set a macro to run the report with
two text boxes something like color = forms!formname!field. Two text boxes
for each time it is run. So 16 text boxes make 8 reports. This works fine. 4
to 12 of the have to be printed at a time. If there are less than 8 times it
needs to be done is there a way to stop the macro. Right now it will go
through the process of trying to print it, and making it to the no data
section and give the message box that was created for that. Is there a way to
skip empty boxes or stop completely on an empty box.
 
I decided to go about it the hard way,
IsNull([Forms]![frmprnt]![txt0]) action msgbox
IsNull([Forms]![frmprnt]![txt0]) action stopmacro
IsNull([Forms]![frmprnt]![txt8]) action msgbox
IsNull([Forms]![frmprnt]![txt8]) action stopmacro
for each of the 8 times that the report would print changing the txt number
to match the text box it is representing
 
Harley,

It may save a few complexities in the macro to do something similar, but
just check for an entry in the textbox (by the way, I don't think it is
necessary to fully reference the form if the macro is being called from
an event on the frmprnt form) before the report tries to print, e.g.
[txt0] Is Not Null action OpenReport
[txt8] Is Not Null action OpenReport
 
Back
Top