Send Instantiated Report

E

Edgar

Hello Everybody, Please any help on This:
I have a base report which I reuse for different type of information, I just
instanciate it and reformat some fields as required. And when i try to send
it by mail, on snp format, Access attaches the base (original) report. It's a
problem cause the base report has for example 8 pages, and the instantiated
report that i get on screen has 2 o 3, pages. Which is what i want and need.
This is how it goes:

Public MyReport as report
sub Routine()
set MyReport = Report_Base
MyReport.controlsource = "Data1"
' some criteria is define to open the report, which shortens it
docmd.open acreport, MyReport.name, "criteria"
end sub

' Now a string to send it with another routine
DoCmd.SendObject acReport, "", "SnapshotFormat(*.snp)", "", "", "",
MyReport.Name, TheMessage, True, ""

***after this, access loads the base report on Outlook. Of course it does,
cause MyReport.name is "Base", which is the name for Report_Base. The
question is how can i order access to load just the new report, i mean the
instanciated one, or the result that i get on screen and not the base
report?. I can't change the name for the instanciated report and get it from
random memory or something like that.

Please any recomendation would be very appreciated
 
A

Allen Browne

Access does not handle multiple instances of a report well at all. They
interfere with each other. Unless you are using Access 2007, you face silly
errors. For example:
Me.Filter = "SomeField = True"
will actually be applied to the wrong instance of the report, and:
Debug.Print Me.FilterOn
will not reliably report information about whether a filter is applied.
Since the whole point of opening multiple instances is to be able to view
and filter data differently, it's just plain broken.

So, I suggest you might consider a different approach. Could you move the
code you have into Report_Open? You may need a public string variable to
pass the filter (or you might use OpenArgs in the more recent versions.)
However you do it, if there are no other instances open, and you perform
whatever manipulations you need in Report_Open, you get the desired result.

The important thing is that, when you perform the SendObject, Access opens
the report and its Report_Open event fires. No other instance is open, and
so it gets processed correctly, in exactly the same way it would have been
processed had you use OpenReport.
 
H

heidii

The important thing is that, when you perform theSendObject, Access opens
thereportand its Report_Open event fires. No other instance is open, and
so it gets processed correctly, in exactly the same way it would have been
processed had you use OpenReport.

I am having a problem with changing the caption on my reports onopen
event.

I have a continous form with a command button at the end of each
record.

Here is the code on my button:

Me.EMAILREC = True 'check emailed box to that it can't be queried
again on form
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.SendObject acReport, "RPT-RECOMMENDATIONS-EMAIL-MAIN1",
"SnapshotFormat(*.snp)", "", "", "", "RECOMMENDATION #:" & " " & Me.
[RECNUMBER] & " " & Me.[TARGETDATE], "", False, ""
DoCmd.OpenQuery "QRY-RECS-CREATED-TODAY-EMAILED-UPDATE" 'updates
records that were checked for emailing so they will not show on form
again to be selected.
Forms![FRM-RECS-CREATED].Requery ' requery form after emailing last
checked records to show records remaining to be emailed.

My button code works fine, until I added code in my reports OnOpen
event to change the reports Caption. I want to change the caption so
that the report name that is attached to the email will say
Recommendation, then show the values for the Recnumber and TargetDate
instead of the actual name of the report.

Why does my code not run if I place this in my reports OnOpen Event?

My code halts on line 2 if the OnOpen code is active.

Help
 
A

Allen Browne

Heidii, I doubt you can do this effectively in Report_Open.

Someone else may have a suggestion, but opening in design view and setting
the Caption is all that comes to mind.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

heidii said:
The important thing is that, when you perform theSendObject, Access opens
thereportand its Report_Open event fires. No other instance is open, and
so it gets processed correctly, in exactly the same way it would have
been
processed had you use OpenReport.

I am having a problem with changing the caption on my reports onopen
event.

I have a continous form with a command button at the end of each
record.

Here is the code on my button:

Me.EMAILREC = True 'check emailed box to that it can't be queried
again on form
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.SendObject acReport, "RPT-RECOMMENDATIONS-EMAIL-MAIN1",
"SnapshotFormat(*.snp)", "", "", "", "RECOMMENDATION #:" & " " & Me.
[RECNUMBER] & " " & Me.[TARGETDATE], "", False, ""
DoCmd.OpenQuery "QRY-RECS-CREATED-TODAY-EMAILED-UPDATE" 'updates
records that were checked for emailing so they will not show on form
again to be selected.
Forms![FRM-RECS-CREATED].Requery ' requery form after emailing last
checked records to show records remaining to be emailed.

My button code works fine, until I added code in my reports OnOpen
event to change the reports Caption. I want to change the caption so
that the report name that is attached to the email will say
Recommendation, then show the values for the Recnumber and TargetDate
instead of the actual name of the report.

Why does my code not run if I place this in my reports OnOpen Event?

My code halts on line 2 if the OnOpen code is active.

Help
 

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