need help exporting a report and setting the location of the file...

K

Kelvin Beaton

This code acts like it's running. It scrolls through the pages anyway.
DoCmd.OutputTo acOutputReport, "rpt_OutreachContact-Report", "Rich Text
Format (*.rtf)", "Outreach Contact - Report.rtf"

When I rerun it, it doesn't ask if I want to over write the old file.
And I don't know where it's putting the file...

I thought I could put the file on the desktop by adding this "C:\Documents
and Settings\%username%\desktop\" but no luck.
DoCmd.OutputTo acOutputReport, "rpt_OutreachContact-Report", "Rich Text
Format (*.rtf)", "C:\Documents and Settings\%username%\desktop\Outreach
Contact - Report.rtf"
It says "... can't save the output data to the file you've selected."

Can someone help me export this report?

Thanks

Kelvin
 
D

Douglas J. Steele

Take a look at http://www.mvps.org/access/api/api0054.htm for how to
retrieve the location of special folders. Copy everything between Code Start
and Code End into a new module (not a class module, nor a module associated
with a form), and save it.

You'd then use:

DoCmd.OutputTo acOutputReport, "rpt_OutreachContact-Report", _
"Rich Text Format (*.rtf)", _
fGetSpecialFolderLocation(CSIDL_DESKTOPDIRECTORY) & _
"\Outreach Contact - Report.rtf"

Alternatively, you could use the Environ function to give you the value of
%username%:

DoCmd.OutputTo acOutputReport, "rpt_OutreachContact-Report", _
"Rich Text Format (*.rtf)", _
"C:\Documents and Settings\" & Environ("username") & _
"\desktop\Outreach Contact - Report.rtf"

However, I don't really recommend the second approach, in case the actual
desktop folder location is non-standard.
 
D

dbahooker

Douglas is a known troll for whom the only answer is MDB, regardless
of the question
 

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