• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 623
  • Last Modified:

Export Access Report to Excel

I am using Access 2007 and I have a report rptRepairsBySNandGS which I want to export to excel to the users home folder as in C:\Users\USERNAME\Document\ with the report name and the current date concatenated to it here is my code

Private Sub cmdExportExcel_Click()
   On Error GoTo cmdExportExcel_Click_Error

If IsNull(Me.txtStartDate) Or IsNull(Me.txtEndDate) Then
MsgBox "You must enter a Start Date and End Date." _
    & vbCrLf & "Please try again.", vbExclamation
    Exit Sub
 End If
DoCmd.OutputTo acOutputReport, "rptRepairsBySNandGS", acFormatXLS, xlsFileNameToStore, OpenAfterPublish = False

   Exit Sub


    MsgBox Err.Description
    Resume Exit_cmdExportExcel_Click:
End Sub

Open in new window

1 Solution
Rey Obrero (Capricorn1)Commented:
dim xlsFileNameToStore as string

xlsFileNameToStore=environ("userprofile")& "\Documents\rptRepairsBySNandGS_" & Format(Now(),"mm_dd_yyyy") & ".xlsx"

DoCmd.OutputTo acOutputReport, "rptRepairsBySNandGS", acFormatXLS, xlsFileNameToStore, OpenAfterPublish = False
skull52Author Commented:
Cap, thanks, that worked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now