I need to be able to set the criteria of one field of a query based on a table value. I have a table called CRITERIA, with a text field called DATE_CRITERIA. There is one record, with a value of 2013Q3. I will use a form to set this value to other strings.
In my query, I have this in as one of the fields:
PERIOD_1: "SUM(IIF([QUARTER]='" & DLookUp("[DATE_CRITERIA]","CRITERIA") & "',[AMOUNT],0))"
When I run the query, I don't get an error message, but my "PERIOD_1" column just has SUM(IIF([QUARTER]='2013Q3',[AMOUNT],0)) filled the whole way down.
If I enter it like this (without the Dlookup), there's no problem:
PERIOD_1: Sum(IIf([QUARTER]="2013Q3",[AMOUNT],0))
Can someone please let me know what I'm doing wrong? Thanks!