Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2008
    Posts
    3

    Unanswered: Access Import Trouble: hasfieldnames:=True

    Hello everyone. I have some VBA code setup to create a new table and import a text file to it. The field names of the table need to change about every 30 days, so I parse the text file to grab the appropriate names. All of the text files I work with are tab delimited.

    The problem comes when I try to import the text file using the condition hasfieldnames:=True. Instead of parsing through the field names using a tab delimiter, Access joins them together using an underscore.

    For example, the text file has field names of Store State County City. When I try import the text file, Access gives an error saying the column Store_State_County_City cannot be found in the table.

    The field names in the table exactly match the field names in the text file. I cannot use an import specification because the field names need to remain dynamic.

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    The field names in the table exactly match the field names in the text file.
    You can ignore the field names in the first record's import then
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    "maybe" this example might help: http://www.dbforums.com/showpost.php...6&postcount=24

    It's worth looking at and you could modify it to meet your needs as I doubt it exactly fits your needs but again, may be worth looking at (it let's you toggle between saying yes or no to field names and it is csv based but give it a try on a csv file even though you're working with tab delimited files.) But you may be able to use the browse for the file part of it.

    I'm guessing though you'll most likely need to design 1 or 2 import specifications (ie. 1 with field names and 1 without) since it doesn't sound like the import file is comma separated compatible (which would be ideal).
    Last edited by pkstormy; 08-29-08 at 12:20.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Aug 2008
    Posts
    3
    Quote Originally Posted by StarTrekker
    You can ignore the field names in the first record's import then
    I believe if you do this then Access automatically assigns F1, F2, F3...etc as your field names for the import.

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by ledzep227
    ...The field names of the table need to change about every 30 days, so I parse the text file to grab the appropriate names....
    smells a bit fishy to me.... that means a redesign every month, new queries at the very least.
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Aug 2008
    Posts
    3
    Quote Originally Posted by healdem
    smells a bit fishy to me.... that means a redesign every month, new queries at the very least.
    I will have to tweak the query pulling the info every month in order to accommodate a change in promotional products. However, I want to avoid having to change information in more than one place. Get it?

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by ledzep227
    I will have to tweak the query pulling the info every month in order to accommodate a change in promotional products. However, I want to avoid having to change information in more than one place. Get it?
    in short No....
    it doesn't sond right, the design doesn't sound normalised to me.
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    ▲ Agreed.

    Quote Originally Posted by ledzep227
    I believe if you do this then Access automatically assigns F1, F2, F3...etc as your field names for the import.
    Not if your table already exists.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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