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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically inserting date in file name ?? 1

Status
Not open for further replies.

Pugs320

Technical User
Jan 29, 2002
19
US
This is a great site to learn and interact with others and know that I am not the only one with QUESTIONS. Here is my question and I don't know if it is possible!!

I work for a company that does business with a division of the government. As such , we are subject to periodic auditing of our business. I run reports on a daily basis gathering info from vaious DB's and tables, 27 daily reports total. I am with this co. for a short period of time and am now in the process of automating these reports through Macros. I save these reports to a file as <FileName_date.rtf>. The Macros works great but I need to input the date part of the file name manually. This can get tedious with the number of reports that are run. Does anyone know code that will put the date in the file name automatically? I am running Access 97. I appreciate any help or direction.

Andy
 
If you are using the Save action in the macro in the File Name argument try
&quot;FileName&quot; & Date() & &quot;.rtf&quot;

Replace &quot;FileName&quot; with whatever your file name is.

Paul

 
I tried this Paul but no luck. I also tried a couple of variations with and without quotations but I keep on getting an error msg.
 
The message is like this:
Can't save the output data to the file you selected.


*The file may be open. If so close it, and then save the output data to the file again. Yada, Yada, Yada


Andy
 
Another point, I am using the &quot;OutputTo&quot; Action in my Macro

Andy
 
You should verify if the name of the file you created as &quot;/&quot; in it due to the Date() function.

This might be the cause of the error.

Hope it helps!

Salvatore Grassagliata
 
That is something I didn't think of. It may be worth trying.
It would look like this.

&quot;FileName&quot; & Format(Date(),&quot;mmddyy&quot;) & &quot;.rtf&quot;

Paul

 
I tried this and I get the same error msg I got B4

Andy
 
What arugment are you putting the current <FileName_date.rtf>
in. Is it the Object Name argument or the Output File argument.

Paul
 
I am putting it into the &quot;Output to&quot; action.

Andy
 
This worked fine for me, but I am on Access2000

DoCmd.OutputTo acOutputTable, &quot;superform&quot;, acFormatRTF, &quot;c:\bobbyr3&quot; & Format(Date, &quot;mmddyy&quot;) & &quot;.rtf&quot;
 
Rollo58,

I took your code and tried a couple of things. I was thinking on a much lower level than you, I was thinking MACRO. This code is working the way I wanted it to. THANK YOU for your help

OutputTo acOutputReport, &quot;FileName&quot;,acFormatRTF, &quot;J:\FileName&quot; & Format(Date - 1, &quot;mmddyy&quot;) & &quot;.rtf&quot;, True

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top