Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating csv (2002)

    I need an easy way to create a csv file from a table. I'm using the DoCmd.OutputTo object in a On Click event in a form I created. The output from this command is not usable in it's current form (attached), pipes (|) dividing fields. I only expect one row in the table, so performance should not be a concern. Thanks for any help in advance.

    DoCmd.OutputTo acOutputTable, "tblPropertyAddress", _
    acFormatTXT, "C:PropertyImagesPropertyFile.txt", False
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating csv (2002)

    Use DoCmd.TransferText instead of DoCmd.OutputTo:

    DoCmd.TransferText acExportDelim, , "tblPropertyAddress", "C:PropertyImagesPropertyFile.txt", True

    This will use the default settings. If you don't like them, create an export specification and supply its name:

    DoCmd.TransferText acExportDelim, "MySpecification", "tblPropertyAddress", "C:PropertyImagesPropertyFile.txt", True

    To create an export specification, select the table in the database window and select File | Export...
    Select Text Files (*.txt, *.csv, *.tab, *.asc) as file type.
    Specify a file name (it must have one of the four extensions mentioned), and click Export.
    The Export Text Wizard starts. In the first step, select Delimited.
    In the second step, select the delimiter and the text separator, also specify whether the text file should contain field names in the first line.
    Then click Advanced..., and Save As... to store the settings as an export specification. Use the name you give the specification in the DoCmd.TransferText command.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating csv (2002)

    That works percectly, I'll check out the export specification option though.

    Thanks for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •