Docmd outputto acoutputreport Results


I have installed a 60-trial of Office 2007 to see if I can resolve a problem I currently have with Acc2000 :

I currently use the "outputto" command in the Report_Page event of the report to output an RTF file, which is then converted to a PDF and then e-mailed to customers.

i.e. DoCmd.OutputTo acOutputReport, "Quote2", acFormatRTF, FPath

I have experienced formatting problems with this method (that are OK if previewed in Access) in that large gaps appears in the report data when the report is longer than 3 pages.

After installing Office 2007, I downloaded and installed the "SaveAsPDFAndXPS.exe" add-in.

I have tried to use the outputto method as follows :

DoCmd.OutputTo acOutputReport, "Quote2", acFormatPDF, FPath

Where FPath is the full path to a network share.
(Nothing else has changed other than the output format)

I was hoping to cut out the middle part of the process and go straight to a PDF output, which can then be e-mailed, however, even though Access tells me it is outputting the report, there is nothing in the network folder when I go to find it!!
I have tried outputting the report to a local directory, but get the same (non)result.

Can anyone tell me what I have missed / needs to be added to get this to work???

I've looked through the past threads and none seemed to provide any insight to my situation. I'm new to the OutputTo command. I first tested it with a standalone macro. Once working, I created some code to execute the macro from a form with the database window hidden. The macro worked fine. I then have tried to run the command from vba (so that I may easily alter the output location and file name on the fly). I'm stuck on the 2046 error. Thinking there might be a problem with the variable stDocName, I tried the the report name as a quoted string -- still get the error.

Application.Echo False
DoCmd.Hourglass True
HideDatabaseWindow False
' DoCmd.RunMacro "OutPutRTF"
DoCmd.OutputTo acOutputReport, stDocName, _
acFormatRTF, _
"D:Office Developer ProjectsDatabaseApplicationDevlp_mdbAccess2002 Version3.xExpenses.rtf"
Application.Echo True
HideDatabaseWindow True
DoCmd.Hourglass False

I have tried searching here and found no solution to this little issue.

The Overflow error occurs when using the following code;

	DoCmd.OutputTo acOutputReport, Me.SelBP.Value & " Summary Report", acFormatRTF, "C:BPD" & Me.SelBP.Value & " Summary

You can see the report going through and when it reaches 5 or 6 pages, I receive the Overflow error.
If it's a short report all is well and it works fine.

Any suggestions please.

Hello Everyone,

I am a novice programmer but I am trying to take an Access 2010 project I created and put the backend on Azure (and then I want to use Sagekey to create an installation package for the front end). So far it works fine except in one area when the program hits this line "Docmd.OutputTo, acOutputReport, Document name, acFormatPDF..." I get the error "The command or action 'OutputTo' isn't avaliable now"

Does anyone have any idea as to what I am doing wrong?

DoCmd.OutputTo acOutputReport, "Report_Name", acFormatSNP, "C:somepathfilename.snp"

The line above is outputting a snapshot, but the report is based on a query that depends on user input. That is to say, when I try to run this, it'll prompt me to enter in a value for the variable "Input" so that it'll churn out the rest of the report.

How can I add that field in this code so that I can specify what I want "Input" to be when this line runs? Thanks.

I am building a button to export reports to an excel spreadsheet. I know how to use the OutputTo with variables to save a file to a specific place.

DoCmd.OutputTo acOutputReport, stDocName, acFormatXLS, stDocPath, False

But they want the ability to specify the directory location, kind of like when you do a file save as and then select where you want the file to go.

Other than putting a prompt in for them to type in the path/file name, what other options would allow them to specify the location and name of the file?

Hi super-brains,

I am finding that Access crashes on a line of code and I receieve the "Microsoft Access has encountered a problem and needs to close" type message.

The offending line is:

    DoCmd.OutputTo acOutputReport, sReportObj, "Biff8", , True

where sReportObj is the user chosen report name.

I have tried substituting each variable to test whether it's something going wrong, but that doesn't seem to make a difference. Worryingly, I've managed to use this code in another Db, so I am starting to worry that thier behaviour pointing towards a corrupt Db.

Looking through other threads on the forum, someone else has encountered the problem. They were exporting to text format however and was able to substitiute OutpputTo with TransferText. I am not able to use TransferSpreadsheet as I am outputting a report and not a table.

Any help greatly appreciated.

From eRed the Noobe :-)

I have a report that I am trying to save as a PDF using DoCmd.OutputTo

This code properly saves the report:

	DoCmd.OutputTo acOutputReport, "LTCFarNF", acFormatPDF, "M:ARMGRReports" & Me.ltcfname.Value & Chr(34) & ".pdf", True

However, I need to filter the report. The code below properly lets me preview the report:

	DoCmd.OpenReport "LTCFarNF", acViewPreview, , "[LTCFarNF].[ltcfname]=" & Chr(34) & Me.ltcfname.Value & Chr(34)

How can I apply the filter/where to the DoCmd.OutputTo

Thanks for your help!



I have used Access a lot for data analysis and am comfortable with regular macros but not much in the way of visual basic ... I have a query which returns 710 records. I have created a report based on the query which shows 1 record per page (so 710 pages). I would like to use the outputto command to set it up so it instead saves 710 individual files with a naming convention based on two of the fields in the report (asset#_city) ... I want to have the output in pdf so I added the addin to Access 2007.

From what I understand, here is the command:
DoCmd.OutputTo acOutputReport, "Verification Form", acFormatPDF, [Queries]![Report - Verification Form]![Asset Number]&"_"&[Queries]![Report - Verification Form]![City]&"_"&"_1VF.pdf",True

It is for a report named "Verification Form" and is based on a query named "Report - Verification Form"
(I know, I know ... naming a report Form and a query Report isn't ideal, but other than that - is the command correct?)

Any advice is appreciated ... for example, I don't even know where I should input the string, nor what needs to precede it (sub) or follow (end sub). ...

Thank you ...

Hi Forum, access 2010.

I want to filter a report for a variable number of days and then email same.
This code is on the form command button and the operator enters W, F, M or X to declare the number of days.

	Dim Response As String
    Dim ReportPeriod As String
    Response = InputBox("Enter W for Week, F for Fortnight, or M for Month to select " & _
                        "what Repayment Report to send. Enter X to escape and not send a report", vbInformation)
        If Response = "W" Then
            ReportPeriod = "Week"
        ElseIf Response = "F" Then
            ReportPeriod = "Fortnight"
        ElseIf Response = "M" Then
            ReportPeriod = "Month"
        ElseIf Response = "X" Then
            GoTo Exit_Procedure
            MsgBox "You must enter either W, F, M or X. Try again."
            GoTo Exit_Procedure
        End If
        'Produce and save report
    DoCmd.OpenReport "rptRepaymentsByStatementReport", acViewNormal, , , acWindowNormal, ReportPeriod
    DoCmd.OutputTo acOutputReport, "rptRepaymentsByStatementReport", acFormatPDF,
"W:AttachmentsrptRepaymentsByStatementReport.pdf", 0, , , acExportQualityPrint

This code is on the report Open event

	Dim strOpenArg As String
    strOpenArg = Me.OpenArgs()
    Select Case strOpenArg
    Case "Week"
        Me.Filter = "(StatementDate) Between Date()-7 And Date()"
        Me.FilterOn = True
    Case "Fortnight"
        Me.Filter = "(tblBankStatements.StatementDate) Between Date()-14 And Date()"
        Me.FilterOn = True
    Case "Month"
        Me.Filter = "(tblBankStatements.StatementDate) Between Date()-31 And Date()"
        Me.FilterOn = True
    Case Else
        'No OpenArg so do nothing
    End Select

It appears to work in that a report for either 7, 14 or 31 days is produced.
Then a full report for the last 11 years is also produced.

I suspect OutputTo is running the report instead of accepting the one produced by the code earlier ??

Appreciate any advice. Bill


I'm struggling with a vb macro in access 2007 that returns a "runtime error 2501 outputto action was cancelled". The codes is intended to break up a 1690 page report into 338 five page pdfs, name them, and save in a file structure it creates. Unfortunately it errors when it finishes creating the first pdf - the debugger highlights the DoCmd.OutputTo acOutputReport line.

I've tried different computers and uninstalling/reinstalling printer drivers. I've added error handling to ignore error 2501 but the code then runs but the pdfs and folder structure is never produced. This code worked the last time the report was run a year ago. I've inherited this project from someone who left the company and I have to admit I have almost no knowledge of vb code. Any idea what the problem is?

Option Compare Database
Option Explicit
Private Sub CreateReports_Click()
Dim cn As ADODB.Connection
Dim rsDistricts As ADODB.Recordset
Set cn = CurrentProject.Connection
Set rsDistricts = cn.Execute("SELECT [District_Code], [AGENCY_KEY], [AGENCY_NAME] FROM District_List")
Do Until rsDistricts.EOF
'Open report for a specific district
DoCmd.OpenReport "JUSTIN_District_Report_Template for 2010-11 9-27", acViewPreview, , "[District_Code]='" & _
rsDistricts![District_Code] & "'", acWindowNormal
'Output report to pdf file
DoCmd.OutputTo acOutputReport, "JUSTIN_District_Report_Template for 2010-11 9-27", acFormatPDF, _
"G:OEATSHACCESS for ELLs DataSecureReportsAMAO Reports" & rsDistricts![AGENCY_KEY] & "9999992010_11" & rsDistricts![AGENCY_NAME] & "_" & rsDistricts![District_Code] & "_ELL_AMAO_2010-11.pdf", , , , acExportQualityPrint

'Close report
DoCmd.Close acReport, "JUSTIN_District_Report_Template for 2010-11 9-27"

End Sub

I'm getting an "OutputTo action was cancelled" error when trying to save a report as a PDF. The code is very straightfoward and works perfectly on every machine but one. It's not a trust/permissions issue but I believe is related to a conflict with another version of Microsoft Office. The application is running under Access 2007 runtime on every machine. The machine in question also has a starter version of Office 2010 installed. After testing every conceivable possiblity I decided to uninstall Office 2010 and the application started working but only twice, now it's failing again. It's clearly something to do with the environment on this machine. I've tried uninstalling & reinstalling the application and Access Runtime but no help. I'm sure I can restore this machine to the factory image and get it working but I'd like to avoid that if at all possible. Perhaps someone has experience with version conflicts and/or library & registry issues related to this problem. The code in question is listed below but as I've already stated, it works fine everywhere but on this machine. Any help would be appreciated.

strRpt = "rptAcctsReceivableSingle"
strPDF = "C:testtest.pdf"
DoCmd.OpenReport strRpt, acPreview, , "[CustomerID] = " & Me!SelectCustomer
DoCmd.OutputTo acOutputReport, strRpt, acFormatPDF, strPDF, False
DoCmd.Close acReport, strRpt, acSaveNo

im trying to use a control source with-in a report to create the file name when exported

	DoCmd.OutputTo acOutputReport, "rptMATRIX", "PDFFormat(*.pdf)", "D:usersStagehandsDropboxstagehand payrollbilling" &
Report![rptMATRIX]![eventname]!Value & ".pdf", False, "", , acExportQualityPrint

the report is set to landscape; however, when i run this code it always exports a pdf in portrait...any suggestions

DOCUMENTSDropboxMCC CompletelightsissuesREPORTSELECTRIC ISSUES SORTED BY AREA.pdf", False, "", , acExportQualityPrint

Good afternoon fellow Access devotees :-)

I've been trying for a while now to get my code going..Feeling bit like my friend to my right.....

Allow me to explain. I have a Report that has a 'Division' as a Header.

A Division can be one of five variables ("CPD","SND","PSD","BPD","PPD")

Ideally want to output the report as a type PDF for each Division. Here, have 5 reports in a folder. I am only getting one. I know that the missing reports is not null. That is they have records.
Here is the code I have cobbled together...

Private Sub Print1_Click()
Dim PathNm As String
Dim RptNm As String
Dim strFileNm As String
Dim Sql As String
Dim db As DAO.Database
Dim rs As DAO.Recordset

On Error GoTo ErrorHandler
strPathNm = "D:Stock"
strRptNm = "BCSP Summary Report"

Sql = "SELECT DISTINCT R_Label1 FROM Ring Report"
Set db = CurrentDb()
Set rs = db.OpenRecordset("BCSP Report")

OwnNm = rs!R_label1
strFileNm = strPathNm & "BCSP_Summary" & "_" & OwnNm & ".pdf"

DoCmd.OpenReport strRptNm, acViewPreview, , "R_Label1 = '" & "CPD" & "' "
DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm
DoCmd.Close acReport, strRptNm

DoCmd.OpenReport strRptNm, acViewPreview, , "R_Label1 = '" & "SND" & "' "
DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm
DoCmd.Close acReport, strRptNm

DoCmd.OpenReport strRptNm, acViewPreview, , "R_Label1 = '" & "PSD" & "' "
DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm
DoCmd.Close acReport, strRptNm

DoCmd.OpenReport strRptNm, acViewPreview, , "R_Label1 = '" & "BPD" & "' "
DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm
DoCmd.Close acReport, strRptNm
DoCmd.OpenReport strRptNm, acViewPreview, , "R_Label1 = '" & "PPD" & "' "
DoCmd.OutputTo acOutputReport, strRptNm, acFormatPDF, strFileNm
DoCmd.Close acReport, strRptNm
Exit Sub
MsgBox "Error #: " & Err.Number & vbCrLf & Err.Description
End Sub

As I run the VBA I can see the all the Reports in preview so I believe that the filter is working. The Output to is falling down.

I accept that my code could work better. I tried writing code as a loop. It did work but as there are only five variables and over 1000 results in the query it took forever to loop through. I tried a Select Case Statement but couldn't get that going.

I would really value some guidance on how to do this.

Thanks in advance

I have an Access 2007 database in which every morning I manually initiate an event procedure (DoCmd.OutputTo acOutputReport), by clicking a Button, to output 5 preformatted reports as a PDF into a specific folder.

This works great - though I'd like to schedule it to run Daily at 6AM.

Is this possible?
Is this the correct way to go about this?

Below you will see my procedure....

Any help would be greatly apprciated

DoCmd.OutputTo acOutputReport, "REPORT1", acFormatPDF, "C: AMREPORTREPORT1.pdf"
DoCmd.OutputTo acOutputReport, "REPORT2", acFormatPDF, "C: AMREPORT REPORT2.pdf"
DoCmd.OutputTo acOutputReport, "REPORT3", acFormatPDF, "C: AMREPORT REPORT3.pdf"
DoCmd.OutputTo acOutputReport, "REPORT4", acFormatPDF, "C: AMREPORT REPORT4.pdf"
DoCmd.OutputTo acOutputReport, "REPORT5", acFormatPDF, "C: AMREPORT REPORT5.pdf"

Gday Guys,

I have a question regarding the OutputTo Cmd?
THis is what i have

DoCmd.OutputTo acOutputReport, "rptInvoice", acFormatRTF, "Bbcg1-jacquifPersonalData TrackingInvoices" & Inv & ".rtf"
Where Inv has been set as a path to a form

Now how do i get another directory under invoices to be created and the file to be stored in from my form? so i want the name of the directory to be the customer name on my form? any ideas?


I'm doing something new here -- well, new for me anyway. And I'm far from a network guru so I need to know if this can even be done.

I'm trying to drop a .doc file (report) into our fax software (LightningFax). In testing I dropped the .doc file into the same folder as the Access database on my own machine, and it worked fine:

stReportName = "C:FAXFax" & rs3.Fields("NextReportNo").Value & ".doc"
DoCmd.OutputTo acOutputReport, "Fax Report", acFormatRTF, stReportName, False

But then I changed it to go to the folder on the server where LightningFax needs to find it:

stReportName = "prxwebfaxreportFax" & rs3.Fields("NextReportNo").Value & ".doc"
DoCmd.OutputTo acOutputReport, "Fax Report", acFormatRTF, stReportName, False

It still dropped it into the same folder as before on my own machine.

Can this even be done? Should it work? If it should work, and its not, is it a network configuration problem?

Thanks in advance for any help anybody can provide.


Hi guys,

I starting to do a lo of exporting to word now. problem is i've forgotten how i did i before.

I can open a word doc and export items i need through code. but I kow that I can export full reports to word using

DoCmd.OutputTo acOutputReport, lettersource, acFormatRTF
but the acformatRTF is no good for me I'm sure that I've exported to .doc before but acformatmsword isn't the option.

Does anyone know how i do this.

It save a lot more time than doing the VBA for CreateObject("Word Application") etc etc.

To clarify : in one of my reports I have and OLE Class word200 embeded object full of text I need to export to word. RTF looses this.


I currently have a database that is running code that is hiding the database window when it is being run.

On the close trigger for my form I'm tring to output two reports:

Filename = ".OldBooks.SNP"
DoCmd.OutputTo acOutputReport, "rOldBooks", acFormatSNP, Filename, False

Filename = ".testReport.SNP"
DoCmd.OutputTo acOutputReport, "rBarCodeList_2Col", acFormatSNP, Filename, False

What is happening is the first report is outputting but the second one is not. When I run the debugger when the program tries to run the second OutputTo I am getting the following error message:

Runtime error '2046'

The command or action 'OutputTo' isn't avaliable now

I have tried switching the order of the DoCmd's and have recieved the same result

Any idea to why I may be getting this message, what it may means or how to correct it?

Not finding an answer? Try a Google search.