Having a problem refering to a string from a form in a union query. It works fine as a non union.
This union query works
If I do add a where clause
It doesn't work - The MS Jet Database does not recognize [forms]![frmMain].[txtBannerYear] as a valid field name or expression.
However, if I run the same query and remove the part before the union, it works fine.
The union query works with hard coded value WHERE YEAR < "2009"
I also tried UNION ALL, didn't work either. Any thoughts how I can rewrite to allow query to refer to a value from the form?
This union query works
Code:
SELECT *
FROM qryAPPTotals in '\\imageserver\Application\AppStats.mdb'
UNION SELECT Left(Sort_Status,1), Year, Stu_Pop, Status, iif(left(Sort_Status,1) in ('3','5'),Total/100,Total), iif(left(Sort_Status,1) in ('3','5'),Dom/100,Dom), iif(left(Sort_Status,1) in ('3','5'),Intl/100,Intl)
From GDomIntl
ORDER BY 3, 2, 1;
If I do add a where clause
Code:
SELECT *
FROM qryAPPTotals in '\\imageserver\Application\AppStats.mdb'
UNION SELECT Left(Sort_Status,1), Year, Stu_Pop, Status, iif(left(Sort_Status,1) in ('3','5'),Total/100,Total), iif(left(Sort_Status,1) in ('3','5'),Dom/100,Dom), iif(left(Sort_Status,1) in ('3','5'),Intl/100,Intl)
From GDomIntl
[red]WHERE YEAR < [forms]![frmMain].[txtBannerYear][/red]
ORDER BY 3, 2, 1;
It doesn't work - The MS Jet Database does not recognize [forms]![frmMain].[txtBannerYear] as a valid field name or expression.
However, if I run the same query and remove the part before the union, it works fine.
Code:
SELECT Left(Sort_Status,1), Year, Stu_Pop, Status, iif(left(Sort_Status,1) in ('3','5'),Total/100,Total), iif(left(Sort_Status,1) in ('3','5'),Dom/100,Dom), iif(left(Sort_Status,1) in ('3','5'),Intl/100,Intl)
From GDomIntl
[red]WHERE YEAR < [forms]![frmMain].[txtBannerYear][/red]
ORDER BY 3, 2, 1;
The union query works with hard coded value WHERE YEAR < "2009"
I also tried UNION ALL, didn't work either. Any thoughts how I can rewrite to allow query to refer to a value from the form?