Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    renaming a file from Access (access 2003)

    I'm trying to import a file from my c: drive into an access db. I used code to build a transfertext module to import the .txt file. We have a system which generates the file with a period in the name of the .txt file. Access will not allow the .txt to be imported into a table unless I rename the file without the period in the file name. Is there a way I can rename this file from access so I can add this to my module to load the file. Does anyone have a solution for this? Thank you for this..


    File name: Today.run.txt Required name Todayrun.txt

    File location: C:temp

  2. #2
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: renaming a file from Access (access 2003)

    Don't know if there is a rename command

    How about:

    FileSystemObject.CopyFile "C:tempToday.run.txt", "C:tempTodayrun.txt"

    HTH, John

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: renaming a file from Access (access 2003)

    Try
    <code>
    Name "C:tempToday.run.text" As "C:TempTodayrun.txt"</code>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: renaming a file from Access (access 2003)

    John,

    Your code requires that you have created an object of type Scripting.FileSystemObject, and you shouldn't use FileSystemObject as name for that object.

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: renaming a file from Access (access 2003)

    Check the Name command in VBA, this renames a file.

    Name FromFilename ToFilename

    you may have to put a comma betwen the 2 filenames.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: renaming a file from Access (access 2003)

    The syntax for the Name instruction is

    Name OldName As NewName

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: renaming a file from Access (access 2003)

    Thanks for reminding me of Visual Basic Help, Contents Tab, Visual Basic Language Reference Chapter

    I usually use Answer Wizard and Index Tab for answers, problem is if you donít know proper nomenclature you come up short.

    John

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •