Solved

Syntax to OutputTo acOutputReport using string values

Posted on 2008-06-13
2
1,141 Views
Last Modified: 2013-12-20
I am trying to pass a string as the ObjectName  and OutputFile values in the OutputTo acOutputReport function.  It works fine when I explicitly use the report name and path name in double quotes, but when I us the stDocName and strPath strings, I get an error message.  Can you help me with the syntax?

Error message received:  The report name ''rpt_All'' you entered in either the property sheet or macro is misspelled or refers to a report that doesn't exist.


Private Sub cmdCreatePDF_Click()
 
On Error GoTo Err_cmdCreatePDF_Click
 
 
 
    Dim strPath As String
 
    strPath = Me.Mail_Attachment_Path
 
    
 
    Dim stDocName As String
 
    Select Case Me.frame_Choices
 
        Case 1
 
        stDocName = "rpt_ANA"
 
        Case 2
 
            stDocName = "rpt_SUP"
 
        Case 3
 
            stDocName = "rpt_CSM"
 
        Case 4
 
            stDocName = "rpt_All"
 
        End Select
 
        
 
    
 
    'Send report as a snapshot  (works fine)
 
    DoCmd.OutputTo acOutputReport, "rpt_RollUP", _
 
    acFormatSNP, "Q:\SPG\SRG\Operations\StatusReporting_Testing\Rollup.snp", True
 
  
 
    works fine
 
    DoCmd.OutputTo acOutputReport, "rpt_All", _
 
    acFormatSNP, "Q:\SPG\SRG\Operations\StatusReporting_Testing\testRollup.snp", True
 
    
 
    Does not work
 
    DoCmd.OutputTo acOutputReport, "'" & stDocName & "'", _
 
    acFormatSNP, "'" & strPath & "'" & "'" & stDocName & "'", True
 
 
 
Exit_cmdCreatePDF_Click:
 
    Exit Sub
 
 
 
Err_cmdCreatePDF_Click:
 
    MsgBox Err.Description
 
    Debug.Print Err.Description
 
    Resume Exit_cmdCreatePDF_Click

Open in new window

0
Comment
Question by:PJVicto
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 21780093
DoCmd.OutputTo acOutputReport, stDocName , acFormatSNP, strPath & stDocName , True
 
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 21780137
you may need to add "\"


DoCmd.OutputTo acOutputReport, stDocName , acFormatSNP, strPath &"\"& stDocName , True
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question