-
1
- #1
psemianonymous
Programmer
I found this extremely useful piece of VBA code. It will loop until the report closes--this means that you can run some code, open the report, wait until the report is closed, and then continue with the code. This was useful for me as I confirm using a messagebox that the report prints correctly. Anyway, there's just three steps:
1. Open your report in preview mode.
2. Select your report (set the focus to your report). This step is optional, though it is usually implied.
3. Run a "DoEvents Loop" until the report disappears. If you don't put "DoEvents" inside the loop, your program will totally freeze.
Here is how I used it:
(found it here: --
Find common answers using Google Groups:
1. Open your report in preview mode.
2. Select your report (set the focus to your report). This step is optional, though it is usually implied.
3. Run a "DoEvents Loop" until the report disappears. If you don't put "DoEvents" inside the loop, your program will totally freeze.
Here is how I used it:
Code:
If rptFilter = "" Then
DoCmd.OpenReport "rptDUNNING_LETTER_RFI", acViewPreview
Else
DoCmd.OpenReport "rptDUNNING_LETTER_RFI", acViewPreview, , rptFilter
End If
DoCmd.SelectObject acReport, "rptDUNNING_LETTER_RFI"
Do While SysCmd(acSysCmdGetObjectState, acReport, "rptDUNNING_LETTER_RFI") = 1
DoEvents
Loop
'In a different function I run the message box. Not
'in this one.
(found it here: --
Find common answers using Google Groups: