report output to ... Urgent...

gdanalakshmi

Registered User.
Local time
Today, 14:05
Joined
Nov 26, 2002
Messages
102
I have a parameter query whose output goes into a report. But, I want the output of the parameter query to go into a excel sheet.

How do i do this??
 
This should do it for you. Just change the names as needed. Im using two charts because the spreadsheet you output to gets overwritten each time you run the query so you lose formatting and formulas.
HTH,
Jerry

Dim objExcel As Object
Dim strFile As String
Dim strFile2 As String
strFile = "C:\qcdatabase\chartbuffer.xls"
strFile2 = "C:\qcdatabase\scrapcharts.xls"

If DCount("*", "[qryScrapChart]") > 0 Then
DoCmd.OutputTo acOutputQuery, "qryScrapChart", acFormatXLS, strFile, False
Set objExcel = GetObject(strFile)
objExcel.Application.Visible = True
objExcel.Windows(1).Visible = True
objExcel.Windows(1).WindowState = xlMinimized

Set objExcel = GetObject(strFile2)
objExcel.Application.Visible = True
objExcel.Windows(1).Visible = True
objExcel.Windows(1).WindowState = xlMaximized
Else
MsgBox "There is no data to chart."
End If
ExitHere:
Exit Sub
 
I want to add a title to the excel sheet after outputting the records. How do I do that?
 
Simply put the title where you want on the second spreadsheet not the one actualy getting the query and it should stay. If you are doing a chart put it in a spreadsheet, dont show gridlines and put your title on the spreadsheet not the chart.
 

Users who are viewing this thread

Back
Top Bottom