The problem is that the report is bound to a very complex Union query which can take from about 5 to 60 seconds to process depending on what options the users selects. What happens on screen is that when they click the Print button the form closes and the screen goes virtually blank while the query runs and then, after a period of time, the report appears on screen. So rather than leaving the user with a blank screen I have added another pop up form (frmPrintingReport) which shows a message to the effect that the report is being processed and to please wait. In the report's Page event I have added some code which closes the pop up message form which then disappears when the report appears on screen. This all works fine (and will do if the next bit is not possible).
However, what I would really like to do is rather than giving the user a 'static' screen display, I would like to have some sort of counter on screen which counts off the seconds as the query is processed as this would give the user an idea of the time it takes to process various options they choose.
Problem is, it doesn't work. I added a Text box control to show a number and used the form's Timer to increment the counter at 1 second intervals but it does not work (i.e. the timer does not get triggered). I also tried using the Timer API function with the same result.
What is happening (I believe) is that when the frmPrintingReport form loses the focus to the report itself, any code in the form stops executing, I confirmed this by Remming out the line of code in the report which closes the pop up form and when the report appears on screen - the counter on the form starts counting.
So the question is - is there any way to execute some VBA code in a form when it does not have the focus?
CODE
Private Sub btnPrintStats_Click()
On Error GoTo ErrorCode
DoCmd.OpenForm "frmPrintOptions", , , , , acDialog, Forms!frmMain!frmMainFilterSub!txtFilterName 'show print options
If gDummy = 0 Then Exit Sub
DoCmd.OpenForm "frmPrintingReport" 'show 'Please Wait' message
DoEvents
DoCmd.OpenReport "rptStats", acViewPreview, , , , gDummy 'preview report and pass stats mode to report
Exit Sub
ErrorCode:
If Err = 2501 Then Exit Sub
MsgBox Err.Description
End Sub
On Error GoTo ErrorCode
DoCmd.OpenForm "frmPrintOptions", , , , , acDialog, Forms!frmMain!frmMainFilterSub!txtFilterName 'show print options
If gDummy = 0 Then Exit Sub
DoCmd.OpenForm "frmPrintingReport" 'show 'Please Wait' message
DoEvents
DoCmd.OpenReport "rptStats", acViewPreview, , , , gDummy 'preview report and pass stats mode to report
Exit Sub
ErrorCode:
If Err = 2501 Then Exit Sub
MsgBox Err.Description
End Sub
I don't think it is possible to do this but maybe someone has some alternative ideas.
Peter Hibbs.