Pausing code until a report is printed

J

JulieD

Hi All

having a bad day .. i have a form with a command button.
when the command button is pressed the following happens
1 the last date of entry is retrieved from a table
2 a report showing the information entered for this date is displayed on
screen
3 delete confirmed is asked for
4 data for the date is deleted from three tables.

All this works fine EXCEPT i need to wait until the report displayed in 2 is
printed before proceeding to 3 and i just can't figure out how to do it. The
report is also used in two other situations within the db so i can't do it
against the Report_Close event.

any ideas?

Cheers
JulieD
 
A

Allen Browne

Hi Julie

Access 2002 and 2003 support opening the report in Dialog mode. This pauses
the code until the report is closed, just like opening a form in dialog
mode. So if you are working with these versions:
DoCmd.OpenReport "MyReport", acViewPreview, , , acDialog
Debug.Print "This doesn't fire until the report is closed."

If earlier versions, I'm not clear about the problem with Report_Close.
Could the code that needs to be run after the report closes be separated
into another routine that is called from Report_Close? Could you pass an
argument to the report in OpenArgs for the case where you need the code to
trigger in Report_Close, and then test the value of OpenArgs and run the
code only if the value was passed in?

If not, could you set some public boolean value in Report_Close, and have
your main code just loop until the boolean is true (with DoEvents in the
loop)?

HTH
 
J

JulieD

Hi Allen

(hope all is well)

thanks for this - i am using ver 2000 ... so i will need to look at the
report_close option (specifically passing a value). The main reason that i
was trying to avoid this method is that this functionality is only temporary
and i didn't want it split up all over the place.

Cheers
JulieD
 
Top