Results 1 to 3 of 3
  1. #1
    riantoaji is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2015
    Posts
    2

    export using form

    hellow expert

    i'm a beginner and i have a case want to filter date with start date and end date and make a report and that's clear and now i want to export the report with a button in .xls .what should i do?please be kindness

  2. #2
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Quick draw, untested but should work with some tweaking:

    Code:
    Private Sub btExportReportToXls_Click()
    Dim XlsName As String
    Dim XlsFullPath As String
    Dim ReportName As String
        ReportName = "repToExport"
        DoCmd.OpenReport ReportName, acViewPreview, , , acHidden 'opens report preview, required for export
        XlsName = "ExportedReport" ' file name of your exported xls
        XlsFullPath = Application.CurrentProject.Path & "\XLS\" & XlsName & ".xls" 'full path to above file
        DoCmd.OutputTo acOutputReport, ReportName, acFormatXLS, XlsFullPath 'export command
        DoCmd.Close acReport, ReportName, acSaveNo     'close report preview back
    End Sub
    That should work but personally I don't think exporting report to Excel format is the best idea. Maybe you'd consider exporting query results?

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    If you use the OutputTo method you will want to apply Criteria to the Report's Filter property in the OpenReport event.

    DoCmd.OpenReport ReportName, acViewPreview, ,"My date criteria here" , acHidden 'opens report preview, required for export

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

Similar Threads

  1. 1- export form into new database?
    By Michael.Reynolds1775 in forum Import/Export Data
    Replies: 3
    Last Post: 03-17-2015, 03:53 AM
  2. Export Form And Subform Data To Excel Form Same Worksheet
    By tomtheappraiser in forum Import/Export Data
    Replies: 6
    Last Post: 08-12-2013, 10:39 AM
  3. Auto Export Form
    By Juan4412 in forum Programming
    Replies: 6
    Last Post: 07-14-2011, 07:54 AM
  4. Crosstab and Export Form example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-24-2010, 12:30 AM
  5. Export Form but Keep Information?
    By SpeedyApocalypse in forum Forms
    Replies: 4
    Last Post: 04-09-2010, 07:30 AM

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