Recordset with Text File

J

JF Bouthillier

Hi all,

Can someone help me build a recordset with an external
text file?

Thank you very much.
JF
 
J

John Nurick

Hi JF,

Do you mean something like this?

Dim rsR As DAO.Recordset

Set rsR = DBEngine(0)(0).OpenRecordset( _
"SELECT * FROM [Text;HDR=Yes;" _
& "Database=D:\Folder\Subfolder\;].Filename#txt", _
dbOpenDynaset)

This works for standard CSV files, but AFAIK for any other kind of text
file (e.g. tab-separated) you need to provide a table specification in a
SCHEMA.INI file in the same folder as the text file. This is documented
very sketchily in Help and more fully at the following links:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetschema_ini_file.asp

Create a Schema.ini file based on an existing table in your database:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;155512

http://support.microsoft.com/default.aspx?scid=kb;EN-US;149090
http://www.devx.com/tips/Tip/12566
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top