Solved

Strange problem with exporting access report in pdf format

Posted on 2016-11-18
4
40 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
[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
4 Comments
 
LVL 8

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

752 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