Hi there, can you try:
Code:
Private Sub ImprimirPDFcmd_Click()
On Error GoTo Err_ImprimirPapelcmd_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim stDocName As String
Dim stLinkCriteria As String
Dim stFileName as String
stDocName = "Diagram_Cause_Efect_ByID" 'modify the report to include the criteria below in its record source and save it with a different name as suggested
'stLinkCriteria = "[ID]=" & "'" & Me.ID & "'"
'Set Application.Printer = Application.Printers("PDF Creator")
'Application.Printer.Orientation = Orientacion
'Application.Printer.PaperSize = Tamaņo
stFileName=CurrentProject.path & "\" & stDocName & Format(Date,"YYYYMMDD") & ".pdf" 'set the file name for the new PDF
'DoCmd.OpenReport stDocName, acViewNormal, , stLinkCriteria
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF, stFileName, True
'Set Application.Printer = Nothing
MsgBox "Report to PDF", vbInformation, "Exporting to PDF"
Exit_ImprimirPapelcmd_Click:
Exit Sub
Err_ImprimirPapelcmd_Click:
MsgBox Err.Description
Resume Exit_ImprimirPapelcmd_Click
End Sub