Results 1 to 3 of 3
  1. #1
    FriQenstein is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    98

    Different results from the OutputTo function

    Greetings all,



    I have a button that has the following VBA to output the report to a PDF file:
    Code:
    Private Sub EXPORT_Click()
    Dim myPath1 As String
    Dim myPath2 As String
    Dim strReportName As String
    
    
    myPath2 = Me.Text23
    myPath1 = "C:\Users\User1\Documents\Projects\Database\Outbound Invoices\" + myPath2 + "\"
    strReportName = Me.Text20 & ".pdf"
    DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath1 + strReportName, True
    
    
    End Sub
    This works perfectly. When the button is clicked, the report is automatically written to the specified path and filename and then it opens the PDF in view mode with the default PDF viewer.

    However, when I try to do the same thing on a second report, I get different results. When clicking the button, it opens the report in the PDF view and does not actually export it. I cannot see any differences in the code so I am uncertain why the second rendition is not performing like the first.
    Here is the code for the second button:
    Code:
    Private Sub Command152_Click()
    Dim myPath_A As String
    Dim myPath_B As String
    Dim strRCVRname As String
    
    
    myPath_A = Me.ClientName
    myPath_B = "C:\Users\User1\Documents\Projects\Database\Inbound Invoices\" + myPath_B + "\"
    strRCVRname = Me.RCVRnumber & ".pdf"
    DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath_A + strRCVRnumber, True
    
    
    End Sub
    Am I missing something here?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    myPath_A does not hold a file path. Perhaps you want
    Code:
    myPath_A = Me.ClientName myPath_B = "C:\Users\User1\Documents\Projects\Database\Inbound Invoices\" + myPath_A + "\" strRCVRname = Me.RCVRnumber & ".pdf" DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath_B + strRCVRnumber, True
    None of those variables are really needed unless data is used multiple times in code.
    Code:
    DoCmd.OutputTo acOutputReport, "", acFormatPDF, "C:\Users\User1\Documents\Projects\Database\Inbound Invoices\" & Me.ClientName & "\" & Me.RCVRnumber & ".pdf", True

    & character is preferred operator for concatenation
    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
    FriQenstein is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Posts
    98
    Quote Originally Posted by June7 View Post
    myPath_A does not hold a file path. Perhaps you want
    Code:
    myPath_A = Me.ClientName myPath_B = "C:\Users\User1\Documents\Projects\Database\Inbound Invoices\" + myPath_A + "\" strRCVRname = Me.RCVRnumber & ".pdf" DoCmd.OutputTo acOutputReport, "", acFormatPDF, myPath_B + strRCVRnumber, True
    None of those variables are really needed unless data is used multiple times in code.
    Code:
    DoCmd.OutputTo acOutputReport, "", acFormatPDF, "C:\Users\User1\Documents\Projects\Database\Inbound Invoices\" & Me.ClientName & "\" & Me.RCVRnumber & ".pdf", True

    & character is preferred operator for concatenation
    Thank you June7. That was exactly what it was... I had my two variables backwards.. in the wrong area.
    Much appreciated. Up-voted.

    Regards

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

Similar Threads

  1. iif Function not giving me correct results
    By Ramesh Kumar C in forum Queries
    Replies: 4
    Last Post: 08-30-2017, 10:15 AM
  2. Replies: 31
    Last Post: 08-10-2017, 01:26 PM
  3. DSum function not returning any results
    By dougdrex in forum Queries
    Replies: 6
    Last Post: 12-23-2014, 02:09 PM
  4. Results from local function won't compare
    By joethall in forum Queries
    Replies: 1
    Last Post: 07-27-2013, 08:13 AM
  5. Replies: 2
    Last Post: 04-16-2012, 12:56 PM

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