Link to home
Start Free TrialLog in
Avatar of Fred Webb
Fred WebbFlag for United States of America

asked on

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
    txtStartDate.SetFocus
    Exit Sub
 End If
DoCmd.OutputTo acOutputReport, "rptRepairsBySNandGS", acFormatXLS, xlsFileNameToStore, OpenAfterPublish = False


Exit_cmdExportExcel_Click:
   Exit Sub

cmdExportExcel_Click_Error:

Err_cmdExportExcel_Click::
    MsgBox Err.Description
    Resume Exit_cmdExportExcel_Click:
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fred Webb

ASKER

Cap, thanks, that worked.