Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automating Improting .csv file into access table

Status
Not open for further replies.
Nov 4, 2003
8
0
0
CA
Hi All,

I'm trying to write a program for importing multiple csv files into access table.
All my csv files have the same headers and record layout.I have to import it and append into one big access table.. I have never done this before or write vb program extensively. Can somebody please point me to the right direction.

Thank You.
 
You can import the text file then update your big table in the following way.

Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim rs As New ADODB.Recordset

DoCmd.TransferText acImportDelim, , "Table name", "LOCATION OF TEXT FILE", True
rs.Open "Table Name", cnn, adOpenForwardOnly, adLockOptimistic
rs.MoveFirst
Do While Not rs.EOF

a = rs.Fields(0)
b = rs.Fields(1)

strSQL = "INSERT INTO BIG_TABLE" & vbCrLf & "VALUES ('a', 'b')"
cnn.Execute strSQL

rs.MoveNext

Loop

THis will import your text file then add the values a into field one and b into field two. You could repeat this to get all your table in there.

Let me know if this helps

dyarwood
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top