Hi there
I have an inserted chart within a report based on a query with the following syntax:
SELECT DISTINCT TradeContractorQuarter.[What trade?], TradeContractorQuarter.[Contractor ID], TradeContractorQuarter.[Contractor Name], QuestionHold.QuestionID, QuestionHold.[Question Text], QuestionHold.Target, ContJobQueResMonYearLink.Resp, CDate([year] & "-" & [month] & "-01") AS CalcDate, TradeContractorQuarter.Qtr, TradeContractorQuarter.From, TradeContractorQuarter.To
FROM QuestionHold INNER JOIN (ContJobQueResMonYearLink INNER JOIN TradeContractorQuarter ON ContJobQueResMonYearLink.CoID=TradeContractorQuarter.[Contractor ID]) ON QuestionHold.QuestionID=ContJobQueResMonYearLink.QuesID
WHERE (((TradeContractorQuarter.[What trade?])=Forms!TradeQuartersChoice!TradeChoice Or Forms!TradeQuartersChoice!TradeChoice Is Null) And ((CDate([year] & "-" & [month] & "-01")) Between [From] And [To]) And ((TradeContractorQuarter.Qtr)=IIf(forms!tradequarterschoice!qtr1=-1,1,0) Or (TradeContractorQuarter.Qtr)=IIf(forms!tradequarterschoice!qtr2=-1,2,0) Or (TradeContractorQuarter.Qtr)=IIf(forms!tradequarterschoice!qtr3=-1,3,0) Or (TradeContractorQuarter.Qtr)=IIf(forms!tradequarterschoice!qtr4=-1,4,0)))
ORDER BY TradeContractorQuarter.[Contractor Name], QuestionHold.QuestionID;
The query above works fine as a query in that if the user leaves the combo box called [Tradechoice] blank it lists all the trades. However, when this query is used to drive the inserted chart in the report it only works OK if a trade is selected leaves graphs empty if the [tradechoice] combo box is left blank. Why is this? This is the SQL from the inserted chart:
PARAMETERS [Forms]![TradeQuartersChoice]![TradeChoice] Text ( 255 ), [forms]![tradequarterschoice]![qtr1] Bit, [forms]![tradequarterschoice]![qtr2] Bit, [forms]![tradequarterschoice]![qtr3] Bit, [forms]![tradequarterschoice]![qtr4] Bit;
TRANSFORM Avg([TradeQtrQueryto usegraphs].Resp) AS AvgOfResp
SELECT [TradeQtrQueryto usegraphs].[Question Text], [TradeQtrQueryto usegraphs].Target
FROM [TradeQtrQueryto usegraphs]
WHERE ((([TradeContractorQuarter].[What trade?])=[Forms]![TradeQuartersChoice]![TradeChoice])) OR ((([Forms]![TradeQuartersChoice]![TradeChoice]) Is Null))
GROUP BY [TradeQtrQueryto usegraphs].QuestionID, [TradeQtrQueryto usegraphs].[Question Text], [TradeQtrQueryto usegraphs].Target
ORDER BY [TradeQtrQueryto usegraphs].QuestionID
PIVOT "Qtr " & [Qtr];
Thanks Sandra
I have an inserted chart within a report based on a query with the following syntax:
SELECT DISTINCT TradeContractorQuarter.[What trade?], TradeContractorQuarter.[Contractor ID], TradeContractorQuarter.[Contractor Name], QuestionHold.QuestionID, QuestionHold.[Question Text], QuestionHold.Target, ContJobQueResMonYearLink.Resp, CDate([year] & "-" & [month] & "-01") AS CalcDate, TradeContractorQuarter.Qtr, TradeContractorQuarter.From, TradeContractorQuarter.To
FROM QuestionHold INNER JOIN (ContJobQueResMonYearLink INNER JOIN TradeContractorQuarter ON ContJobQueResMonYearLink.CoID=TradeContractorQuarter.[Contractor ID]) ON QuestionHold.QuestionID=ContJobQueResMonYearLink.QuesID
WHERE (((TradeContractorQuarter.[What trade?])=Forms!TradeQuartersChoice!TradeChoice Or Forms!TradeQuartersChoice!TradeChoice Is Null) And ((CDate([year] & "-" & [month] & "-01")) Between [From] And [To]) And ((TradeContractorQuarter.Qtr)=IIf(forms!tradequarterschoice!qtr1=-1,1,0) Or (TradeContractorQuarter.Qtr)=IIf(forms!tradequarterschoice!qtr2=-1,2,0) Or (TradeContractorQuarter.Qtr)=IIf(forms!tradequarterschoice!qtr3=-1,3,0) Or (TradeContractorQuarter.Qtr)=IIf(forms!tradequarterschoice!qtr4=-1,4,0)))
ORDER BY TradeContractorQuarter.[Contractor Name], QuestionHold.QuestionID;
The query above works fine as a query in that if the user leaves the combo box called [Tradechoice] blank it lists all the trades. However, when this query is used to drive the inserted chart in the report it only works OK if a trade is selected leaves graphs empty if the [tradechoice] combo box is left blank. Why is this? This is the SQL from the inserted chart:
PARAMETERS [Forms]![TradeQuartersChoice]![TradeChoice] Text ( 255 ), [forms]![tradequarterschoice]![qtr1] Bit, [forms]![tradequarterschoice]![qtr2] Bit, [forms]![tradequarterschoice]![qtr3] Bit, [forms]![tradequarterschoice]![qtr4] Bit;
TRANSFORM Avg([TradeQtrQueryto usegraphs].Resp) AS AvgOfResp
SELECT [TradeQtrQueryto usegraphs].[Question Text], [TradeQtrQueryto usegraphs].Target
FROM [TradeQtrQueryto usegraphs]
WHERE ((([TradeContractorQuarter].[What trade?])=[Forms]![TradeQuartersChoice]![TradeChoice])) OR ((([Forms]![TradeQuartersChoice]![TradeChoice]) Is Null))
GROUP BY [TradeQtrQueryto usegraphs].QuestionID, [TradeQtrQueryto usegraphs].[Question Text], [TradeQtrQueryto usegraphs].Target
ORDER BY [TradeQtrQueryto usegraphs].QuestionID
PIVOT "Qtr " & [Qtr];
Thanks Sandra