Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009

    Unanswered: Error using TransferText to export to CSV

    I have four tables I need to export to CSV -- minus one field each. It *looks* like it should be easy to do via DoCmd.TransferText, but everytime I run it I get the following error (or a similar one):

    The Microsoft Jet database engine could not find the object <name>. Make sure the object exists and that you spell its name and the path name correctly. (Error 3011)

    My original coding was:
    'DoCmd.TransferText acExportDelim, "", "qryNavigatorCharacteristicsForExport", "d:\navchar.csv", True

    Then I tried (somewhere I read that TransferText didn't like queries -- although the documentation says it does -- I also wasn't sure that it made sense to permanently store a query that will be used once a quarter...):

    Dim Example As String
    Example = "SELECT IDPN NGENDER tblNavigatorCharacteristics"
    Dim filename As String
    filename = "d:\exportnav.txt"

    DoCmd.TransferText acExportDelim, , Example, filename, True

    Ideally, I'd like the user to be able to specify a location for the file -- but honestly, I'll be happy to have it work, even if the location is hardcoded.

    I've searched and found other posts with the same/similar problem, but haven't yet found a seems odd to me that it is complaining about a file not existing when it is a file I am trying to export to (rather than import to).

    Thank you!

  2. #2
    Join Date
    Jun 2009
    I went back to my original coding... deleted the blank string from the specifications argument, and removed the file extension from the destination file. So, it now reads:

    DoCmd.TransferText acExportDelim, , "tblNavigatorCharacteristics", "d:\navchar", True

    And, now I get a new error:
    Cannot update. Database or object is read-only. (Error 3027)

  3. #3
    Join Date
    Dec 2004
    Madison, WI
    See the code bank. There's a few examples on how to do this. I think the one of the latest posts (Excel tab form) let's you do exactly what you want to do when you go to export the excel query data.

    Basically you'll need to utilize the Browse function and coding.

    Here's the example:

    Click a query in the yellow to view in excel type format on the 1st form. It will then show you an excel type form with the query.

    On the Excel form, click "Export Data" at the top. Notice the popup to save the file with a browse button to select the location. You can also export the file as a .csv, .xls, .dbf, with the option to include the date in the saving filename.

    This is exactly what I'm pretty sure you are asking about.
    Last edited by pkstormy; 06-28-09 at 03:31.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  4. #4
    Join Date
    Jun 2009
    Thanks - I'll check it out.

Posting Permissions

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