How to "hold" execution

J

John

Hi

I have this code as below that first runs a report and then an update query
to set a flag so these records are not included in the report next time.

Private Sub Command2_Click()
DoCmd.OpenReport "MyReport", acViewPreview
DoCmd.OpenQuery "MyQuery"
End Sub

The problem is that as the report comes up the code execution continues and
the query is also run to set the flags. The result is that the report is
unable to show all the records as flags of some records are already set by
the query while report is being loaded. How can I "halt" the execution at
report stage and only allow the query to run when user has closed the
report?

Thanks

Regards
 
O

Ofer

"The other option is to open the report with dialog

Private Sub Command2_Click()
DoCmd.OpenReport "MyReport", acViewPreview, , , acDialog
DoCmd.OpenQuery "MyQuery"
End Sub
 
Top