Link to home
Start Free TrialLog in
Avatar of GenieMaster
GenieMaster

asked on

Adding Records to an Access Table

I want to run a query that on click will look at a file and add records based on the values in that file.
I have a file called example.txt  

the values of the file are like this

463,BEI,BEIGE,10
454,BLK,BLACK,15

The database is called productlabels. The table is called mlabels.
In this table is the columns
Id (this is an auto number)
pi (this is a text value column)
col_id (this is a text value column)
col_description (this is a text value column)

I want the query to read and add the value "463" to column 2 (pi) "BEI" to column 3  (col_id) "BEIGE" to column 4 (col_description) as the last value was 10 I want it to create 10 records of this value. Then it should do the same for the next line but that has 15 records as you can see in the file and likewise for how many entries are listed in the text file.
In completion of the query if the file name can be renamed to example_done.txt
This is to avoid if the action query is run again it will not create a duplicate of those already added.

I am hoping that the query on running would the table be like this;

1  463 BEI BEIGE
2  463 BEI BEIGE
3  463 BEI BEIGE
4  463 BEI BEIGE
5  463 BEI BEIGE
6  463 BEI BEIGE
7  463 BEI BEIGE
8  463 BEI BEIGE
9  463 BEI BEIGE
10  463 BEI BEIGE
11 454 BLK Black
12 454 BLK Black
13 454 BLK Black
14 454 BLK Black
15 454 BLK Black
16 454 BLK Black
17 454 BLK Black
18 454 BLK Black
19 454 BLK Black
20 454 BLK Black
21 454 BLK Black
22 454 BLK Black
23 454 BLK Black
20 454 BLK Black
21 454 BLK Black
22 454 BLK Black
23 454 BLK Black
24 454 BLK Black
25 454 BLK Black
ASKER CERTIFIED SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this sample
DBImportcsv.mdb
Avatar of GenieMaster
GenieMaster

ASKER

Dear ASL315,
Thanks. What you did was perfect and just what I needed. Could not ask for any better. Brilliant. :)