Command not available

S

Steve

I have an Access program that compiles a handful of information then exports
reports to Excel for users. I have an issue where the program executes and
outputs report#1 to Excel, the next step is to output report #2 - however I
get an error "the command or action outputto is not available" when the 2nd
report tries to kick off.

I have tried moving some of the program functions so that something else
happens in between report #1 and #2 figuring that the outputto action
perhaps needed additional time to finish - ie, I changed the program so
deleting some temp tables and such occurred after report#1 and before
report#2, but I still got the same error.

I didn't have any program functions to insert that took a great deal of
time, so my next thought was that perhaps there still wasn't enough time for
the first outputto action to complete - so I inserted first a 5 minute wait
before the next outputto command, however still no luck and same error. I
have adjusted the wait between reports all the way up to 30 minutes with no
difference - still the outputto not available error.

Can anyone offer any help?
 
C

Can you post a sample of your code

Steve said:
I have an Access program that compiles a handful of information then exports
reports to Excel for users. I have an issue where the program executes and
outputs report#1 to Excel, the next step is to output report #2 - however I
get an error "the command or action outputto is not available" when the 2nd
report tries to kick off.

I have tried moving some of the program functions so that something else
happens in between report #1 and #2 figuring that the outputto action
perhaps needed additional time to finish - ie, I changed the program so
deleting some temp tables and such occurred after report#1 and before
report#2, but I still got the same error.

I didn't have any program functions to insert that took a great deal of
time, so my next thought was that perhaps there still wasn't enough time for
the first outputto action to complete - so I inserted first a 5 minute wait
before the next outputto command, however still no luck and same error. I
have adjusted the wait between reports all the way up to 30 minutes with no
difference - still the outputto not available error.

Can anyone offer any help?
 
S

Steve

sample code:

strfn = "\\server\share\directory\filename" & ".xls"
strfn1 = \\server\share\directory\filename1 & ".xls"
stDocName = "rpt1"
stDocName1 = "rpt2"
DoCmd.OutputTo acReport, stDocName, acFormatXLS, strfn, False
DoCmd.OutputTo acReport, stDocName1, acFormatXLS, strfn1, False

The first docmd line runs fine and outputs my excel file #1. The resulting
excel file is complete and usable. The second docmd line results in the "the
command or action outputto is not available". Again, I have tried insert
some miscellaneous commands inbetween the two docmd lines, but it had no
effect and resulted in the same error. I also created a wait cycle and
started testing with a 5 minute wait up to a 30 minute wait in between the 2
docmd lines - no effect, same error. I have inserted program breaks and
single stepped through and any commands not dealing with the reports or
output excel files function and complete, but when I hit the next docmd line
above then same error.



"Can you post a sample of your code" <Can you post a sample of your
(e-mail address removed)> wrote in message
 
6

'69 Camaro

Hi, Steve.

Your code is missing double quotes at the beginning and end of a string
literal. Change the following line of code:

strfn1 = \\server\share\directory\filename1 & ".xls"

to:

strfn1 = "\\server\share\directory\filename1" & ".xls"

There's no need to add a time delay between the outputs of the reports.

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
 
S

Steve

That was a typo in my cut and paste where I changed my actual server info.
Thanks though!

I suppose I have found a work around to the problem, but I really don't
understand why this would work and a normal method would not.

My original code was:
After line1, line2 resulted in a "the command or action outputto is not
available". I tried inserting a pause of up to 30 minutes between the lines
and I could single step through and see the pause executed, but same error
as soon as it hit the report line. I also tried rearranging some code so
that I did some maintenance items in between such as removing temp tables,
etc. Same deal - single stepped through all of that but hitting the 2nd
report line produced the same error.

My workaround that so far seems to function is this:

I output report #1 and the next command opens a second form who's load
procedure outputs report #2. So far this seems to work, but I am baffled why
I couldn't get both reports to output from the same form. Essentially my
new code is simply

DoCmd.OutputTo acReport, stDocName, acFormatXLS, strfn, False
docmd.openform("frm2nd")
DoCmd.OutputTo acReport, stDocName1, acFormatXLS, strfn1, False
 
J

John Nurick

Did you include a DoEvents in your "wait" loop? if not, what happens if
you substitute
DoEvents
for
docmd.openform("frm2nd")
?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top