Results 1 to 2 of 2
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    export error

    Hi All. I am using access 2010 but working on a 2003 db. I have a command button on a form that I am trying to get to export a report to my desktop:
    Code:
    Private Sub Export_QA_Report_Click()
    On Error GoTo Err_Export_QA_Report_Click
    Dim reportname As String
    Dim theFilePath As String
    reportname = "rptQAReport"
    theFilePath = "C:\Documents and Settings\" & Environ("UserName") & "\Desktop\"
    theFilePath = theFilePath & reportname & "_" & Format(Date, "yyyy-mm-dd") & ".xls"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, reportname, theFilePath, True
    MsgBox "Look on your desktop for the report."
    Exit_Export_QA_Report_Click:
        Exit Sub
    Err_Export_QA_Report_Click:
        MsgBox Err.Description
        Resume Exit_Export_QA_Report_Click
        End Sub
    I am getting a msg stating MS access could not find the object rptQAReport...
    This is the correct name of the report I am trying to reference. Can anyone tell me please what's wrong?
    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    TransferSpreadsheet expects a table or query object, not form or report.

    Use OutputTo method for form or report. http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error Attempting to Export Data to IE9
    By Angrybox in forum Programming
    Replies: 9
    Last Post: 06-29-2012, 03:50 PM
  2. Export to Excel Error Handling
    By TimMoffy in forum Programming
    Replies: 1
    Last Post: 06-06-2012, 05:40 AM
  3. Error when trying to export from table to Excel
    By tobinjames in forum Import/Export Data
    Replies: 3
    Last Post: 12-15-2011, 02:55 PM
  4. Macro export to excel error
    By Andy_d in forum Import/Export Data
    Replies: 7
    Last Post: 04-15-2011, 09:54 AM
  5. Export Pivot table to Excel Error
    By Whalen16 in forum Import/Export Data
    Replies: 3
    Last Post: 09-30-2010, 12:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums