wait on report

G

Guest

I am listing some cases, and am capturing the case_id and page_number of the
report for later use as a table of contents and index. I am capturing the
case_id by using vb code on the "On Print" events of the report detail and
footer. In order to get all of the data to the table, I use some send keys
to force the report to go all the way to the end, then back home.
SendKeys "{End}"
SendKeys "{Home}"

That part is working just fine. My problem, however, is that I want the
index (a separate report) to automatically open after the case listing
finishes. If I put the doCmd... right after the SendKeys, it opens too
quickly and the first report isn't quite finished loading the table.

How can pause for a few seconds before the index opens, but still allow the
listing report to finish without becoming distracted by a dialog form or
other loss of focus?

thanks,
Rae Lynn
 
G

George Nicholson

Not 100% sure if this address your timing issue but my guess is that you can
probably use a WaitUntilOpen function similar to the following to make sure
report #1 is open before you open the 2nd one.

Public Sub WaitUntilOpen(strObjName As String, Optional lngObjType As
acObjecttype = acForm)
' Suspends code execution until specified object is open. Default
object is a Form.
On Error Resume Next
Do Until IsLoaded(strObjName, lngObjType)
DoEvents
Loop
End Sub

Public Function IsLoaded(strObjName As String, Optional lngObjType As
acObjecttype = acForm) As Boolean
' Returns True (non-zero) if strObjName is Open, False(0) if not Open or
doesn't exist.
' (subform status can't be tested this way)
' The 12 legal acObjectTypes include: acForm (default), acTable,
acQuery, acReport (see ObjectBrowser for complete list)

On Error Resume Next
IsLoaded = (SysCmd(acSysCmdGetObjectState, lngObjType, strObjName) <> 0)
End Function

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top