Results 1 to 2 of 2
  1. #1
    sakurasanta86 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2018
    Posts
    1

    Export report to PDF with automatic naming

    Hello,I want to automatically save a report to a pdf with automatic naming by clicking a button:- report name : rptTest- name of the pdf-file : number-initials-date.pdf (e.g 2156598-SRU-20171222.pdf)I am getting the error message "The action or method requires a Report Name argument."What am i doing wrong?I used the following code :Private Sub Command0_Click()On Error GoTo Err_Command0_ClickDim Number As StringDim Initials As StringDim Date As StringDim Filename As StringDim Path As StringNumber= Me.Number.ValueInitials = Me.Initials.ValueDate = Year(Now()) & "" & Month(Now()) & "" & Day(Now())Filename = Number & "-" & Initials & "-" & Date & ".pdf"Path = "D:\Documents\Projecten\Database" & FilenameDoCmd.OpenReport rptTest, acPreviewDoCmd.OutputTo acOutputReport, "rptTest", acFormatPDF, Path, TrueExit_Command0_Click:Exit SubErr_Command0_Click:MsgBox Err.DescriptionResume Exit_Command0_ClickEnd Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Please format code with CODE tags to retain line endings and indentations so we can read it easier. I am not inclined to try and decipher as it is.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-25-2018, 02:53 PM
  2. Export report to PDF with automatic naming
    By Monoceros in forum Programming
    Replies: 6
    Last Post: 12-23-2017, 08:07 AM
  3. automatic report export/emailing
    By broecher in forum Programming
    Replies: 6
    Last Post: 01-29-2015, 03:21 PM
  4. Automatic Document Naming
    By dbakeg00 in forum Access
    Replies: 7
    Last Post: 01-22-2015, 03:25 PM
  5. Replies: 7
    Last Post: 01-08-2014, 10:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums