Results 1 to 7 of 7
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097

    output report object directly to pdf file without any preview

    I'd like the report object to output directly to the pdf file without any preview. The format property of the report is "Report View". Do I simply have the arguments wrong? (The two variables are valid string)



    Code:
    DoCmd.OutputTo acOutputReport, rptName, acFormatPDF, strCurPDFName

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Syntax looks fine.

    So is the output failing?
    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.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    The preview is fine and so is the pdf. What I'm trying to do is create the pdf WITHOUT first seeing the report preview. I.e., just write the pdf and nothing else.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Did you try? It should work, however, any filtering supplied through OpenReport command will not be possible.
    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.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    Got it. Below is the open code and a pretty clear source of the problem. I can solve this problem either with a bit of code to update the query def or follow Welshgasman's suggestion, which I'll try first and report back after dinner

    Code:
    Private Sub Report_Open(Cancel As Integer)
    
    
    If Left(strCurRetreat, 1) = "S" Then
        Me.Filter = "SPRING Like  ""*-*"" AND SUPPS = False"
        Me.FilterOn = True
    Else
        Me.Filter = "FALL Like  ""*-*"" AND SUPPF = False"
        Me.FilterOn = True
    End If
    
    
    End Sub

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    Works like a champ! I'll finish up with some error handling and a boat-load of comments so that "I" don't forget what the whole scheme is about....
    Code:
    Private Sub pdfDirect(rptName As String, CtrlName As String)
    
    
    strpdfFile = Forms("frmDocuments").Controls(Replace(CtrlName, "lbl", "tb"))
    strCurPDFName = strCurRptsPath & "\" & strCurRetreat & "\" & strpdfFile & ".pdf"
    
    
    DoCmd.OpenReport rptName, acViewPreview, , , acHidden
    DoCmd.OutputTo acOutputReport, rptName, acFormatPDF, strCurPDFName
    DoCmd.Close acReport, rptName, acSaveNo
    
    
    End Sub
    Probably include the URL's to both this thread as well as Welshgasman's right in the comment block of the sub.

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

Similar Threads

  1. Output Report to PDF file
    By jcc285 in forum Reports
    Replies: 4
    Last Post: 03-30-2015, 10:54 AM
  2. Replies: 2
    Last Post: 03-16-2014, 02:12 PM
  3. Importing file directly from a Sharepoint file (not list)
    By jstoler in forum Import/Export Data
    Replies: 1
    Last Post: 06-28-2013, 01:44 PM
  4. Save a report file without preview
    By alex__ice in forum Reports
    Replies: 2
    Last Post: 04-16-2013, 08:13 AM
  5. Replies: 0
    Last Post: 02-04-2009, 04:47 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