Hi all, Can someone help me build a recordset with an external text file? Thank you very much. JF
J JF Bouthillier Aug 25, 2004 #1 Hi all, Can someone help me build a recordset with an external text file? Thank you very much. JF
J John Nurick Aug 25, 2004 #2 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
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