Solved

Strange problem with exporting access report in pdf format

Posted on 2016-11-18
4
28 Views
Last Modified: 2016-11-23
Access 2013 (accdb format) database.

I have to following code to open an access report in preview, export to pdf and then close the report (the szWhere is a filter string):
    'Preview the report
    DoCmd.OpenReport szDocName, acViewPreview, , szWhere
    
    '*****************************************************************************************
    DoCmd.OutputTo acOutputReport, , acFormatPDF, szFileName, False
    '*****************************************************************************************
    
    DoCmd.Close acReport, szDocName

Open in new window


In development it works perfectly.  In the production environment this code has stopped working.  It has been working for ca 18 months without problem.  It fails on the OutputTo line.
Interestingly on the production PC if a report is opened in preview mode manually, then the export to pdf/xps option chosen the report is exported without problem.

I'm stuck - the functionality works when run manually but not automatically.  Any ideas as to what the problem could be and how to get it working again.
0
Comment
Question by:AndyAinscow
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Anders Ebro (Microsoft MVP)
ID: 41892758
If I had to guess it could be a timing thing. I think the docmd works on the active object, if you haven't specified an object by name. Try being explicit about which opject to export:
 DoCmd.OpenReport szDocName, acViewPreview, , szWhere
    

    DoCmd.OutputTo acOutputReport,szDocName , acFormatPDF, szFileName, False

Open in new window

0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 0 total points
ID: 41892807
I have tried that but it didn't make any difference.  :-(

Found it.  For some reason the destination folder had been deleted !!  Creating it cures the problem.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41893238
I had this recurring problem before and prevented it from happening by adding codes to check if the folder exists and if it don't exists, create the folder before running the codes.
0
 
LVL 44

Author Closing Comment

by:AndyAinscow
ID: 41898885
Missing folder.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

823 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