Results 1 to 7 of 7
  1. #1
    Monoceros is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2009
    Posts
    5

    Post 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_Click


    Dim Number As String
    Dim Initials As String
    Dim Date As String
    Dim Filename As String
    Dim Path As String

    Number= Me.Number.Value
    Initials = Me.Initials.Value
    Date = Year(Now()) & "" & Month(Now()) & "" & Day(Now())
    Filename = Number & "-" & Initials & "-" & Date & ".pdf"
    Path = "D:\Documents\Projecten\Database" & Filename


    DoCmd.OpenReport rptTest, acPreview
    DoCmd.OutputTo acOutputReport, "rptTest", acFormatPDF, Path, True


    Exit_Command0_Click:
    Exit Sub
    Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click

    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  3. #3
    Monoceros is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2009
    Posts
    5
    Yes : rptTest but without the quotes

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Code:
    DoCmd.OpenReport rptTest, acPreview
        DoCmd.OutputTo acOutputReport, "rptTest", acFormatPDF, Path, True
    In these lines, rptTest seems to be an un-dimmed variable;
    "rptTest" is the literal string, name of your report.

  5. #5
    Monoceros is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2009
    Posts
    5
    Not sure I understand you : I changed it to the following code, but I keep getting the same error message.

    Dim Number As String
    Dim Initials As String
    Dim Date As String
    Dim Filename As String
    Dim Path As String
    Dim Report As String

    Number= Me.Number.Value
    Initials = Me.Initials.Value
    Date = Year(Now()) & "" & Month(Now()) & "" & Day(Now())
    Filename = Number & "-" & Initials & "-" & Dats & ".pdf"
    Path = "D:\Documents\Projecten\Database" & Filename
    Report = "rptTest"

    DoCmd.OpenReport rptTest, acPreview

    DoCmd.OutputTo acOutputReport, "Report", acFormatPDF, "Path", True

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Try (untested)
    DoCmd.OpenReport "rptTest", acPreview
    DoCmd.OutputTo acOutputReport, "rptTest", acFormatPDF, Path, True

  7. #7
    Monoceros is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2009
    Posts
    5
    Quote Originally Posted by orange View Post
    Try (untested)
    DoCmd.OpenReport "rptTest", acPreview
    DoCmd.OutputTo acOutputReport, "rptTest", acFormatPDF, Path, True
    Yes, it worked ! Thank you very much

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

Similar Threads

  1. Automatic report update
    By gsucin in forum Reports
    Replies: 4
    Last Post: 10-27-2016, 01:04 PM
  2. Naming a report.
    By Homegrownandy in forum Reports
    Replies: 2
    Last Post: 11-18-2015, 08:01 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

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
  •  
Other Forums: Microsoft Office Forums