I have a form with several unbound search controls in the header. I have two queries to get the row sources for two of those controls (combo boxes). Both of these queries reference other controls in the same form with an IIF statement to determine which records to pull.
One of the queries is working and the other is not. It returns an error "...does not recognize 'Forms!IMT!Dept' as a valid field name or expression."
Here are the two queries:
WORKING:
Expand|Select|Wrap|Line Numbers
- SELECT department
- FROM ideas
- WHERE IIf(Forms!IMT!Care=True,([ideas].department) Like "CC*",([ideas].department) Like "*")
- GROUP BY ([ideas].department);
Expand|Select|Wrap|Line Numbers
- SELECT TEAMS
- FROM qryEmpGroups
- WHERE IIf(Forms!IMT!Dept IS NULL, [qryEmpGroups].[TEAMS] LIKE "*",[qryEmpGroups].[DEPTS] = Forms!IMT!Dept )
- AND ((qryEmpGroups.TEAMS) Not Like "*exchange*" And (qryEmpGroups.TEAMS) Not Like "*leave*")
- GROUP BY (qryEmpGroups.[TEAMS])
- ORDER BY (qryEmpGroups.[TEAMS]);
I tried replacing the control name Dept with the control name Care and it still didn't work... the error then said it didn't recognize 'Care'.
I don't think it's relevant but qryEmpGroups is a query, where ideas is a table. I may have spoken too soon when I said this. As an experiment, I saved the results of qryEmpGroups to a table and referenced that instead of the query. It's unstable but as long as Dept is null, I'm getting results in the Teams combo box. :/
I'm stumped! What am I missing?