Then add a where clause in to do so. Note that the where clause goes BEFORE
the GROUP BY. It filters the records before the aggregation takes place so it
should be faster.
SELECT
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos*'") AS Icos
, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*isar*'") AS Isar
, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos system*'") AS
[Icos System]
, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*mexico HE*'") AS Mexico
, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*Esprit HE*'") AS Esprit
, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*classic HE*'") AS Classic
, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*Elise*'") AS Elise
FROM [Main Audit Data]
WHERE [Main Audit Data].[Audit Date] Between
forms!graphcriteria!startdate1 And forms!graphcriteria!enddate1
And ( [Main Audit Data].[Boiler Type] Like "ISAR*"
OR [Main Audit Data].[Boiler Type] Like "Icos*"
OR [Main Audit Data].[Boiler Type] Like "Esprit*"
OR [Main Audit Data].[Boiler Type] Like "Mexico*"
OR [Main Audit Data].[Boiler Type] Like "Elise*" )
GROUP BY DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*isar*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos system*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*mexico HE*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*Esprit HE*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*classic HE*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*Elise*'");
There is one problem in that the ICOS count is going to include the items
counted in the ICOS system count. You can try changing that to
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos*' AND [Boiler Type]
NOT LIKE '*ICOS System*' ") AS Icos
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
Hi John, I posted the wrong code the one below works ok but i want to limit
it between two dates, sorry for confusion
SELECT DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos*'") AS
Icos, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*isar*'") AS Isar,
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos system*'") AS [Icos
System], DCount("*","[main Audit Data]","[Boiler Type] LIKE '*mexico HE*'")
AS Mexico, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*Esprit HE*'")
AS Esprit, DCount("*","[main Audit Data]","[Boiler Type] LIKE '*classic
HE*'") AS Classic, DCount("*","[main Audit Data]","[Boiler Type] LIKE
'*Elise*'") AS Elise
FROM [Main Audit Data]
GROUP BY DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*isar*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*icos system*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*mexico HE*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*Esprit HE*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*classic HE*'"),
DCount("*","[main Audit Data]","[Boiler Type] LIKE '*Elise*'");