Print Event Not Working

Tophan

Registered User.
Local time
Today, 15:43
Joined
Mar 27, 2011
Messages
389
Good afternoon,

I tried combining two print events I had in two separate databases. The first one just gives a print preview of the current record. The second one prints the report to a pdf and saves it in the specified folder.

However, when I try combining the two events, the pdf is not creating. I would greatly appreciate if someone could review and advise where I'm going wrong.

Code:
Private Sub CmdPrintTender_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 = "[TenderNo] = """ & Me.[TenderNo] & """"
          DoCmd.OpenReport "RPTProspectiveWorks", acViewPreview, , strWhere
      End If
   
  Dim FileName As String
  Dim FilePath As String
   
  FileName = Me.TenderNo & " - " & Me.ProjectName
  FilePath = "J:\Tender Detail Forms" & FileName & ".pdf"
  DoCmd.OutputTo acOutputReport, "RPTProspectiveWorks", acFormatPDF, FilePath
  MsgBox "Tender Detail Form has been successfully created and saved to J:\Tender Detail Forms", vbInformation, "Enter Tender Details"
  End Sub
 
Is the path appropriate? I'd use a UNC path, but it should work if the J drive is properly mapped. My gut tells me you need a backslash to separate the folder from the file name.
 
Thank you. I forgot to insert the second backsplash in the file path. It was corrected as follows

Code:
FilePath = "J:\Tender Detail Forms[COLOR="Red"]\[/COLOR]" & FileName & ".pdf"
 

Users who are viewing this thread

Back
Top Bottom