Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2008
    Posts
    7

    Question Unanswered: DoCmd.outputTo error

    Hi,

    I am getting " runtime error: 3066
    Query must have already one destination field. " when I click on button on form.

    Query takes two parameters from from , fromdate and ToDate.

    on below line of code

    DoCmd.OutputTo acOutputQuery, stDocName, acFormatXLS, , , , , acExportQualityScreen

    Please help.

  2. #2
    Join Date
    Feb 2004
    Posts
    214

    ...

    does your query work outside of the code?
    The destination field error usually happens when you are running an update query with no field being updated.
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  3. #3
    Join Date
    Nov 2008
    Posts
    7
    Yes, query works fine outside of code.

    Query has two parameters which it takes from FORM.

    I am running select query, based on two textbox value on form.

    PLease let me know how to export result of this query to excel sheet.

  4. #4
    Join Date
    Feb 2004
    Posts
    214

    I usually use

    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, [Your query name], "path to save it to", Yes

    I typed the code on the fly, so you may need to adjust it a bit
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

  5. #5
    Join Date
    Nov 2008
    Posts
    7
    Thank you, I had problem in my query. And I used your syntax, it worked fine.

  6. #6
    Join Date
    Feb 2004
    Posts
    214

    ...

    Glad I could help.
    You know, I'm sick of following my dreams, man. I'm just going to ask where they're going and hook up with 'em later

Posting Permissions

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