Solved

Syntax to OutputTo acOutputReport using string values

Posted on 2008-06-13
2
1,152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

726 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