selection criteria in sendobject

Lanason

Registered User.
Local time
Today, 21:40
Joined
Sep 12, 2003
Messages
258
I am automatically send a pdf report in an email

does anyone know how to send a selection parameter to select just particular record from the report??

DoCmd.SendObject acReport, StDocName, acFormatPDF, MailTo, MailCC, MailBcc, Subject, MailGreeting & MailMessage & MailSignature, True

Thanks

Adrian
 
If you open the report filtered first, then do the send object it will send the filtered open version.

The other option is to include the parameter in the reports underlying query recordsource. So if it's a form field put that in the query.
 
you want to send report: StDocName
uses the query behind the report , qsMyQuery1Rec
the query: qsMyQuery1Rec will look at the form, myForm, to see what record you are on.

query sql: select * from table where [id] = forms!myForm!txtID
user selects record on the form, clicks the button to send the email, (or print rpt)
the query sees the current record , the report is filtered, now send.
 
Thank you guys - I was trying to get away from creating a separate query / report and use a generic report with no parameters hard encoded
 
Then use the first option, open the report filtered, then save/send it , then close it.

Code:
DoCmd.OpenReport "YourReport", acViewPreview, , "YourIDField = " & YourCriteriaID  [COLOR="green"]' This filters it without hard coding the report [/COLOR]
DoCmd.OutputTo acOutputReport, "YourReport", acFormatPDF, strSavePath , , , , acExportQualityPrint      [COLOR="Green"]'This saves the pdf but you can send it instead
[/COLOR]DoCmd.Close acReport, "YourReport"  [COLOR="green"] 'Close it afterwards[/COLOR]
 

Users who are viewing this thread

Back
Top Bottom