Import csv into access table to update values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Joe Richards
    New Member
    • Nov 2011
    • 1

    Import csv into access table to update values

    Hi All,

    I'm looking for code to get me started (i can work out the niggles myself) as i've no idea where to start.

    I have a table say, ID, Bookname, Quantity.

    I want to import a CSV file containing Bookname, Quantity where the quantity in the CSV will decrement the quantity in the table. I expect some kind of loop to cycle though the rows in the csv but not sure of the syntax, especially the connection to a csv.

    Regards,
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    We don't do your code for you (We can help when you've shown what you've achieved yourself.) but here's the basic logic you can follow to start yourself off with :
    1. Start with a table definition that matches your CSV file.
    2. Clear the table before each run is processed.
    3. Import the data into this table.
    4. Use an UPDATE query to update your main table from the CSV table (applying subtractions for matching [BookName]s).

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      1. Is the [ID] Field in your Table Unique?
      2. What is your Table Name?
      3. Does the *.csv File consist of IDs, Book Names, and Quantities?
      4. Do the IDs in the *.csv File, if they exist, match the IDs in the Table?
      5. Does the 1st Row in the *.csv File contain Field Names, and if so what are they?
      6. What is the Logic as to how are the Quantities in the *.csv File to decrement the Quantities in the Table?

      Comment

      Working...