PDA

View Full Version : Single Record CSV



fif_rumac
05-03-2006, 08:00 AM
Hello,

I hope someone can help me!

I would like to be able to create CSV files which contain data from only one record is a table... does anyone know if this is possible???

Thanks

fif_rumac

OBP
05-03-2006, 09:58 AM
I have just used this to output a single record, which was filtered by a query to a csv (text) file. Which opens OK in Excel.
I was surprised to find it had output the field names as well. So it may be better to create a report with no field names just the field data and output that instead.

DoCmd.OutputTo acOutputQuery, "Query Name", acFormatTXT, "Test.csv"

Sorry, although I chose CSV it actually just output as text.
I will have another try.

You can certainly export a table out to a csv file, so all you need is a dummy table to contain your one record and then export it

OBP
05-03-2006, 11:09 AM
Assuming that you can isolate the record that you want to export by putting it in it's own table the following is the correct code

Docmd.TransferText acExportDelim, "New File Name", "Table Name", " full Path name of file",True

Where the full path has the .TXT or .CSV file extension.

The "New File Name" is the name of the export specification that you can set up in the Export wizard prior to exporting the data.

I have found that the this VBA version exports the field names as well as the data whereas doing the same thig manually only exports the data.

OK got it, the ",True" on the end puts the Field names in, leave it off and you just get the data.

stanl
05-03-2006, 01:06 PM
Just write an SQL query to return a single row - then use getstring() - it defaults to Tab-Delimited but you can make it whatever you want.

.02
Stan
Stan