I am trying to run a code that will print a report to pdf and save in the specified folder, however I keep getting an error with the file name. Where am I going wrong?
Also, is there a way of adding a hyperlink to the folder in the message box?
Also, is there a way of adding a hyperlink to the folder in the message box?
Code:
Private Sub CmdPrintJob_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ContractName] = """ & Me.[ContractName] & """"
DoCmd.OpenReport "RPTJobSetUp", acViewPreview, , strWhere
End If
Dim FileName As String
Dim FilePath As String
[COLOR="Red"]FileName = Me.ContractName
[/COLOR]FilePath = "J:\Job Set-Up Sheets\" & FileName & ".pdf"
DoCmd.OutputTo acOutputReport, "RPTJobSetUp", acFormatPDF, FilePath
Debug.Print FilePath
MsgBox "Your new job set-up has been successfully created and saved to J:\Job Set-Up Sheets ", vbInformation, "New Job Set-Up"
End Sub