Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2007
    Posts
    9

    Unanswered: error in outputing a query

    an error message showed up when I tried generating a report from my access. "Microsoft Access can't output data to the file you've selected."

    this is part of the code:

    Code:
    strExcelFilter = fileIO.ahtAddFilterItem(strExcelFilter, _
            "Excel Files (*.XLS)", "*.XLS")
    strExcelPath = fileIO.ahtCommonFileOpenSave( _
            Filter:=strExcelFilter, OpenFile:=False, _
            FileName:="Cashflow forecast.xls", _
            DialogTitle:="Please select an output file...", _
            Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_HIDEREADONLY)
    
    DoCmd.OutputTo acOutputQuery, "qryCashFlow", acFormatXLS, strExcelPath
    Any idea what happens here?? I have seached the error message in the web, but it doesn't help.


    thanks

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Does "qryCashFlow" return any results?
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I would suggest using TransferSpreadsheet instead of OutputTo.

  4. #4
    Join Date
    Mar 2007
    Posts
    9
    Does "qryCashFlow" return any results?
    if what you mean is whether the query has something inside or not, yes there is..

    I would suggest using TransferSpreadsheet instead of OutputTo.
    this is what I tried..
    Code:
    DoCmd.TransferSpreadsheet acExport, , "qryCashFlow", strExcelPath, True
    But it gave an error "Cannot modify table structure. Another user has the table open" I didnt open the query when I tested it. Is there something wrong with the code above?

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Flags:=ahtOFN_OVERWRITEPROMPT Or ahtOFN_HIDEREADONLY)
    Is this your problem?
    George
    Home | Blog

Posting Permissions

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