Hi Steve,
Thanks again for your suggestions and your obvious
patience with us.
At the end of the day, the decision was to go with the
multiple reports as we needed to close this project. The
client didn't care how the reports were generated as long
as they were done right away.
I am still interested in figuring out how this could have
been handled better, to avoid a similar situation. So...
I tried your suggestion of using single query and
grouping/sorting in the report. This still did not yield
the results I needed because:
-The original supplied tables pretty much used number
field values (0,1,2) to indicate (NA,N,Y) for the data we
are reporting on. Fields Location, Event, Type and
EventDescription are all strings and date is obvious. If
I use the summary options for the reports, the default
setting SUMS the field values rather then providing a
COUNT of the number of Y records. I couldn't figure out
how to change the report SUM to COUNT and also have it
based on criteria (e.g. WHERE CPR = 2) so that it only
counts the total Ys.
-By far the larger problem was that I could not group the
field EventType and count the occurences of it in the
report. I was only able to sort the occurences. This was
the reason we had developed a second query. The end
result needed to display the top five EventType occurences
from each location. I will provide an example to
illustrate what the client wanted. I use a "/" to
indicate where page formatting (Spaces) would occur.
Location A
_________________________
//Report header section with results supplied by DCount
TotalEvents 42/3%ofTotal
TotalReponses 40/2.5%ofTotal
TotalCPR 5/0.1%ofTotal
..
..
..
__________________________
//Report detail section with results supplied by
//qryByLocationByEventType
EventTypeSummaryForLocationA
MotorVehicleAccident 17
Assault 12
Respiratory 2
..
..
..
So in this example, of the 42 events, 17 were from
MotorVehicleAccidents, 12 from Assaults, etc... This data
is from a one-to-many relationship table between tblData
and tblEventType. If I used the report wizard with a
single query as you suggested, it would not provide the
grouping for the second half of the report. Instead, it
would sort and return every EventType.
As requested, I will give you the SQL from the queries to
help facilitate understanding.
Query1----------------
SELECT tblData.Location, tblData.Date, tblData.Event,
tblData.Episode, tblData.Arrest, tblData.Activation,
tblData.Volunteer, tblData].CPR, tblData.AED,
tblData.Type, tblEventType.EventDescription, tblData.Acute
FROM tblEventType INNER JOIN tblData ON
tblEventType.EventType = tblData.EventType
WHERE (((tblData.Location)="Location A") AND tblData.Date)
Between #1/1/2002# And #4/30/2003#));
Query2----------------
SELECT TOP 5 [qryByLocationA].[EventDescription], Count
([qryByLocationA].[EventDescription]) AS
CountOfEventDescription
FROM [qryByLocationA]
GROUP BY [qryByLocationA].[EventDescription]
ORDER BY Count([qryByLocationA].[EventDescription]) DESC;
I most definately appreciate your suggestions for this. I
hope that I have provided you with enough detail to
understand exactly what we have been trying to
accomplish. Do you still think that one query and the
report's grouping/sorting functions could supply the same
results?
Daniel