I've got a command button on a form that is supposed to open a report.
Private sub cmdReport_Click
DoCmd.CopyObject , "rpt_Temp", acReport, "rpt_dates"
'run some code here that adds controls to the temp report based on the value of some controls in the form
DoCmd.OpenReport "rpt_Temp", acViewPreview, , , acDialog
then docmd.close acreport, "rpt_Temp"
DoCmd.DeleteObject acReport, "rpt_Temp"
But there is some code in that buttons Click that I don't want to fire until the report is closed, which will delete the report. I was under the impression that using acDialog window mode would halt execution of the command buttons Click event code until the report was closed, as it does with a form, but that is not happening. Instead, as soon as the report is open, the code continues to run, closing it and deleting the object.
As a workaround, I've removed the line of code that checks to see whether it is open, and if so, close it, and replaced that with the following.
: DoEvents: Wend
However, this is extremely CPU intensive (100%), and I would prefer to figure out why the code is not pausing as it does when a form is opened with acDialog. I know I could move the code that deletes the temporary report from the button click event to the form_Close event, but again, would like to know whether this is a bug, or is a "feature".