D J
asked on
MS Access How can I convert my VBA code from print preview to PDF output?
How can I convert my VBA code (see below) from print preview to PDF output?
Private Sub Command68_Click()
Dim var As Variant
Dim where As String
For Each var In Me.List66.ItemsSelected
where = Me.List66.ItemData(var) & "," & where
Next var
If Len(where) > 0 Then
where = Left(where, Len(where) - 1)
DoCmd.OpenReport "rpt_SW_Report_By_H", acViewPreview, , "lc_craftsid IN (" & where & ")"
End If
End Sub
Insert a one code line to print to PDF:
If Len(where) > 0 Then
where = Left(where, Len(where) - 1)
DoCmd.OpenReport "rpt_SW_Report_By_H", acViewPreview, , "lc_craftsid IN (" & where & ")"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, "C:\Test\rpt_SW_Report_By_H.pdf", False
End If
/gustav
ASKER
Thanks Gustav,
How do I stop the print preview from displaying with the PDF?
(would like to display PDF only)
How do I stop the print preview from displaying with the PDF?
(would like to display PDF only)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Gustav,
It flashes on the screen, should be OK.
It flashes on the screen, should be OK.
ASKER
Thanks Gustav!
You are welcome!
/gustav
/gustav
if it is a query, post the SQL statement of the query.
if it is a table, create a query against the table, then use the query as the Record Source of the report and post the SQL statement of the query.
better if you can upload a copy of the db. (will save more time posting back and forth)