Transfer CSV file with ado

Wijklodewijk

New member
Local time
Today, 20:11
Joined
Feb 22, 2008
Messages
7
Access2003 sp3 OS XP
I would like to make a csv file using ADO. I can do it with DAO but is it also possible with ADO.
DAO solution
Dim rs_rel As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim db As DAO.Database
Dim tblrel As String

Set db = CurrentDb()
Set qdf = db.CreateQueryDef(name:="abc")
Set qdf = db.QueryDefs("abc")

tblrel = "SELECT * from tablename"

CurrentDb.QueryDefs("abc").SQL = tblrel
strFileName = "C:\temp\test\test.csv"

DoCmd.TransferText acExportDelim, , "abc", strFileName

ADO
Dim rs_rel As ADODB.Recordset
Dim tblrel As String

Set rs_rel = New ADODB.Recordset
tblrel = "SELECT * from tablename"

rs_rel.Open tblrel, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
DoCmd.TransferText acExportDelim, , "rs_rel", strFileName
 
I would check out Access help for:

Converting DAO Code to ADO

And

ADO Methods

that would be a good place to start
 

Users who are viewing this thread

Back
Top Bottom