Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OutputTo Problem

Status
Not open for further replies.

bxgti4x4

Technical User
Feb 22, 2002
167
GB
I have created a report which prints out, emails itself to specific people and then saves itself as a *.RTF file on my C Drive. This works perfectly well but I have to specify the whole path to the file I want. I would like to save the file in a specific folder with the current date as the file name i.e:

"n|\access\daily_updates\17th_November_03"

The code I am using is as follows:

Code:
Private Sub Print_Operations_Status_Report_Click()
On Error GoTo Err_Print_Operations_Status_Report_Click

    Dim stDocName As String

    stDocName = "operational_status"
    DoCmd.OpenReport stDocName, acNormal
    
    stDocName = "operational_status"
    DoCmd.OpenReport stDocName, acNormal
    DoCmd.RunMacro "email operational status"
    DoCmd.OutputTo acReport, stDocName, "RichTextFormat(*.rtf)"

Exit_Print_Operations_Status_Report_Clic:
    Exit Sub

Err_Print_Operations_Status_Report_Click:
    MsgBox Err.Description
    Resume Exit_Print_Operations_Status_Report_Clic
    
End Sub

I assusme that the "DoCmd.OutputTo acReport" is the right code to use and would be grateful if someone could advise the way of completing this statement so that it does what I want.

Thanks a lot
John
[ponder]
 
John,

Try this:

strdestination = "C:\folder\"
strdate = format(date(),"DDMMMMYYYY")

DoCmd.OutputTo acOutputReport, strReportName, acFormatRTF, strDestination & strDate & ".rtf"

Ian
 
Ian,

Thanks for the very prompt reply. I have tried this but I keep getting a message:

"The Object Type argument for the action or method is blank or invalid"

I have substituted "n:\access\daily updates\" for your "C:\folder\" statement and changed strReportName to strDocName" because that is what was specified earlier. It looks like I've missed something somewhere.

John
 
Try:
Code:
strDest = "N:\Access\Daily_Updates\" & Format(Date, "DD MMMM YY") & ".rtf"
DoCmd.OutputTo acReport, stDocName, "RichTextFormat(*.rtf)", strDest
Although I would suggest formatting the date "YYYY-MM-DD" so that the dates are sorted into ascending order. Otherwise it can be a real pig trying to find files.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
Andy,

This worked a treat. Thanks very much for your help.

Best Regards
John
[2thumbsup]
 
Glad to help.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top