Emailing one record from a report

Elwood

Four Fried Chickens
Local time
Today, 03:20
Joined
Jul 13, 2004
Messages
5
I am trying to email one record as a PDF attachment. Below is the code I’m using. The problem is it puts every record into the PDF. At one time I had the same problem while printing I was able to print one record by using the ID field to print one record at a time:

DoCmd.OpenReport stDocName, acViewNormal, , "[ID]=" & Me![ID]

Any help is greatly appreciated.

Private Sub cmdBolo_Click()
On Error GoTo Err_cmdBolo_Click
Dim stDocName As String
Dim stMsg As String
Dim stAddress As String
stMsg = "See Attachment
stDocName = "rptBoloMain"
stAddress = "elwood@medo.com"
DoCmd.OpenReport stDocName, acPreview
DoCmd.SendObject acSendReport, stDocName, acFormatPDF, stAddress, , , "BOLO Test", stMsg, True
Exit_cmdBolo_Click:
Exit Sub
Err_cmdBolo_Click:
MsgBox Err.Description
Resume Exit_cmdBolo_Click
End Sub
 
Have you tried adding that wherecondition when you open it in preview mode?
 
Thank you for the reply Paul,

I’m embarrassed to say my coding has been trial and error with copy and paste. Not sure how to add a wherecondition. Would that follow the acPreview? Can you give me an example?
 
Adapted from your own code:

DoCmd.OpenReport stDocName, acPreview, , "[ID]=" & Me![ID]
 
Throwing an error. "The action or method requires a Report Name argument".
 
That's from your code. Are you still setting the variable to the report name?
 
Paul you are a GOD! Works like a charm.

Thank you for sharing your time.

Kevin
 

Users who are viewing this thread

Back
Top Bottom