Reputation: 347
I have just recently coded behind a command button to send an email of a form, but when the email pops up and I open the PDF file there are 15 duplicates of the same form. Does anybody know why this would be happening?
Thanks :)
On Error GoTo errhandle
DoCmd.SendObject acSendForm, "frmETIC", acFormatPDF, "email address", "", "", "Recovery Report", "Attached is the submitted Recovery Report"
exitErr:
Exit Sub
errhandle:
If Err.Number <> 2501 Then
MsgBox ("Email cancelled!")
End If
Resume exitErr
Me.Filter = "CurrentDate= #" & Me!CurrentDate & "#" AND "Discover= '" & Me!Discover & "'" AND "Tail= '" & Me!Tail & "'" AND "FleetID= '" & Me!FleetID & "'"
Upvotes: 2
Views: 132
Reputation: 2059
It sounds like your form currently has 15 records. When you use SendObject on a form, it prints all records in the form, not just the current one, into the PDF. I think you need to filter your form to show only the current record, then SendObject. If your data source has a primary key field named ID
use:
Me.Filter = "ID=" & Me!ID
Me.FilterOn = True
DoCmd.SendObject acSendForm, "frmETIC", ...
If you have a multi-field primary key use:
Me.Filter = "ID=" & Me!ID & " AND CustName = '" & Me!CustName & "'"
Me.FilterOn = True
Use no delimiter for numeric fields, quotes around text field values, and #
around date field values formatted mm/dd/yyyy.
Upvotes: 2