Reposted: Sending a report with criteria

G

Guest

Does anyone know how to send a report object in rtf format with criteria gathered from a dialog box

I started with the following code to use criteria from a dialog box to generate the report

Dim ReportNam
ReportName = "rptDiscontinuedCatalogue
DoCmd.OpenReport
ReportName:=ReportName,
View:=acViewPreview,
WhereCondition:="Department<>'94'" &
"AND SC<99 AND St='D' AND DiscDate Between #" &
Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #" &
Format$(Me.EndDate, "mm/dd/yyyy") & "#

and I know that I could use the following code to mail the report

DoCmd.SendObject objecttype:=acSendReport, ObjectName:="rptDiscontinuedCatalogue", To:="Joe Bloggs", Subject:="Subject", MessageText:="This is a test", EditMessage:=Tru

....however, I am so far unable to combine the two to produce the desired result

I have recently been advised to set the criteria on the report's On Open event, but am unsure of the correct command to use

Your help will be appreciated.
 
R

Rick

I have done something similar where I run a report, email it to the person
for whome it was run, run the next report, email it, etc.
The trick is to run the report with the criteria, then when building the
email statement don't specify the report name this tells it to send the
current report. Here is part of my code which seems to work pretty well...

Hope that gets you on track.

Rick



DoCmd.OpenReport varDocName, acViewPreview, , "[Enter
SupervisorID]=varUser" ' open report
DoCmd.SendObject acSendReport, , "snapshot format", varUser, , ,
"Exception Report", "Attached is your Exception report." & Chr(10) & "Please
work on the items listed before the managers receive their copy of the
report on Wednesday", False









Jedster said:
Does anyone know how to send a report object in rtf format with criteria gathered from a dialog box?

I started with the following code to use criteria from a dialog box to generate the report:

Dim ReportName
ReportName = "rptDiscontinuedCatalogue"
DoCmd.OpenReport _
ReportName:=ReportName, _
View:=acViewPreview, _
WhereCondition:="Department<>'94'" & _
"AND SC<99 AND St='D' AND DiscDate Between #" & _
Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #" & _
Format$(Me.EndDate, "mm/dd/yyyy") & "#"

and I know that I could use the following code to mail the report:

DoCmd.SendObject objecttype:=acSendReport,
ObjectName:="rptDiscontinuedCatalogue", To:="Joe Bloggs",
Subject:="Subject", MessageText:="This is a test", EditMessage:=True
...however, I am so far unable to combine the two to produce the desired result.

I have recently been advised to set the criteria on the report's On Open
event, but am unsure of the correct command to use.
 

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

Similar Threads


Top