Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a Filter or Where Condition to a Send Object String

Status
Not open for further replies.

ImStuk

Technical User
Feb 20, 2003
62
US
I am trying to use the following with a Command Button to send a report via email. I want to use a where condition to open/send the report so that only the current record is on the report. Where can I insert the Criteria filter I wrote in the Send Object string?

Private Sub cmdemail_Click()
On Error GoTo Err_cmdemail_Click
Dim stDocName As String
Dim stCriteria As String
stDocName = "rptActivitySheet"
stLinkCriteria = "[ActivitySheetID]=" & Me![ActivitySheetID]
DoCmd.SendObject acSendReport, "rptActivitySheet", "Snapshot Format (*.snp)", , , , stDocName, , 1
Exit_cmdemail_Click:
Exit Sub
Err_cmdemail_Click:
If Err.Number = 2501 Then
MsgBox "This Activity Sheet was not sent", vbCritical, "Email Canceled..."
Exit Sub
Else
MsgBox Err.Description
Resume Exit_cmdemail_Click
End If
End Sub
 
I actually found an easy Solution to my problem. I just put a filter in the Query That is the Report Record Source.

However, if somebody knows how to insert a filter into the send object string I would still love to know.
 
Nope - it's either what you've alredy done (criteria in the query), assign the recordsource in the reports on open event, or you could use a querydef object to alter the stored query.

Roy-Vidar
 
i was also trying to use filters on the OutputTo method. i found a way to do this using the OpenReport method before the OutputTo.
So the OutputTo will include in the rtf file only the conditioned data

Se below


id = Me!listboxinvoiceids
stDocName = "Test1"
DoCmd.OpenReport stDocName, acPreview, , "[InvoiceID]=" & Me!listboxinvoiceids
DoCmd.OutputTo acOutputReport, stDocName, "Rich Text Format (*.rtf)", "c:\" & id & ".rtf", no
DoCmd.Close acReport, stDocName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top