Create a report.
Open report with WHERE criteria for the record(s) required.
Output to pdf is required.
Private Sub cmdShip_Click()
On Error GoTo Err_cmdShip_Click
Dim stRptName As String, stParam As String, stLinkCriteria As String, stDBpath As String, stFTPpath As String, _
Dim iPreview As Integer, iDialog As Integer, blnPrintIt As Boolean
stDBpath = CurrentProject.Path & "\"
stFTPpath = stDBpath & "Gazette\"
iPreview = acViewPreview
If Me.ChkPreview Then
' iPreview = 2
iDialog = acWindowNormal
Else
iDialog = acHidden
End If
stRptName = "Main_by_Ship"
stParam = Replace(LCase(Me.cboShip.Value), " ", "_")
stLinkCriteria = "[Ship] = '" & Me.cboShip.Value & "'"
'DoCmd.CopyObject , stParam, acReport, stRptName
If Me.ChkPreview Then
DoCmd.OpenReport stRptName, iPreview, , stLinkCriteria, iDialog
Else
DoCmd.OpenReport stRptName, iPreview, , stLinkCriteria, iDialog
DoCmd.OutputTo acOutputReport, stRptName, acFormatPDF, stFTPpath & stParam & ".pdf", False
DoCmd.Close acReport, stRptName
End If
Exit_cmdShip_Click:
Exit Sub
Err_cmdShip_Click:
MsgBox Err.Description
Resume Exit_cmdShip_Click
End Sub