Results 1 to 5 of 5
  1. #1
    mgilbert86 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    9

    Post VBA Importing Text File - Error 3011 - File name has two extensions

    Hello,



    I am writing VBA module that imports a text file that has two extension names (.tsv.csv).

    When the system is trying to find the file, I get error 3011 and it shows me that the file name being searched for stopped at ".tsv."

    The microsoft access database could not find the object "FileName20150907.tsv."


    Here is the code:

    Dim Monday As String


    Monday = Forms!Form!Text34

    Dim ExtractFile As String
    ExtractFile = Dir$("C:\\Folder\FileName" & Monday & "*.tsv.csv")


    DoCmd.TransferText acImportDelim, "Spec", "Extract File", ExtractFile, True

    Any Ideas on how to fix?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Rename the file.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mgilbert86 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    9
    Quote Originally Posted by June7 View Post
    Rename the file.
    We have a team that adds a .csv extension on to the files and posts them out to a folder in our shared drive. Problem is, if the user has to go out and rename the file, it would be easier then to just have them manually upload the text file and skip the vba importing the file for them. Is there not any work around within vba to deal with a file with this name?

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    We have a team that adds a .csv extension
    Can't they alter their process to CHANGE the extension as opposed to adding a new one (seems like a really bad practice)?

    If not, you may be come up with VBA script that will do that for you (rename the files first).

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Options:

    1. have the team properly name the file - just have to change the tsv to csv instead of appending csv

    2. VBA to rename the file - example of renaming a single file: Name "C:\Temp\MyFile.tsv.csv" AS "C:\Temp\MyFile.csv"
    Why do you have * wildcard in the file name? I don't think Access can deal with that in the import operation.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error when importing text file
    By narendrabr in forum Import/Export Data
    Replies: 1
    Last Post: 01-11-2013, 03:27 AM
  2. Importing a text file
    By crowegreg in forum Import/Export Data
    Replies: 2
    Last Post: 09-18-2012, 12:51 PM
  3. Importing A Text File
    By steve2507 in forum Access
    Replies: 5
    Last Post: 02-28-2012, 01:48 AM
  4. Importing a text file
    By Kurs in forum Access
    Replies: 11
    Last Post: 02-20-2012, 02:26 PM
  5. Error 3027 when importing text file
    By tym in forum Access
    Replies: 4
    Last Post: 12-12-2011, 12:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums