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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data in to Access DB

Status
Not open for further replies.

geocabs

IS-IT--Management
Jul 6, 2000
24
0
0
GB
I want to take a CSV file line by line and update records in an Access database with the records from each line. (Update record where present and add where not present)

Does anyone know a command line command or VB command (asp page) for Access / ODBC which can allow me to send the data to ODBC link.

Does anyone know what is the best way to do this?
 
Why not simply IMPORT the CSV into Access as a table and then merge the two tables together inside Access ?




G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
The process needs to be completely automated and the CSV file is produced by another DOS application automatically.
 
What I do in cases like this is set up a linked table, then write code to rename the file, run my query, then rename (or delete, in my case) the old file.

I do this in a number of cases to bring data in from automatic test equipment. It's a lot easier than writing code to go through the table and update.



 
How About something like this

Dim strFromFile As String
Dim dbs As Database
'Dim rst As Recordset: 'Access97
Dim rst As DAO.Recordset: '(Access2000+)

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Table1")

Open "your_file.csv" For Input As #1
Input #1, strFromFile
With rst
.AddNew
rst!Field1 = strFromFile
.Update
End With

Close #1
Set rst = Nothing
Set dbs = Nothing

if you are using access2000 use the second recordset dim statement

you'll also have to set a reference to the microsoft DAO 3.6 object library

hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top