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

import a DAO recordset into a db table

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
1. I want to read a text file into a db using a schema.ini file.

2. My position-delimited text file has the exact same format as a table in my db. I have made a valid schema.ini file that also has the exact same format.

3. I found a vba function at support.microsoft.com. If you have a valid schema.ini file, it will read the text file into a recordset. The code works great!

4. Here is my question: How do I actually import the recordset?!? I have searched for a method like "rs.import", but I can't find anything like that. I do NOT want to import it one row at a time. The file is 125mb.

5. If your answer requires me to reference anything special, please mention the reference.

Here is a code sample:

'from Function TestSchema()
Dim db As Database, rs As Recordset
Set db = OpenDatabase("c:\", False, _
False, "TEXT;Database=c:\;table=sales.txt")
Set rs = db.OpenRecordset("sales.txt")
Debug.Print rs(0).Value
rs.MoveLast
Debug.Print "Record count= " & rs.RecordCount
rs.Close
End Function
 
Steve,

Assuming that this text file contains only one record type, why do you want to create a recordset from it first, and then apend the recordset into a table?

Why not just link the text file and append it? Or use DoCmd.TransferText to import the table direct?

Ed Metcalfe.

Please do not feed the trolls.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top