Results 1 to 3 of 3

Trouble importing .txt file without a header row (first row is skipped upon import)

  1. #1
    Bcanfield83 is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    72

    Question Trouble importing .txt file without a header row (first row is skipped upon import)

    Hi all,
    I have a fairly basic .txt file that I'm trying to import into my database. To start, I do what I normally do and select (in MS Access) External Data | Text File


    After selecting the .txt file that I'm importing, I selected the "Delimitted" method since all of the fields on the .txt file are separated by the "|" delimitter.
    Then, I clicked the "Advanced" button to create an Import Specification based upon the field names in the table that this file will be imported into.
    The issue I'm running into is that there is no header row on the .txt file - the first row on the file is literally the first record that should be imported.
    I've confirmed that the "First Row Contains Column Names" option is unchecked when I save the Import Specification. So in theory, it shouldn't be skipping that first row under the assumption that it's a header row.. but it still does nonetheless.

    I found another thread about this same issue, but haven't yet stumbled upon a solution other than manually importing it. My intent though is to have the file import upon clicking a button in a form - the OnClick event behind the button links to a VBA procedure which uses the DoCmd.TransferText acImportDelim method, in which I'd also reference the corresponding Import Specification. I'm already doing something like this for other .txt files - but this is the first one I've run into where there's no header row on the .txt file itself, and thus it's skipping over that row while importing it. :-\
    https://answers.microsoft.com/en-us/...2-40012ffa923b

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,440
    the docmd.transfertext has a switch for 'has field names', if you don't explicitly set that to false it will assume you do.

    i.e.

    docmd.transfertext acimportdelim, "specname", "tablename", "filename", FALSE

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    8,454
    The last post in the link you posted explains how to fix the problem.


    In the mean time, have you considered just adding a blank line at the top of the txt file? Don't know how many files you have to import of how often, but is would/could be a quick fix temporarily.
    HTH
    -----
    Steve
    --------------------------------
    "Veni, Vidi, Velcro"
    (I came; I saw; I stuck around.)

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

Similar Threads

  1. How do I Save/Import .txt file name to Access when importing?
    By PJ Crittenden in forum Import/Export Data
    Replies: 3
    Last Post: 11-05-2014, 07:40 AM
  2. Trouble importing/linking dbase file
    By MarshaPav in forum Import/Export Data
    Replies: 3
    Last Post: 12-12-2013, 12:59 PM
  3. importing header and body information from text (csv) file
    By JamesL in forum Import/Export Data
    Replies: 6
    Last Post: 04-10-2012, 09:47 PM
  4. Importing CSV file into 2010/creating save import routine
    By rbtrout in forum Import/Export Data
    Replies: 5
    Last Post: 08-05-2011, 08:54 AM
  5. Importing Excel file. (2 non numeric values won't import)
    By Amerigo in forum Import/Export Data
    Replies: 3
    Last Post: 05-20-2011, 11:31 AM

Tags for this Thread

Posting Permissions

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