check if report is opened

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can i check if a report is opened? I use visible property , if it is
opened it returns -1, but if it is closed it returns #Name? and i can't use
IIf function.
 
There are several ways to do this. If you need to do this more than one
time or for more than one report, try adding a module with code similar to
the following:

Public Function repIsLoaded(ByVal strReportName As String) As Boolean
'Returns true if the specified form is open in either form or datasheet
view

Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllReports(strReportName)

If oAccessObject.isLoaded Then
repIsLoaded = True
End If
End Function

Then, to see if a given report is open, use the following syntax:

If repIsLoaded("REPORT_NAME") = True Then
.......
End if

If you only need to check once if a report is open, modify the code to fit
as needed (use the .IsLoaded property of an AccessObject)

HTH
 
If SysCmd(acSysCmdGetObjectState, acReport, "NameOfReport) >
0 Then
MsgBox :report is already open"
Else
DoCmd.OpenReport . . .
End If

Chris
 
Sorry proper syntax is:
If SysCmd(acSysCmdGetObjectState, acReport, "NameOfReport")
MsgBox ("This report is already open")
Else
DoCmd.OpenReport . . .
End If

Chris
 
Back
Top