Lee Mac
Lee Mac

Reputation: 16015

'No Current Record' Error when Outputting Report to PDF from Batch File or Task Scheduler

The Problem

I'm using a scheduled task to open an MS Access database, run a macro to email a report in PDF format, and then close the database. The report is relatively basic and the macro simply uses the EmailDatabaseObject action to export & email the report in PDF format.

This has been running successfully on a daily basis for the past 4 years on a Windows 7 machine running the latest version of Office 365 compatible with Windows 7.

I've recently updated the machine to Windows 10 and I'm now encountering a No Current Record error when running the scheduled task. After clicking OK to the error several times, Windows reports that MS Access has stopped working and the application crashes.

If I manually open the database and manually run the macro, everything is successful.

Setup

My Research

What I've Already Tried

Current Workaround

I've found that this error only arises when the export format is set to PDF; as such, my current workaround is to export the report to RTF format - but this is obviously not ideal.


Update

I've now systematically removed items from the report until I was able to run the report successfully from the scheduled task.

I removed items until I was left with a single static label in the Report Header and a set of fields in the Report Detail referencing basic numeric & text data from a single table in the database.

Removing the Report Header & Footer resulted in the report running successfully from the scheduled task, and so I determined that the issue must be caused by a setting associated with the Report Header/Footer.

I isolated the issue to the 'Force New Page' setting in the Report Header:

enter image description here

With this set to 'After Section', the report crashes; but if this is set to 'None', the report is successful.

However, when setting this to 'None' in the original report, the report still crashes when run from the Task Scheduler and output to PDF.

Steps to Reproduce the Problem

I've uploaded an incredibly basic database here, containing a single table, a single report, and a single macro which executes the ExportWithFormatting action followed by the QuitAccess action.

To reproduce the problem, open a command prompt window and issue the following commands:

cd C:\Program Files (x86)\Microsoft Office\root\Office16
msaccess.exe C:\YourPath\test.accdb /x macro1

MS Access should then open and you may be presented with the 'No Current Record' error.


Has anyone else encountered this issue and knows of a solution?

Many thanks for your time.

Upvotes: 2

Views: 505

Answers (0)

Related Questions