Access 2010 Suspend Form Event Until Report Is Closed

Hi Folks,
The attached code extracts data to a Table (STEP_100) , displays a Report in preview based on the data in the Table (STEP_200) and then deletes the data in the Table (STEP_800).

When the Report displays in preview and the code continues and deleties the data in the Table before all of the data can be displayed correctly in the Report.

How can I suspend the code running after the Report is displayed in preview (end of STEP_200) until the Report is closed and then resume the processing to delete the data in the Table (STEP_800)?

Thanks.
Bob C.
Run-R-40-060---Event-Venue-Area-Info-Rep
Bob CollisonSystem ArchitectAsked:
Who is Participating?
 
Gustav BrockCIOCommented:
There are methods to let the application "sleep until .." but the simplest method would be to move the call of the clean-up function to the OnClose event of the report.

/gustav
0
 
hnasrCommented:
/gustav's idea is fine, but may stop you from reusing report in another context.
0
 
Gustav BrockCIOCommented:
Here is full code for a "suspension" function for a form: OpenFormDialog. Browse to paragraph Simulating dialogue mode

http://www.experts-exchange.com/Database/MS_Access/A_17684-Modern-Metro-style-message-box-and-input-box-for-Microsoft-Access-2013.html

Replace the CurrentProject.AllForms with CurrentProject.AllReports and you have a OpenReportDialog function.

You may even use the time-out function to wait for, say, five seconds if that is enough for your report to settle.

/gustav
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
hnasrCommented:
One way: Try modifying one line in your code, DoCmd.OpenReport stDocName_R49060, acPreview

DoCmd.OpenReport stDocName_R49060, acViewPreview, , , acDialog

Open in new window

0
 
Bob CollisonSystem ArchitectAuthor Commented:
Hi Experts,

Thanks for all of your suggestions.
- The Timer Solutions are not desirable for this situation.
- The acDialog Solution works except that the previewed report cannot be resized which is not desirable.

The best solution for this situation is to move the emptying of the table to the Form Close Event because:
- The Called Load procedure empties the Table before loading it.
- Each record that is loaded contains three fields that ensure that the record relates to only one Unique User (logon User), Object (specific Report) and Process (Form running the report).

Thanks.
Bob C.
0
 
Dale FyeCommented:
I use the method described by hnasr.

The acDialog value used in the WindowMode argument will prevent code that follows that line from running until the report is closed.  Works the same way.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.