BMLekki
April 20th, 2001, 09:48 AM
I need to export data from an access database as a *.csv. Any ideas?? Is this possable?
|
Click to See Complete Forum and Search --> : Export Data BMLekki April 20th, 2001, 09:48 AM I need to export data from an access database as a *.csv. Any ideas?? Is this possable? Iouri April 20th, 2001, 11:16 AM For example you want to export Your table to the temp.csv file with "|" as delimeter create a recordset from your table and then rs.movefirst do while not rs.eof Open "c:\temp.csv" For Output As #1 'to write to Print #1, rs!Field(1).Value & "|" & rs!Field(2).Value & ...etc Close #1 rs.movenext Loop Iouri Boutchkine iouri@hotsheet.com Cubbie April 20th, 2001, 12:59 PM The following code will create a .csv file from an Access 2000 table: Note this will put double quotes around each field in the .csv file. If you do not want the double quotes then use the export wizard to create a specification by changing the text qualifier to none. Put the specification name just before the table name in the code below. Dim appAccess as new Access.Application '*********************************************************************** '************* Open Access database and transfer file to DB ************ 'Must select Access 8 Object Library for Access 97 & 'Access 9 Library for Access 2000 in Project|References 'Open Database DB Path Exclusive appAccess.OpenCurrentDatabase "Path\Some..MDB", true ' Transfer text file to database appAccess.DoCmd.TransferText acExportDelim,"[Specification Name if required]" , "Tablename", "Path\somefile.csv", 1 ' Close appAccess.CloseCurrentDatabase ' set object to nothing set appAccess = nothing codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |