Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2014
    Posts
    1

    Post Unanswered: Export form to PDF with Date and Time

    This code exports a form to the current desktop using the current date and time as part of the file name. Since the second is included the form can be reexported recurrently without overwriting the last copy. Can be used with a report as well by editing as required.

    '------------------------------------------------------------
    ' Export_Log_PDF_Export
    '
    '------------------------------------------------------------
    Function Export_Log_PDF_Export()

    Dim mnth As String
    Dim dy As String
    Dim yr As String
    Dim tm As String
    Dim hr As String
    Dim mn As String
    Dim sc As String
    Dim file_nme As String

    mnth = Month(Now())
    dy = Day(Now())
    yr = Year(Now())
    hr = Hour(Now())
    mn = Minute(Now())
    sc = Second(Now())
    file_nme = "./" + mnth + "-" + dy + "-" + yr + "_" + hr + "" + mn + "" + sc + "_XXXXX_Shift_Record.pdf"


    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.SetWarnings False
    DoCmd.OutputTo acOutputForm, "FormName", "PDFFormat(*.pdf)", [file_nme], False, "", , acExportQualityPrint

    Export_Log_PDF_Export_Exit:
    Exit Function

    End Function
    __________________________________________________ _______

    Save as a module and attach to a button to activate. Thanks to DB Forum users for the information needed to make this work.
    Last edited by RKee; 07-20-14 at 12:52.

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    Code:
    vFilename = format(now(),"yyyymmdd-hhnnss") & "_XXXXX_Shift_Record.pdf"
    DoCmd.OutputTo acOutputForm, "FormName", "PDFFormat(*.pdf)", vFilename , False, "", , acExportQualityPrint

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •