Stop reading the code until report is closed

Newman

Québécois
Local time
Yesterday, 21:36
Joined
Aug 26, 2002
Messages
766
I have a form that is used to create the criteria for a couple of reports at the same time. (often the same one with slight differences)
What I need is that it reads part of the code until a report is opened. Then, it should stop reading the code until the report is closed. Then, keep on reading from where it stopped until an other report is opened, then ...
Thank you!
 
Here's how I've done it with success:
Code:
'Your code executes first
  DoCmd.OpenReport "ReportName", acViewPreview
  Do While Application.CurrentObjectName = "ReportName"
    DoEvents  'Yield to other processes.
  Loop
'The rest of the code follows here
This opens the report in Preview, lets the user look at it or print it or otherwise do what they do in preview mode, then control returns to this module when they close the report.

-Curt
 
Newman,

The only way that I can think of to control that is to store the
state in a form control (knowing the form will be open) or
declare a global variable. The report can initialize it in the
OnOpen event and clear it on the OnClose event.

Unless somebody knows how to detect if a form is open.

hth,
Wayne
 
Newman,

I don't know this thing's origin, but it could be amended to
handle reports.

Public Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
Else
IsLoaded = False
End If
Else
IsLoaded = False
End If

End Function

Wayne
 
Thanks to both of you.

I'll try them later. Thanks!
Any other advices are welcome...
 

Users who are viewing this thread

Back
Top Bottom