hi
i have the follwoing sql in a query
SELECT CountryID, StateID, KindID
, NZ(Round(STR([M2S]),0),"No
data") AS [M2 Start]
, NZ(Round(STR([M2E]),0),"No
data") AS [M2 End]
, NZ(Round(STR([M2D]),0),"No
change") AS [M2 Difference]
FROM (SELECT CountryID, StateID, KindID, Avg(PAStart) AS M2S, Avg(PAEnd) AS M2E, [M2S]-[M2E] AS M2D
FROM (Select CountryID, StateID, KindID, Price/Area AS PAStart, Null as PAEnd
From TbMain
Where (
(([TBMain.Time]=Forms!FSal
esStock!Re
portDateSt
art) OR Forms!FSalesStock!ReportDa
teStart IS Null)
And (((Format([TBMain.Time],"y
yyy"))=[Fo
rms]![FSal
esStock]![
StartYear]
OR [Forms]![FSalesStock]![Sta
rtYear] IS Null))
And (((Format([TBMain.Time],"y
yyy"))=[Fo
rms]![FSal
esStock]![
StartMonth
Year] OR [Forms]![FSalesStock]![Sta
rtMonthYea
r] IS Null))
And (((Format([TBMain.Time],"m
m"))=[Form
s]![FSales
Stock]![St
artMonth] OR [Forms]![FSalesStock]![Sta
rtMonth] IS Null))
)
UNION
Select CountryID, StateID, KindID, Null as PAStart, Price/Area AS PAEnd
From TbMain
Where (
(([TBMain.Time]=Forms!FSal
esStock!Re
portDateEn
d) OR Forms!FSalesStock!ReportDa
teEnd IS Null)
And (((Format([TBMain.Time],"y
yyy"))=[Fo
rms]![FSal
esStock]![
EndYear1] OR [Forms]![FSalesStock]![End
Year1] IS Null))
And (((Format([TBMain.Time],"y
yyy"))=[Fo
rms]![FSal
esStock]![
EndMonthYe
ar] OR [Forms]![FSalesStock]![End
MonthYear]
IS Null))
And (((Format([TBMain.Time],"m
m"))=[Form
s]![FSales
Stock]![En
dMonth] OR [Forms]![FSalesStock]![End
Month] IS Null))
)
)
GROUP BY TbMain.CountryID, TbMain.StateID, TbMain.KindID) AS T;
I can not run the query for the null values ... i get an error " This expression is typed incorrectly or it is too complex to be evaluated"
Note when i pick a date FOR ReportDateStart and ReportDateEnd the query work fine ?
thanks
Start Free Trial