By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,124 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

Renaming .xlsx File in Folder Location using Variable

P: 11
Windows 7, Access 2010 32-bit

I have exported a file to the following path and name:
h:\main\test\todaysdatafile_currdata.xlsx

Once exported, I am trying to rename it as follows (using the NAME command):
h:\main\test\mapfile_mmddyy.xlsx where the mmddyy reads a control field on the form that is equivalent to the current date in the mmddyy format.

I get everything in my results but the mmddyy variable.

Any suggestions?

Kindest regards,
A12help
Nov 7 '12 #1

✓ answered by NeoPa

Try :
Expand|Select|Wrap|Line Numbers
  1. Name "h:\main\test\todaysdatafile_currdata.xlsx" As _
  2.      "mapfile_" & Format(Date(), "mmddyy") & ".xlsx"
Todays date is always available from the Date() function but it should be formatted explicitly if you want to be sure of it coming out in the right way.

Share this Question
Share on Google+
5 Replies


zmbd
Expert Mod 5K+
P: 5,287
A12... as in your other post... we need to see your code.
Please format it using the <CODE/> button once posted.
Nov 7 '12 #2

P: 11
Expand|Select|Wrap|Line Numbers
  1. DoCmd.RunSavedImportExport "Exp_SF Map File"
  2. Name "h:\main\test\todaysdatafile_currdata.xlsx" As "h:\main\test\mapfile_mmddyy_" & ctlFileDt & ".xlsx"
Nov 7 '12 #3

NeoPa
Expert Mod 15k+
P: 31,261
Try :
Expand|Select|Wrap|Line Numbers
  1. Name "h:\main\test\todaysdatafile_currdata.xlsx" As _
  2.      "mapfile_" & Format(Date(), "mmddyy") & ".xlsx"
Todays date is always available from the Date() function but it should be formatted explicitly if you want to be sure of it coming out in the right way.
Nov 7 '12 #4

P: 11
NeoPa,

Thanks so much; I knew it would be something simple.

When I created the ctlFileDt field on the form, I did all of the date formatting there thinking the code could just read that field. I did not think about dumping the formatting piece directly into the code. I tried and this works great.

Sincerely appreciate the help.
Nov 7 '12 #5

NeoPa
Expert Mod 15k+
P: 31,261
Not a problem. It's good to be able to help :-)
Nov 7 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.