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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifying which report is open...

Status
Not open for further replies.

mrf1xa

Technical User
Jan 14, 2002
366
GB
Hello

I want to write a function that can be called from a customised menu button on an open report, which uses 'OutputTo' to create a snapshot of the report for emailing.

I can do this for a single report with the output name hardcoded. However, how can I use this function to work with whatever report is open at the time the button is pressed? I need to know how to identify the name of the open report and I don't know how.

e.g. if report 'ITWork' is open, I want the output name to be 'ITWork.snp'

Thanks in advance. Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Hi

how about using the name property of the report?

Without knowing what you application looks like, hopefully aircode below will convey the idea:

Dim rpt As Report

Set rpt = Me

X = YourFunction(rpt)

Public Function YourFunction(rpt As Report)

If rpt.Name = .... Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks for the response Ken. Sorry to say I don't seem to be able to see the obvious here.

Here is the function I have, that works well for just the one report called 'rptOPR'. I can't seem to get my head around how to change this so that the name becomes whatever report is current at the time. I have a vague idea of what your code is doing, but not sure where to put it. Bear in mind the idea is to call this from a custom button on a menu bar visible to all reports.

Could I have another pointer please? Thanks

Code:
Function Snapshot()

Dim str As String
    
    str = "OPR" & DatePart("d", Date) & "." & DatePart("m", Date) & "." & DatePart("YYYY", Date) & ".snp"
    
    DoCmd.OutputTo acReport, "rptOPR", acFormatSNP, str, -1
        
End Function


Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Hi

OK - not quite waht I expected but..

Function Snapshot(strReport As String)

Dim str As String

str = "OPR" & DatePart("d", Date) & "." & DatePart("m", Date) & "." & DatePart("YYYY", Date) & ".snp"

DoCmd.OutputTo acReport, strReport , acFormatSNP, str, -1

End Function

and to call it Snapshot("MyReport")


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks again Ken. I don't think I'm making myself clear- my apologies.

This works up to a point- just had to slightly tweak what you gave me:

Code:
Public Function Snapshot(strReport As String)

Dim str As String
    
    str = strReport & DatePart("d", Date) & "." & DatePart("m", Date) & "." & DatePart("YYYY", Date) & ".snp"
    
    DoCmd.OutputTo acReport, strReport, acFormatSNP, str, -1
        
End Function

However, when calling it I still have to specify the name of the report e.g. Snapshot("OPR") or whatever. What I want to do, if it can be done, is to call whatever report is active at the time this menu button is pressed. It seems to me I need something like Snapshot(CurrentReport) but this doesn't exist as far as I know- it certainly doesn't work!
Is there a function which gives something like this?

Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Hi

Ah!, now I understand, but cannot really help!

If you where confident that only one report could be open at one time you could use the reports collection, which lists only open reports Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Oh well, thanks anyway Ken, atleast I'm not as daft as I thought I was! Nigel
Didn't someone say work is supposed to be fun? They didn't have computers then I guess....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top