Export an Access Table to a csv file

Hi...

I'm trying to export a table that I have in a Access Db to a csv file. For now, I'm exporting it to a Excel file, but I can't make it to a csv file. Can someone help me

This is the code that I'm using to export the data to excel...First the query...

DoCmd.RunSQL "SELECT [Files] INTO Table2 FROM Table1;"

and then the code line:

DoCmd.TransferSpreadsheet acExport, 8, "Table2", "C:\Table2", True

or if anybody can tell how to do it from the excel file that'll be great too!

Thanks for your time.



Answer this question

Export an Access Table to a csv file

  • Marco2006

    I am trying to export a table into a .csv format, but when I do, I lose the leading four zeroes on one of the fields. I need the four leading zeros to stay put when exporting. Does anyone know if this is possible

  • 12565489789513213216549874565123

    what is the data type of the table

    Is it integer



  • Rod Colledge

    Hi Galford,

    Are you doing this as a one-off exercise or are you trying to do this as part of an application

    Assuming Access 2003, If you are doing it as a one-off then try this:

    Open the table

    File (Menu) --> Export

    Save as Type 'Text Files'

    Don't use the 'save formated' option

    That will bring up the Export Text Wizard

    Choose Delimited, click next

    Choose 'Comma' delimiter and " as Text qualifier.

    Choose 'Include Field names on First Row' if you want column headings

    Click next

    Give it a name and click finish

    That will give you a CSV file.

    If you want to do it as part of the application take a look at docmd.TransferText in MS Access help.

    I hope this puts you on the right path.

    Regards

    Nigel


  • simon_wang

    In this case you can use the following command:

    DoCmd.TransferText acExportDelim, "Standard Output", _
    "External Report", "C:\Txtfiles\MyText.csv"


  • Animats

    I have recently converted a database from Access 97 to Access 2003 which used the TransferTest command

    DoCmd.TransferText acExportDelim, , "Query name", "c:\path\filename" - which worked fine.

    However, if I try to run this line of code in Access 2003 I get a message "Cannot update. Database or object may be read-only".

    Anybody know how to make this work



  • Roger_Wolter_MS

    The table consists of numerous fields, but this one in particular is a text field. When the table was initially imported into the database, it was a Number field. Since we needed the 11-digit number, we then created an Update Query to add back in the leading zeroes, but had to change it over to a text field. Now when I export it out of Access into a .csv file, the leading zeroes are removed automatically by the system again.



  • mg123

    the function given by you works, but i would like to export fields delimited by * and I would also like the strings to be exported without the quotation marks (" ")

    so instead of:

    1,"sample text",0,0

    i would like to have:

    1*sample text*0*0



    is it possible Smile

  • Export an Access Table to a csv file