K
kcsims
The following is my SQL from my crosstab query:
TRANSFORM Count(INTERVAL.NEXT_INSPECTION_DATE) AS [The Value]
SELECT INSPECTIONTYPEGROUP.INSPECTIONTYPEGROUP_DESC,
UNITNAME.UNITNAME_DESC, Count(INTERVAL.NEXT_INSPECTION_DATE) AS [Total Of
NEXT_INSPECTION_DATE]
FROM UNITNAME INNER JOIN ((INSPECTIONTYPEGROUP INNER JOIN INSPECTIONTYPE ON
INSPECTIONTYPEGROUP.INSPECTIONTYPEGROUP_ID =
INSPECTIONTYPE.INSPECTIONTYPEGROUP_ID) INNER JOIN (ASSET INNER JOIN
INTERVAL ON ASSET.ASSET_ID = INTERVAL.ASSET_ID) ON
INSPECTIONTYPE.INSPECTIONTYPE_ID = INTERVAL.INSPECTIONTYPE_ID) ON
UNITNAME.UNITNAME_ID = ASSET.UNITNAME_ID
WHERE (((Format([NEXT_INSPECTION_DATE],"yyyy"))=2006) AND
((UNITNAME.UNITNAME_DESC)="45"))
GROUP BY INSPECTIONTYPEGROUP.INSPECTIONTYPEGROUP_DESC,
UNITNAME.UNITNAME_DESC
PIVOT "Qtr" & Format([NEXT_INSPECTION_DATE],"q") In
("Qtr1","Qtr2","Qtr3","Qtr4");
I want to be able to feed the year which I have typed in WHERE as
Format([NEXT_INSPECTION_DATE],"yyyy"))=2006 and the UnitName which I have
typed in WHERE as UNITNAME.UNITNAME_DESC)="45"
I want to be able to control the inputs through a combo box on a form.
I also have the WHERE statement modified in another queries to track
whether or not the inspection was completed. Here is the WHERE statement
for it with everything else being the same:
WHERE (((Format([NEXT_INSPECTION_DATE],"yyyy"))=2006) AND
((UNITNAME.UNITNAME_DESC)="45") AND ((INTERVAL.COMPLETED) Is Null Or
(INTERVAL.COMPLETED)=2))
It works fine except of course for not being able to control them through a
combo box on a form. I know I can add Parameters to the Query such as
[inspection data] , then add [inspection date] to the criteria for that
field, then type them in manual and it works, but like I said, I want to be
able to control it from a combo box.
Last question (I think) : Since I have 2 separate queries to count up the
inspections that are completed and one with just the total scheduled (both
quarterly), is there any *easy* way to make 1 report that would have a
count (by year and broken down quarterly) of all the inspections that were
completed and the total scheduled? I would want the output to just have the
quarters listed across the top and have the type of inspection for the row
header with the totals for that type of inspection broken out to total and
completed.
If any more information is needed such as table structure and what not,
just let me know. In addition to my main problems, if anyone has any
pointers maybe streamline this or let me know better practices to perform
these operations, input is greatly appreciated. Thanks.
TRANSFORM Count(INTERVAL.NEXT_INSPECTION_DATE) AS [The Value]
SELECT INSPECTIONTYPEGROUP.INSPECTIONTYPEGROUP_DESC,
UNITNAME.UNITNAME_DESC, Count(INTERVAL.NEXT_INSPECTION_DATE) AS [Total Of
NEXT_INSPECTION_DATE]
FROM UNITNAME INNER JOIN ((INSPECTIONTYPEGROUP INNER JOIN INSPECTIONTYPE ON
INSPECTIONTYPEGROUP.INSPECTIONTYPEGROUP_ID =
INSPECTIONTYPE.INSPECTIONTYPEGROUP_ID) INNER JOIN (ASSET INNER JOIN
INTERVAL ON ASSET.ASSET_ID = INTERVAL.ASSET_ID) ON
INSPECTIONTYPE.INSPECTIONTYPE_ID = INTERVAL.INSPECTIONTYPE_ID) ON
UNITNAME.UNITNAME_ID = ASSET.UNITNAME_ID
WHERE (((Format([NEXT_INSPECTION_DATE],"yyyy"))=2006) AND
((UNITNAME.UNITNAME_DESC)="45"))
GROUP BY INSPECTIONTYPEGROUP.INSPECTIONTYPEGROUP_DESC,
UNITNAME.UNITNAME_DESC
PIVOT "Qtr" & Format([NEXT_INSPECTION_DATE],"q") In
("Qtr1","Qtr2","Qtr3","Qtr4");
I want to be able to feed the year which I have typed in WHERE as
Format([NEXT_INSPECTION_DATE],"yyyy"))=2006 and the UnitName which I have
typed in WHERE as UNITNAME.UNITNAME_DESC)="45"
I want to be able to control the inputs through a combo box on a form.
I also have the WHERE statement modified in another queries to track
whether or not the inspection was completed. Here is the WHERE statement
for it with everything else being the same:
WHERE (((Format([NEXT_INSPECTION_DATE],"yyyy"))=2006) AND
((UNITNAME.UNITNAME_DESC)="45") AND ((INTERVAL.COMPLETED) Is Null Or
(INTERVAL.COMPLETED)=2))
It works fine except of course for not being able to control them through a
combo box on a form. I know I can add Parameters to the Query such as
[inspection data] , then add [inspection date] to the criteria for that
field, then type them in manual and it works, but like I said, I want to be
able to control it from a combo box.
Last question (I think) : Since I have 2 separate queries to count up the
inspections that are completed and one with just the total scheduled (both
quarterly), is there any *easy* way to make 1 report that would have a
count (by year and broken down quarterly) of all the inspections that were
completed and the total scheduled? I would want the output to just have the
quarters listed across the top and have the type of inspection for the row
header with the totals for that type of inspection broken out to total and
completed.
If any more information is needed such as table structure and what not,
just let me know. In addition to my main problems, if anyone has any
pointers maybe streamline this or let me know better practices to perform
these operations, input is greatly appreciated. Thanks.