In the code that calls the report, you can delete the table after the
report closes.
Your code will need to check to see if the report is loaded and loop
until the report is closed.
In the simplest form that could look like
DoCmd.OpenReport "NameOfReport"
WHILE CurrentProject.AllReports("NameOfReport").IsLoaded
DoEvents 'Need this so other processing will execute
WEND
You could make that more efficient by introducing a delay into the loop.
You might use the Sleep API (code below)
WHILE CurrentProject.AllReports("NameOfReport").IsLoaded
DoEvents 'Need this so other processing will execute
Call sSleep(2000) '2 second delay
WEND
Make code go to Sleep
Author: Dev Ashish
More than a few people have asked me if an alternative to DoEvents
exists to implement a wait period in Access. (DoEvents yields execution
so that the operating system can process other events.)
The answer is yes, the Sleep API can be used for this. Look at the
sample sTestSleep Sub. When you run it, you'll notice a delay beforethe
Msgbox appears on screen. The duration can be increased/decreased
bychanging the constant cTime to a corressponding higher/lower value.
For normal use from within your code, simply place a call to the
sSleep sub with an appropriate time in milliseconds
'***************** Code Start *******************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Sub sapiSleep Lib "kernel32" _
Alias "Sleep" _
(ByVal dwMilliseconds As Long)
Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End Sub
Sub sTestSleep()
Const cTIME = 1000 'in MilliSeconds
Call sSleep(cTIME)
MsgBox "Before this Msgbox, I was asleep for " _
& cTIME & " Milliseconds."
End Sub
'***************** Code End *********************