Renaming .xlsx File in Folder Location using Variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • A12help
    New Member
    • Oct 2012
    • 11

    Renaming .xlsx File in Folder Location using Variable

    Windows 7, Access 2010 32-bit

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

    Once exported, I am trying to rename it as follows (using the NAME command):
    h:\main\test\ma pfile_mmddyy.xl sx 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
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    A12... as in your other post... we need to see your code.
    Please format it using the <CODE/> button once posted.

    Comment

    • A12help
      New Member
      • Oct 2012
      • 11

      #3
      Code:
      DoCmd.RunSavedImportExport "Exp_SF Map File"
      Name "h:\main\test\todaysdatafile_currdata.xlsx" As "h:\main\test\mapfile_mmddyy_" & ctlFileDt & ".xlsx"

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        Try :
        Code:
        Name "h:\main\test\todaysdatafile_currdata.xlsx" As _
             "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.

        Comment

        • A12help
          New Member
          • Oct 2012
          • 11

          #5
          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.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32633

            #6
            Not a problem. It's good to be able to help :-)

            Comment

            Working...