?
Solved

"No Current Record" error - Exporting report from macro called from batch file

Posted on 2010-09-21
5
Medium Priority
?
1,122 Views
Last Modified: 2012-08-13
Hello all,

I have a batch file which calls a macro in Access 2007. The macro is simple; it exports a report to a PDF. It works fine when running from within Access, but throws a "No Current Record" error when running the batch file.

My exact problem is also documented here: http://www.pcreview.co.uk/forums/thread-3990774.php, sans a solution.

The macro has just two actions:

OuputTo: (Report, testreport, PDF Format (*.pdf), C:\TestReport.pdf, No, , 0, Print
Quit: (SaveAll)

I have also tried removing the Quit action but it makes no difference. I also read that it has to do with grouping so I created a non-grouped, non-sorted report and it still fails.

I also converted the macro to VBA and then created a simple RunCode macro calling that function. This time it ran without error (when called from the batch file), however it only exports page 1 of the report; beginning at the top of page 2 it displays #error for each field. This seems to have something to do with the way Access 2007 is reading the records when it prints, I just can't figure out how to get around it.

Thanks in advance,

g8tor
0
Comment
Question by:Jim M
[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
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
fcfang earned 2000 total points
ID: 33730413
Three possible solutions:

- I'm sure you've already tried compacting/repairing the database. If not, try it, if so, does creating a new accdb file and then importing all the objects from the old accdb to the new change anything?

- Secondly, you mentioned that you were able to run the macro just fine manually. Is the scheduled job user you? Maybe a permissions issue?

- Finally, if all else fails, what happens if you rename the macro to autoexec and run the accdb from the scheduled job without the /X email parameter?

Hope any of these help...
0
 
LVL 75
ID: 33730708
""No Current Record" error "
That is a very unusual record to be associated with a Report.

Are you positive there is no other code running here ?

mx
0
 
LVL 2

Author Closing Comment

by:Jim M
ID: 33738362
Thanks for the comments. Apparently "all else" has failed, because making it an autoexec works. That is completely bizarre. I hate autoexec macros, but it is the lesser of evils in this case. Thanks for the help.
0
 
LVL 75
ID: 33738575
"I hate autoexec macros, "
Why?
0
 
LVL 2

Author Comment

by:Jim M
ID: 33739103
Because it means I am obligated to do that autoexec operation when the database is opened. If i have a macro that cleans some data and one that spits out a couple of reports, I can call them independently using the approach I use (command line /x switch). I like that flexibility. If there is an autoexec, then whatever that thing does must be done every time. I'm not saying there isn't significant utility to autoexec macros in many cases, but not for what I am doing. I also don't like having to remember to hold down shift key for this db but not for that one.

Unless there is a way to supress an autoexec macro when calling another macro from a command line switch??? basically a command line version of holding down the shift key???
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

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