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

Export report with the current date in the file name

Status
Not open for further replies.

blindlemonray

Technical User
Nov 24, 2003
130
GB
I am looking to export a report into a folder but would like to add the current date to the file name i.e "User_Date.snp", but am having some problems.

I got to:-

Code:
    DoCmd.OutputTo acReport, "user", acFormatSNP, "G:\Folder\User " & Date, False, ""

But I get a run time error 2024 not enough space blah blah but this is not the case.

I looked at thread thread703-1250025 but this does not seem to solve my problem.

Any suggestions much appreciated.
Cheers
[peace]
 
I just played with this, and looked at the string it's making when trying to save the file, and it comes out as for example

\\serverpath\sharepath\USER-12/19/07.snp

which it doesn't like, obviously. So try formatting the data without slashes, something like:

Code:
Dim strName As String
strName = "\\serverpath\sharepath\USER-" & Format(Date, "mmddyyyy") & ".snp"
DoCmd.OutputTo acOutputReport, "A1", acFormatSNP, strName, False

Then the file name is
USER-12192007

and it works fine.

Next time try putting in Debug.print or MSGBOX to see the string it's creating for you, it could hold a clue to the issue.

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Hi GingerR,

I had just figured this code:-

Code:
Dim Stname As String
Stname = "G:\Folder\user " & ddmmyy
DoCmd.OutputTo acReport, "User", acFormatSNP, Stname, False, ""

Which works..now problem is it comes out with no file extension!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top