Export report (1 Viewer)

slimjen1

Registered User.
Local time
Today, 03:29
Joined
Jun 13, 2006
Messages
562
All, using access 2016...I have a report based on a query I need users to export to a folder on the desktop.The button is on the form. It runs but just places the field names in the columns with no data. Also On the left side there's the numbers 123 like its tring to group something.
Here is the code I'm using:
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\Reports\"
theFilePath = theFilePath & reportname & "_" & Format(Date, "yyyy-mm-dd") & ".xls"


DoCmd.OutputTo acOutputReport, reportname, acFormatXLS, 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
If this isn't possible, please show me how to export the query based on the forms filter instead. Thank you
 

theDBguy

I’m here to help
Staff member
Local time
Today, 00:29
Joined
Oct 29, 2018
Messages
21,447
Hi. That should have worked but to export the query instead, you can still use OutputTo but only use acOutputQuery instead of acOutputReport and then use the name of the query instead of the report.
 

Users who are viewing this thread

Top Bottom