Question Emailing a single record - URGENT !!!

norton

New member
Local time
Today, 17:38
Joined
Jul 23, 2008
Messages
5
Hi all ... i know this has probably been dredged up before but I am struggling with this and I need an urgent fix.

I am trying to email a single record in a report. But no matter what I have tried it always produces a report of all recordests. I just need it to send the report that is currently being viewed in a form.

my current code works but only for 'all recordsets'.

here it is:
Private Sub sendMail_Click()
On Error GoTo Err_sendMail_Click
Dim strWhere As String
Dim stDocName As String
strWhere = "fldID"
stDocName = "rptPrintRecord"
DoCmd.SendObject acReport, stDocName, , "", , , "Website Enquiry", "Please find the attached Website Enquiry for your attention."

Exit_sendMail_Click:
Exit Sub
Err_sendMail_Click:
MsgBox Err.Description
Resume Exit_sendMail_Click
End Sub

any further help would be greatly appreciated.:confused:
 
One way is to set up the filter in the report (and switch it on!). You will want the filter to reference the field on your form. So the filter will look something like:

[myTableField]=forms!myFormName!myFormBoxName

Save the report (don't forget to switch the filter on). The report will then open for the record given in the form. Note that the report won't work if the form isn't open.

Your code will the run the report which will filter.
You can get rid of: strWhere = "fldID"

hth
Chris
 
Hi Stopher,

Thanks for that , i'm a little confused what you mean by myFormBoxName ?
 
Hi guys, I don't know what to put in myFormBoxName/myTextBoxName field, I'm noob, please help!

Thanks!
 
Hi guys, I don't know what to put in myFormBoxName/myTextBoxName field, I'm noob, please help!
This should be the name of the control on the form that accepts the user input.
 

Users who are viewing this thread

Back
Top Bottom