Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    New Jersey, USA
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    exporting to Excel (97 sr2)

    Help
    I have to export a query into excel and have no idea how to even start this. I would like to be able to push a button on a form and have the source query automatically export into excel.
    Any help would be appreciated
    Thanks
    Cathy

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

    Re: exporting to Excel (97 sr2)

    The VBA command to export to Excel is DoCmd.TransferSpreadsheet. Look it up in the online VBA help for more info. If you want to export the query that is the record source of the form, you could use this:

    Private Sub cmdExportXL_Click()
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, Me.RecordSource, "C:ExcelQuery.xls", True
    End If

    The first argument says that you are exporting.
    The second tells Access to export to Excel 97 format.
    The third argument is the name of the table/query to be exported.
    The fourth argument is the file name to be exported to; this may, but need not be, an existing file.
    The fifth argument tells Access to include the field names in the export.

  3. #3
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: exporting to Excel (97 sr2)

    I'm trying to use this method, however when I use my query name (it's not being called from a bound form) I get Run-time error '3011': The microsoft Jet database engine could not find the object 'qryName'. Marine sure the object exists and that you spell its name and the path name correctly. Any advice?
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What's more, you deserve to be hacked." -Richard Clarke

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

    Re: exporting to Excel (97 sr2)

    "Marine sure"? <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    What kind of query are you trying to export? Does it have parameters, use special functions, is it an action query?

Posting Permissions

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