Importing multiple .CSV files. How to loop?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kyrgan
    New Member
    • Nov 2009
    • 1

    Importing multiple .CSV files. How to loop?

    Hello all, I am new to Access and VBA and hope some of you can point me in the right direction. I am not asking for someone to do my job, I want to learn how to do this.

    My task is to automate an access app where a user manualy imports data from printed worksheets. Currently, all this data is also available in .CSV files. I want to do all this though VBA at the click of a button on a user form.

    What I need to do is:
    1. Create a temporary table
    2. Count all the CSV files in a dir
    3. Loop through and Import all CSV files into temporary table.
    4. Validate the data then move it into the existing database.

    Thanks for any advice you can provide.
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    That all looks OK to me but it is to vague to be sure.
    I don't know what to say to that without doing the entire thing for you, which you don't want me to do and I don't want to do it for you either.

    What is your question?
    What have you done so far?
    What do you want to try that your unsure of?
    Are you experiencing some other difficulty?
    What is that difficulty?

    With that sort of question we can, and are willing, to help you

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      If the data is eventually bound for a single table (you only say "into the database"), then I suggest you can change your approach to :
      1. Create a temporary table.
      2. Loop through all CSV files in the folder.
        1. Clear temporary table.
        2. Import all CSV files into temporary table.
        3. Validate the data.
        4. Copy data from temporary table into main table

      Is there anything in any of those steps you expect to find any difficulty with?

      Comment

      Working...