Jim M
asked on
"No Current Record" error - Exporting report from macro called from batch file
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
"I hate autoexec macros, "
Why?
Why?
ASKER
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???
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???
That is a very unusual record to be associated with a Report.
Are you positive there is no other code running here ?
mx