Fred Webb
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER