Connect with Expertise | Find Experts, Get Answers, Share Insights

Importing multiple .CSV files. How to loop?

 
Join Date: Nov 2009
Posts: 1
#1: Nov 19 '09
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's Avatar
E
C
 
Join Date: Jan 2008
Location: Sydney
Posts: 1,062
#2: Nov 19 '09

re: Importing multiple .CSV files. How to loop?


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
NeoPa's Avatar
E
M
C
 
Join Date: Oct 2006
Location: London - UK
Posts: 18,974
#3: Nov 23 '09

re: Importing multiple .CSV files. How to loop?


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?
Reply