PDA

Click to See Complete Forum and Search --> : Text file to Access 97 database


Clunietp
Aug 4th, 2000, 11:58 AM
here is how you connect to a CSV text file:

'Uses ADO 2.1/5

Dim cn As ADODB.Connection
Dim rs As Recordset

Set cn = New Connection
Set rs = New Recordset

'open connection to folder that contains the CSV file
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=Text;"

'open the file
rs.Open "select * from test.csv", cn

'we have data
MsgBox rs.Fields(1).Value


Just loop through your recordset and insert the values into your MS Access table (you'll have to create a separate conneciton, of course)

JHausmann
Aug 4th, 2000, 12:58 PM
Tom's method will certainly work but you might want to take a look at Access's "TransferSpreadsheet Method" (if you have access installed search in help for the item in quotes).