thanks for the reply.
However, I really need to the data to go to different sheets on the click.
If I were around I would use your recommendation, however I am returning to school in a few weeks and I know that based on the people who will take over generating the recovery report, it would not be possible for them to do so. Also, having the data separated on click would save a lot of time.
I have decided I wish to pursue solving this through access. I am not sure if this is an area you are familiar with but I thought it would be worth asking.
Currently this code (below) exports the entire query results to the ms access file.
Now, each entry has a site, each site has its own worksheet (named as the site)
Do you know what is the best way to have the data go to a worksheet based on its site?
Thanks so much for your time,
I really appreciate your first response, and any additional information is highly valued.
SL
Code:
Private Sub exportcmd_Click()
On Error GoTo err_Handler
Const cTabTwo As Byte = 1
' Excel object variables
Dim appExcel As Excel.Application
Dim wbk As Excel.Workbook
Dim wks As Excel.Worksheet
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim rstOutput As DAO.Recordset
Dim sOutput As String
Set db = CurrentDb
Set qdf = db.QueryDefs("paraquery")
For Each prm In qdf.Parameters
prm.Value = Eval(prm.Name)
Next prm
Set rstOutput = qdf.OpenRecordset
DoCmd.Hourglass True
' set to break on all errors
Application.SetOption "Error Trapping", 0
' start with a clean file built from the template file
sOutput = CurrentProject.Path & "\salary recovery template.xls"
' Create the Excel Applicaiton, Workbook and Worksheet and Database object
Set appExcel = Excel.Application
Set wbk = appExcel.Workbooks.Open(sOutput)
Set wks = appExcel.Worksheets(cTabTwo)
appExcel.Visible = True
'Take the records in the current form and dump to Excel
wks.Range("A11").CopyFromRecordset rstOutput
exit_Here:
' Cleanup all objects (resume next on errors)
On Error Resume Next
Set wks = Nothing
'You may want to save the workbook here
Set wbk = Nothing
Set appExcel = Nothing
rstOutput.Close
Set rstOutput = Nothing
DoCmd.Hourglass False
' Exit exportcmd_Click
err_Handler:
ExportRequest = Err.Description
' Me.lblMsg.Caption = Err.Description
'Resume exit_Here
End Sub