C
CJ
Hi Groupies:
I am exporting data to excel using code. The query that I am exporting has
subqueries and although the criteria works fine in the queries when I run
the export the criteria has been ignored. I have done this before with no
trouble but this one instance has this problem.
From what I can tell, the problem seems to be that some of the queries and
subqueries are Total queries and have used grouping. I have put my criteria
in every single query involved but I still have the same issue.
The criteria looks to a form to find the matching EmployeeID, Start and
Finish dates.
Here is the code that I am using:
Dim xlApp As Object
Dim FieldPayrollDetail As String
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qrptExportFieldPay", "FieldPayrollDetail"
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
With xlApp
.workbooks.Open FileName:="FieldPayrollDetail"
.Cells.Select
With .Selection.Font
.Name = "Arial"
.Size = 10
End With
<snip>
The WHERE statement for all of the queries is something similar to:
WHERE ((tblEmployees.lngEmpID) Like
[Forms]![frmExportFieldEmployeeReport]![cmbEmployee] & "*") AND
(tblCampCosts.dtmDate) Between
[Forms]![frmExportFieldEmployeeReport]![txtStart] And
[Forms]![frmExportFieldEmployeeReport]![txtEnd])
Any ideas?
I am exporting data to excel using code. The query that I am exporting has
subqueries and although the criteria works fine in the queries when I run
the export the criteria has been ignored. I have done this before with no
trouble but this one instance has this problem.
From what I can tell, the problem seems to be that some of the queries and
subqueries are Total queries and have used grouping. I have put my criteria
in every single query involved but I still have the same issue.
The criteria looks to a form to find the matching EmployeeID, Start and
Finish dates.
Here is the code that I am using:
Dim xlApp As Object
Dim FieldPayrollDetail As String
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qrptExportFieldPay", "FieldPayrollDetail"
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
With xlApp
.workbooks.Open FileName:="FieldPayrollDetail"
.Cells.Select
With .Selection.Font
.Name = "Arial"
.Size = 10
End With
<snip>
The WHERE statement for all of the queries is something similar to:
WHERE ((tblEmployees.lngEmpID) Like
[Forms]![frmExportFieldEmployeeReport]![cmbEmployee] & "*") AND
(tblCampCosts.dtmDate) Between
[Forms]![frmExportFieldEmployeeReport]![txtStart] And
[Forms]![frmExportFieldEmployeeReport]![txtEnd])
Any ideas?