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

Add date and timestamp to export file created in Access 1

Status
Not open for further replies.

ajv

IS-IT--Management
Jul 10, 2001
9
US
We have several MS Access applications where we create text files from MS Access. We use macros to create the output file. However each new file overwrites the previous one. Can someone help with either VBA code or Access query that would add the data and time stamp to the output file name.

Example: Text file created is output.txt
Would like to add data and time so file name would be
20030224_output.txt

Doing this in UNIX is easy but how do I do this in a MS environment?.

Thanks.
 
the VBA code would be:

Function MakeTimeStampFileName(InputName As String) As String
Dim DotPos As Integer
DotPos = InStr(InputName, ".")
MakeTimeStampFileName = Left(InputName, DotPos - 1) & "_" & Format(Now, "YYYYMMDD") & Right(InputName, Len(InputName) - DotPos + 1)
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top