I'm working on an expression that throws a data type mismatch only when in the Where statement.
Current: IIf(Nz([ISRS_VAL_ST_CAPP_LVL].[NBR_YRS_VALID],99)>0,
IIf(DateAdd("yyyy",CInt(Nz([ISRS_VAL_ST_CAPP_LVL].[NBR_YRS_VALID],99))
,CVDate(Format(Nz([TEST_DATE],19891231),"0000-00-00")))>Now(),True,False),True)
As you can see, I've added an Nz() function to every reference and even tried to cast CBool() on the whole statement, but it still throws the data type mismatch.
I've pinpointed it down to this expression and the expression works exactly as expected in Select statement. When I add it to the Where statement looking to return only True, the error occurs.
What could I be missing?
Update: full query for those interested
SELECT Student.TECH_ID, Student.CAPP_LVL, Values.ABBR, Values.SHORT_DESC, Values.LONG_DESC, Values.GROUP_NBR, Values.NBR_YRS_VALID, Student.SEQ_NBR, Student.CAPP_LVL_SCORE, Student.TEST_DATE, IIf(Nz([Values].[NBR_YRS_VALID],99)>0,IIf(DateAdd("yyyy",CInt([Values].[NBR_YRS_VALID]),CVDate(Format([TEST_DATE],"0000-00-00")))>Now(),True,False),True) AS [Current], Values.END_DATE, Student.LOAD_DATE
FROM Student INNER JOIN Values ON Student.CAPP_LVL = Values.CAPP_LVL
WHERE (((Values.ABBR)<>"MTHB") AND ((Values.END_DATE) Like "9999*"))
ORDER BY Student.TECH_ID, Student.CAPP_LVL, Student.SEQ_NBR;