Updating a table from TXT file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tdw
    New Member
    • Mar 2007
    • 206

    #1

    Updating a table from TXT file

    Hi all,

    I have several ideas on how to do this, but am having difficulty putting the ideas together and figuring out the most efficient way to do this.

    I have a database of survey coordinate points. These records are imported from a txt file, and never manually entered. Currently there are no forms at all.

    The first problem is that the txt file continually gets updated by a CAD program.
    The second problem is that there is one extra field in the database that is not a column in the txt file: DATE. The date for each record gets manually entered into the database table. This date represents the date that the GPS coordinate was recorded in the field.

    So, what I want to do is create a process in a new form that will do the following:
    1. Select the txt file to import (I have already created this part).
    2. Import the data (either replacing ALL of the records, while leaving the DATE fields alone, or finding all changes in the txt file and updating the table to reflect them, again leaving the DATE field alone.)
    3. Prompt the user to add dates to the records that do not have one, preferably by allowing the user to enter a range of coordinate point numbers (the primary key of each record) to add a certain date to.
    (I could probably figure step 3 out for myself. Just haven't done so yet.)

    Any thoughts, especially on step 2?
    So far I have been looking at PopulatePartial Method, PartialReplica Property, ReplicaFilter Property, Synchronize Method, CreateTableDef Method (for creating a new table based on the txt file and then maybe trying to update the original table based on the new one, then delete the new one? I don't know.)

    Again, I would always need the table to update to reflect any additions or changes to the txt file, while retaining the dates for each record. Sometimes existing records (coordinate points) will have changed in the txt file, and often there will be new records (coordinate points) in the txt file. Also, again, the txt file does not contain any dates.

    Thanks!
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    I think you should have a table to hold the imported data, but you don't have to create and delete it. Just keep the table, and delete all the records from it before you start. Then after you import to the table you could run an UPDATE like
    UPDATE FinalTable Set FinalTable.fiel d1 = ImportTable.fie ld1 WHERE FinalTable.PKey = ImportTable.PKe y
    Then do an INSERT of any new records based on a NOT EXISTS of the primary key in the destination table.
    I haven't looked at any of the other methods you mentioned, so there may be a much easier way.

    As for #3, I would make a form that shows only records without a date, and the user can fill them in, since they don't need to worry about the ones that have a date already. You can filter the form for a certain range or whatever.

    Comment

    • tdw
      New Member
      • Mar 2007
      • 206

      #3
      Ok, that all sounds good. I will try it.
      Thanks!

      Comment

      Working...