View Full Version : Export Record to PDF


jfgambit
07-29-2008, 09:31 AM
Ok, this is driving me nuts....

Utilizing Access 2007 I have a report that I want to export as a PDF. The report is based on a query that calls for the specific ID number from a form (ID = [Forms]![frmPeerValid]![ID]). Query works fine, and if you open the report it works fine, but when I export the report via a command button on the form, all the records are exported. How do I export to PDF just the record that the individual is on? Code is as follows:

Private Sub cmdEmail_Click()
'On Error GoTo ErrorHandle

Dim strAttachPath As String
Dim strAttachPath2 As String

'Timestamp the completed validation
If IsNull(Me.ValCompDt) Then
Me.ValCompDt = Now()
End If

'Save the record
DoCmd.RunCommand acCmdSaveRecord

'Export the report to Word RTF
strAttachPath = "C:\temp\"
strAttachPath2 = "PeerValidation" & format(Date, "yyyymmdd") & ".pdf"

If Dir(strAttachPath & strAttachPath2) <> "" Then
Kill strAttachPath & strAttachPath2
End If

DoCmd.OutputTo acOutputForm, "frmPeerValid", acFormatPDF, strAttachPath & strAttachPath2, False, , , acExportQualityScreen

pbaldy
07-29-2008, 09:36 AM
You appear to be exporting the form rather than the report.

jfgambit
07-29-2008, 09:44 AM
And there we are...another coding snafu

thanks pb...