Hi
I want to click button in a form and generate a pdf based on the current record in the form.
I have 2 modules that are not perfect
This is perfect but the form/pdf is not filtered and sends all records.
This filters the form to the current record but leaves me in the preview window where I cant populate the email body and fields programmatically.
Can anyone help me filter the first option. I notice that even is the form has a filter applied, DoCmd.SendObject seems to ignore the filtering.
I have really spent some hours on this, any help appreciated
I want to click button in a form and generate a pdf based on the current record in the form.
I have 2 modules that are not perfect
Code:
Function EmalReport_VBA()
On Error GoTo EmalReport_VBA_Err
Option Compare Database
DoCmd.SendObject acReport, "PDFFormat(*.pdf)", "e", "", "ailbcc", "Subject", "Message Text", True, ""
EmalReport_VBA_Exit:
Exit Sub
EmalReport_VBA_Err:
MsgBox Error$
Resume EmalReport_VBA_Exit
End Sub
This filters the form to the current record but leaves me in the preview window where I cant populate the email body and fields programmatically.
Code:
Private Sub Preview_Button_Click()
DoCmd.OpenReport "Item", acViewPreview, , "[ID]=" & Me.ID
End Sub
I have really spent some hours on this, any help appreciated