Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Sep 2003
    Location
    Houston, Texas, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Export table to text file (Access 2000)

    When I run the code below I get an error that the object cannot be updated because it is read only. That makes no sense to me. Also how can I use a variable instead of test99?

    DoCmd.TransferText acExportFixed, "testexport", "tblForText", "c:arbeitdellaccess2000lehanenewtest99", False, ""

    Hans has helped me with a part of this before. I just do not seem to get hte whole thing the way I want it.
    Thanks fo rany help!!

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Export table to text file (Access 2000)

    If a file of that name already exists, you'll run into this problem. You need to kill the file first before doing a transfertext.
    Charlotte

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

    Re: Export table to text file (Access 2000)

    When you export to a text file, the target file must have one of the extensions .txt, .csv, .asc or .tab, otherwise you get the misleading "read only" error message. If you want to use a variable, concatenate it to the path using the ampersand & character:

    Dim strFileName As String
    strFileName = "test99.txt"
    DoCmd.TransferText acExportFixed, "testexport", "tblForText", "c:arbeitdellaccess2000lehanenew" & strFileName

    Note the trailing backslash after the path. Don't forget that!
    You can omit False for HasFieldNames, since that is the default value, and you can omit further arguments if they are empty.

  4. #4
    Star Lounger
    Join Date
    Sep 2003
    Location
    Houston, Texas, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Export table to text file (Access 2000)

    Thank you - that worked. Now the question is how do I delete the file if it already exists in the folder?

  5. #5
    Star Lounger
    Join Date
    Sep 2003
    Location
    Houston, Texas, USA
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Export table to text file (Access 2000)

    Thank you! It did the trick!!

Posting Permissions

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