pavewayammo
Programmer
Ok here is my problem. I have a table with personnel status. The status field can be either blank or have an l,t or o in it. I figured out how to get the totals for each but my problem is when no one has one of them. For example if at least 1 person has blank and l and o but none for t. I get an error everytime.
Here is the SQL statement for the first part. This one puts it in th columns with duty section, <>, L, O, T. For <>, L, O and T it put totals for each duty section.
TRANSFORM Count(tblPersonnel.SSN) AS CountOfSSN
SELECT tblPersonnel.[DUTY SECTION]
FROM tblPersonnel
GROUP BY tblPersonnel.[DUTY SECTION]
PIVOT tblPersonnel.STATUS;
Output Example:
Duty Section <> L O T
Flight 11 2
PGM 19 1 4 1
and so on.
Here is the second part that puts the data in to another table.
INSERT INTO tblFlightmanning ( Authorized, Assigned, Available, Leave, [Detail/Other], TDY )
SELECT qxtbPersonnelStatusCountByDutySection.SumOfAUTH, [Available]+[Leave]+[Other] AS Assigned, Sum(qryCountTLO.[<>]) AS Available, Sum(qryCountTLO.L) AS Leave, Sum(qryCountTLO.O) AS Other, Sum(qryCountTLO.T) AS TDY
FROM qryCountTLO, qxtbPersonnelStatusCountByDutySection
GROUP BY qxtbPersonnelStatusCountByDutySection.SumOfAUTH;
The second one is where the error comes from. It says that qryCountTLO.T doesn't exist(when no one has a status of "t").
I am not sure what to do now. Any ideas?
paveway
Looking for help check the FAQ's first then do a search then ask. Worked for me.
Here is the SQL statement for the first part. This one puts it in th columns with duty section, <>, L, O, T. For <>, L, O and T it put totals for each duty section.
TRANSFORM Count(tblPersonnel.SSN) AS CountOfSSN
SELECT tblPersonnel.[DUTY SECTION]
FROM tblPersonnel
GROUP BY tblPersonnel.[DUTY SECTION]
PIVOT tblPersonnel.STATUS;
Output Example:
Duty Section <> L O T
Flight 11 2
PGM 19 1 4 1
and so on.
Here is the second part that puts the data in to another table.
INSERT INTO tblFlightmanning ( Authorized, Assigned, Available, Leave, [Detail/Other], TDY )
SELECT qxtbPersonnelStatusCountByDutySection.SumOfAUTH, [Available]+[Leave]+[Other] AS Assigned, Sum(qryCountTLO.[<>]) AS Available, Sum(qryCountTLO.L) AS Leave, Sum(qryCountTLO.O) AS Other, Sum(qryCountTLO.T) AS TDY
FROM qryCountTLO, qxtbPersonnelStatusCountByDutySection
GROUP BY qxtbPersonnelStatusCountByDutySection.SumOfAUTH;
The second one is where the error comes from. It says that qryCountTLO.T doesn't exist(when no one has a status of "t").
I am not sure what to do now. Any ideas?
paveway
Looking for help check the FAQ's first then do a search then ask. Worked for me.