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

Need Access funtion to rename file by appending date to it

Status
Not open for further replies.

newcoder54

Technical User
Jul 2, 2002
46
US
Over my head.

I need an Access function to rename a file and append the current date to it. Ideally from Access I can click a button and it’s all over. I would probably have around 6 buttons that I can click daily to process the 6 files when needed. Wonder if I could even maybe add hour. Thanks much. Larry

For example this:

C:\My Documents\Data.xls
Becomes
c:\My Documents\Data01162004.xls
 


dim somefilename as string
dim somedate as date

someDate=whatever
somefilename="Data"+format$(someDate,"MMDDYYYY")+".xls"
 
Using the formatting above and the Microsoft Scripting Runtime library
[tt]
Dim FSO As New FileSystemObject
Dim File As File
Dim strFile As String

strFile = "your path\file"
Set File = FSO.GetFile(strFile)
File.NAME = "new name"
[/tt]


Turn your headache into my project!
Jeffrey R. Roberts
Insight Data Consulting
Access and SQL Server Development
 
You can also do it a little faster i believe by

fso.CopyFile "c:\Me", "C:\me" & Now() & ".xls", False
fso.DeleteFile "c:\Me"

instead of the FSO.GETFILE

Just use copy and delete of the filesystemobject (add reference)...

Hope this helps,

WZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top