Sub ExportReportForRecord()
Dim recordID As Long
Dim reportName As String
Dim filter As String
Dim outputPath As String
' === Set these values ===
recordID = 123 ' <-- Change this to your selected record ID
reportName = "MyReport" ' <-- Name of your report
outputPath = "C:\Reports\MyReport_" & recordID & ".pdf" ' Output file path
' === Filter to select the record ===
filter = "[ID] = " & recordID ' <-- Change [ID] to your primary key field
' === Open report in hidden mode, filtered to record ===
DoCmd.OpenReport reportName, acViewPreview, , filter
' === Output to PDF ===
DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, outputPath, False
' === Close the report ===
DoCmd.Close acReport, reportName
MsgBox "Report exported to: " & outputPath
End Sub