Results 1 to 4 of 4
  1. #1
    NewtoIT is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    11

    Import issue with irregular text file

    Sorry, I posted this in General questions by mistake.I have the below text file sample named NOTE.txt. It seems that the info was entered into a memo field and ctrl + enter has been used. I use pipe delimited with no text qualifier and I cannot get Access to import it correctly. Of course the 3 fields are NOTE_ID, NOTE_IDB and NOTE_TEXT. Line 1001 imports fine. Lines 1002 and 1003 start fine, then mess up. Line 1004 and 1005 import fine. Can anyone help or offer some VBA code to do this import?

    NOTE_ID|NOTE_IDB|NOTE_TEXT
    1001|1297|STANDING ORDERBEGINNING 5-11-98 ENDING 4-30-99 SHIPPING 1 EVERY 2 WEEKS
    1002|1297|STANDING ORDER
    BEGINNING 11-11-98
    ENDING 11-11-99
    SHIPPING;
    10CS ITEM 1 WEEKLY
    3CS ITEM 2 WEEKLY
    3 CS ITEM 3 10% WEEKLY
    DELIVER TO John Doe
    REF P.O.ABC456


    VERN
    1003|1297|PRINTERS ARE TO BE USED FOR STAR, CERNER APPOINTMENTS, AND ESI.
    NET 30 DAYS. FOB TMC DOCK,
    WARRANTY 1 YEAR ONSITE PARTS AND LABOR.
    1004|1297|DELIVER TO Janie Doe IN DND OFFICE. THANKS AL
    1005|1297|PLEASE DELIVER TO DEPT DEPARTMENT

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Here is example of code to import a simple text file http://www.bigresource.com/Tracker/Track-vb-zAjbnMPyEv/. Your situation will require testing each line for the pipe character and handling as needed.
    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
    NewtoIT is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2011
    Posts
    11
    Thanks June7 for the help but as my moniker would indicate, I am new to IT stuff like this. I thought it might be an easier answer such as DoCmd.TransferText acImport (and the rest that follows here would be pushing my skills some). I went to that page and I understood the question but got lost once the answers started. Can you give me some starting code using C:\MyFiles\NOTE.txt and the field names of NOTE_ID, NOTE_IDB and NOTE_TEXT (all text fields) and a pipe delimiter?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    From the sample in your post, each line is not a complete record. The NOTE_TEXT data is continued on multiple lines. This makes the TransferText method unworkable. Also not possible to set a link to the text file. This leaves the VBA code method that opens the text file and reads each line in a loop structure, parses the line on the delimiter (if present) into an array and saves each array item to appropriate field. The complication is concatenating the multiple NOTE_TEXT lines into a single string.

    You have code example to model from. Attempt adaptation to your situation and post for analysis.

    Here is another thread on topic https://www.accessforums.net/program...ion-23820.html
    Post #2 has couple links you might find of interest.
    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. import text file over 255 fields
    By belmontj in forum Programming
    Replies: 2
    Last Post: 04-29-2012, 01:53 PM
  2. Import Text File
    By vvasudev in forum Import/Export Data
    Replies: 1
    Last Post: 02-17-2012, 01:57 AM
  3. Split Numeric Data out of Irregular Text Field
    By nathanielban in forum Queries
    Replies: 6
    Last Post: 12-21-2010, 10:30 AM
  4. Import text file question
    By sumdumgai in forum Import/Export Data
    Replies: 14
    Last Post: 03-23-2010, 07:59 AM
  5. XML File Import To Access...Overwrite Issue
    By wipers123 in forum Import/Export Data
    Replies: 0
    Last Post: 02-11-2010, 12:27 PM

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
  •  
Other Forums: Microsoft Office Forums