Create a public string variable, and use the Open event of the report to
read and apply the string as the filter.
1. On the Modules tab of the Database Window, click New.
Access opens a new module.
In the General Declarations (just under the Option statements), enter:
Dim gstrReportFilter As String
Save with a name such as "Module1".
Close.
2. Open your report in design view.
Set the On Open property (Event tab of properties box) to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Enter this kind of thing:
Private Sub Report_Open(Cancel As Integer)
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = vbNullString
End If
End Sub
3. Set the filter string before you open your report.
It will be just like the WhereCondition of OpenReport.
Example:
gstrReportFilter = "[InvoiceID] = 73"
DoCmd.SendObject acReport "rptInvoice", .......
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
jlk said:
I need to email a report regarding only one item just as I would send this
report page to the printer.
The DoCmd.SendObject command has no where clause so a script like
DoCmd.SendObject acReport "rptInvoice", .......
would send a complete listing to as an email attachment.
I have not found a way to trim the complete report to the record that has
to be sent.
Would someone have a workaround for me?
I work with access 2000 and 2003.
Hans