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've 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 can use the following code to mail a 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

Any help will be much appreciated.
 
G

Guest

Have you tried putting all the report criteria on the report's on open event?

When you mail out the report it in affect opens it and then prints it to an rtf file which is sent. Thus, if the criteria is set on open, this should sort the problem out for you.

Hope it helps mate.

Basil
 
G

Guest

Thanks for your help, Basil, however, I am not sure as to the correct command I need to use to apply this criteria.
 
G

Guest

Alright Jedster

I don't really understand what you have done, how you intend the report to be used -
- Will the report only be used from this form
- Has the report already been created
- What is it's record source

If the answer to the first question is yes, then you can simply have any parameters in the record source query

Otherwise you can build custom criteria into an SQL string (which can be part fed by user-input variables) that will only be given to the report on that occasion. On open you would type in
Me.RecordSource = "SELECT ..... FROM.... WHERE.......;" 'If you are copying the SQL string from a query's SQL view, make sure you replace all " symbols for

Hope this helps, give me more info if not

----- Jedster wrote: ----

Thanks for your help, Basil, however, I am not sure as to the correct command I need to use to apply this criteria.
 

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