Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect if a report is open (or not) 1

Status
Not open for further replies.

ChrisTheAncient

Technical User
Dec 22, 2002
169
GB

I'm working on a derivative on NWinds using Access XP.

There is a utilities module to detect if a form is open (or not!) prior to opening that form...

Code:
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
        End If
    End If
    
End Function

The help system - and my brain - is not being a lot of help in my next step!

I want to run the other way round with something I'm trying to do, and use a function to detect if a report is open (in either print preview or design mode).

Can the above function be modified to check if a report is open?

TIA

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
Why not just browse the Reports collection ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 

Hi PH

Sounds like that is a potential idea.

Trouble is, I've never done that (my skills are quite limited).

How would I do this please?

And to add insult to injury, I'm on UK time and off to bed now!

Will check back in the morning before I head off to work.

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
Something like this:
sReport="myReport"
bFound = False
For Each rpt In Reports
If rpt.Name = sReport Then
bFound = True
Exit For
End If
Next rpt
If bFound Then MsgBox sReport & " is open"

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 

PH

Thanks - got that this morning.

Will have to wait until later in the day to try it though! I've got to go and do the work that allows me the space to do the computer bits that I enjoy.

Chris


*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
PH

At last, managed to get to computer and have a go!

That way of doing it has worked fine and is now the building block I so desperately needed to get the flipping thing under way again. I can get back to my developing (when I find a 28 hour working day!).

Many, many thanks. I'm truly grateful.

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
Chris

It's quite easy to modify that code to check for an open report, just change it to:

If SysCmd(acSysCmdGetObjectState, acReport, strFormName) <> conObjStateClosed Then

OK so the strFormname parameter is now misleading because it refers to a report rather than a form, but you could easily change that to "strReport" throughout the function if necessary.

John
 
Hi John

Thanks for even more thoughts there.

I can't get to look at it for a day or two because of so much on my plate - but I shall certainly have a look. I'd like to see that method works as well.

Many thanks

Chris

*************************************
OK, I'm stoopid. But I'm good at it!
*************************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top