I have the following query:
SELECT DISTINCT tblMaster.OperatingDay, tblMaster.[TO BA_REPORT], tblMaster.[From BA_REPORT], tblMaster.Hour_Ending, Sum(tblMaster.Import) AS SumOfImport, Sum(tblMaster.Export) AS SumOfExport, Sum(([Export]-[Import])) AS Net, Sum((IIf(IsNull([OffPeakHour]) And IsNull([OffPeakDay]),([export]-[import])))) AS OnPeak, Sum((IIf([OffPeakHour]="OffPeakHour" Or [OffPeakDay]="OffPeakDay",([export]-[import])))) AS OffPeak
FROM tblMaster
GROUP BY tblMaster.OperatingDay, tblMaster.[TO BA_REPORT], tblMaster.[From BA_REPORT], tblMaster.Hour_Ending
HAVING (((tblMaster.OperatingDay)=[Forms]![frm03HourlyNAITotalsEIS]![Combo13]) AND ((tblMaster.[TO BA_REPORT])=[Forms]![frm03HourlyNAITotalsEIS]![Combo3]) AND ((tblMaster.[From BA_REPORT])=[Forms]![frm03HourlyNAITotalsEIS]![Combo49]));
When I run it as a query it runs fine (I get the intended results). But when I copy this same SQL into the RecordSource of a form (the same form mentioned above frm03HourlyNAITotalsEIS) I get no results).
Any idea why?
SELECT DISTINCT tblMaster.OperatingDay, tblMaster.[TO BA_REPORT], tblMaster.[From BA_REPORT], tblMaster.Hour_Ending, Sum(tblMaster.Import) AS SumOfImport, Sum(tblMaster.Export) AS SumOfExport, Sum(([Export]-[Import])) AS Net, Sum((IIf(IsNull([OffPeakHour]) And IsNull([OffPeakDay]),([export]-[import])))) AS OnPeak, Sum((IIf([OffPeakHour]="OffPeakHour" Or [OffPeakDay]="OffPeakDay",([export]-[import])))) AS OffPeak
FROM tblMaster
GROUP BY tblMaster.OperatingDay, tblMaster.[TO BA_REPORT], tblMaster.[From BA_REPORT], tblMaster.Hour_Ending
HAVING (((tblMaster.OperatingDay)=[Forms]![frm03HourlyNAITotalsEIS]![Combo13]) AND ((tblMaster.[TO BA_REPORT])=[Forms]![frm03HourlyNAITotalsEIS]![Combo3]) AND ((tblMaster.[From BA_REPORT])=[Forms]![frm03HourlyNAITotalsEIS]![Combo49]));
When I run it as a query it runs fine (I get the intended results). But when I copy this same SQL into the RecordSource of a form (the same form mentioned above frm03HourlyNAITotalsEIS) I get no results).
Any idea why?