Solved

Syntax to OutputTo acOutputReport using string values

Posted on 2008-06-13
2
1,125 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 119

Expert Comment

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


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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Correct ordering 16 48
How to make an ADE file by code? 11 42
SharePoint 2013 Relational Database 8 27
Access checkbox 2 13
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now