title: Access VBA save object Report.pdf to a specific path with a unique name
body: <p>I'm familiar with VBA but I am not a programmer so any help I can get in this matter is greatly appreciated.  I have a report object that is mailed as a .pdf file. This portion of the code works fine but I would like to be able to save a copy of this file to a specific location with a unique name that includes the date and time the file was created.  The first set of code is the SendObject that works the second set of code does not work, it is a separate procedure I have been testing to save the object.  Once I can get it working I was going to integrate it into first.  I would appreciate any help.</p>
  
  <pre><code>Private Sub Command21_Click()
  
  DoCmd.SetWarnings (False)
  Dim mailto As String
  Dim ccto As String
  Dim bccto As String
      mailto = "Safety-RiskGroup@bargeacbl.com"
      ccto = ""
      bccto = ""
  emailmsg = "The attached document is the updated Case Log." &amp; vbNewLine     
  &amp; "Please review the report, contact me and you find any discrepancies. "&amp;vbNewLine &amp; vbNewLine &amp; "Thank You, " &amp; vbNewLine &amp; vbNewLine &amp; vbNewLine &amp; "Cary S. WInchester" &amp; vbNewLine &amp; "American Commercial Barge Line" &amp; vbNewLine &amp; "Safety Department"
  
  mailsub = "Updated Case Log Report"
  
  On Error Resume Next
  
  DoCmd.SendObject acSendReport, "rpt_CaseLog-CurrentYear", acFormatPDF, mailto, ccto, bccto, mailsub, emailmsg, True
  DoCmd.SetWarnings (True)
  
  End Sub
  </code></pre>
  
  <p>This is the second set of code to attempt to save the object to a specific path with a unique name.</p>
  
  <pre><code>Private Sub Command23_Click()
  
  On Error GoTo Command23_Click_Err
    Dim filePath As String
    filePath = "C:\Work\ACBL\Access Dbase\DayCount" &amp; "CaseLog" _
          &amp; Format(Date, " yyyy/mm/dd") _
          &amp; Format(Time, " hh:MM:ss") &amp; ".pdf"
    DoCmd.OutputTo acOutputReport, "rpt_CaseLog-CurrentYear", _
          "PDFFormat(*.pdf)", filePath, _
          False, "", , acExportQualityPrint
  Command23_Click_Exit:
    Exit Sub
  Command23_Click_Err:
    MsgBox Error$
    Resume Command23_Click_Exit
  
  End Sub
  </code></pre>