Docmd.OutputTo fails

L

Leif

I have an OutputTo command that fails when executed from an autoexec
function. The following is the command:

attach(0) = "c:\temp\Delinquent.snp"
DoCmd.OutputTo acOutputReport, "rptEmpDelinquent", acFormatSNP, attach(0)

The command works fine if executed once the database is "fully up".
However, if I place the command in an Autoexec routine I get the message:

Run-time error '2046':
The command or action 'OutputTo' isn't available now.

Anyone know why? Is there a work around? I would like to be able to fire
this off automatically after the user logs in.

Regards,
Leif
 
D

Damian S

Hi Leif,

If you want to do it automatically after the user logs in, perhaps you could
fire it from the on open of a splash screen that welcomes the user, that way
they only see that screen once when they log in, and you will get away from
using an autoexec macro.

Set your splash screen to be teh startup form of the database...

Hope this helps.

Damian.
 
D

Dave K

What is the source of the data for your report?
I have just tried to recreate this on a db and it works fine and outputs the
rpt. The only thing i can think of without any other info is that the source
data could either be from a linked table (the least likely reason) or ODBC
source like SQL etc.

Do you have any other code that runs from your first load form? could there
be any code that connects your db to another system?

If so i would simply try adding to the vb code after that point rather than
in the autoexec.

HTH
-Dave-
 
L

Leif

Thanks for your reply. I've found the following work around works:

attach(0) = "c:\temp\Delinquent.snp"
' The following two lines are a work around to an error in Access
DoCmd.Echo False
DoCmd.SelectObject acTable, , True
DoCmd.OutputTo acOutputReport, "rptEmpDelinquent", acFormatSNP, attach(0)
' The following two lines are a work around to an error in Access
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide

Regards,
Leif
 
L

Leif

Thanks for your reply. I've found the following work around works:

attach(0) = "c:\temp\Delinquent.snp"
' The following two lines are a work around to an error in Access
DoCmd.Echo False
DoCmd.SelectObject acTable, , True
DoCmd.OutputTo acOutputReport, "rptEmpDelinquent", acFormatSNP, attach(0)
' The following two lines are a work around to an error in Access
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide

Regards,
Leif
 

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