Error when importing text file into Access?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hclifford
    New Member
    • Oct 2014
    • 3

    Error when importing text file into Access?

    Hi all,

    I have been having this problem whereby after using the import function of Access, my text file actually gets reordered. Meaning the rows are all jumbled up and different from what is displayed on my text file. Is this because my text file contains too many lines (500000+) so Access has difficulty importing it?

    How do I work around this?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You can't guarantee the order of rows in a table unless you write a script to process the text file line by line. Which can take a long time to process if you have a lot of data.

    Comment

    • hclifford
      New Member
      • Oct 2014
      • 3

      #3
      Hi Rabbit,

      Can you provide me with an example of the code that will be able to help me?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        An example wouldn't be much help because the bulk of it would change depending on the file layout. But the basic steps are:

        1) Read a file line by line
        2) Break out the line into the fields you need (this is where the bulk of the code would be and also where the changes are depending on the layout)
        3) Insert that row of data into the database table with an autonumber field.

        Steps 1 and 3 are fairly standard. Number 2 is where there are lots of changes depending on your file layout.

        Comment

        Working...