Question : Expression too complex to be evaluated

Hello,

I am passing values from fields in a form to criteria in a query.  When using "*" as the field value for the date field, I receive an error message "Expression too complex to be evaluated".

The original expression was:
([tblPressStatement].[PressStatementDate])>[Forms]![frmReportBuilder]![PressStatementDateGreaterThan] And ([tblPressStatement].[PressStatementDate])<[Forms]![frmReportBuilder]![PressStatementDateLessThan])

I determined the when a wildcard is passed as critiera, I get the error (in other words if dates are passed in both fields all is well).  So, I tried the following expression with same error message.

Thanks for your help,
Dusty

IIf([Forms]![frmReportBuilder]![PressStatementDateGreaterThan]="*" And [Forms]![frmReportBuilder]![PressStatementDateLessThan]="*",Like "*",IIf([Forms]![frmReportBuilder]![PressStatementDateGreaterThan]="*",IIf([Forms]![frmReportBuilder]![PressStatementDateLessThan]="*",([tblPressStatement].[PressStatementDate])>[Forms]![frmReportBuilder]![PressStatementDateGreaterThan],([tblPressStatement].[PressStatementDate])>[Forms]![frmReportBuilder]![PressStatementDateGreaterThan] And ([tblPressStatement].[PressStatementDate])<[Forms]![frmReportBuilder]![PressStatementDateLessThan])))

Answer : Expression too complex to be evaluated

You can't use wildcards for dates.
If you want an option to 'select all dates' then you have to test explicitly for the value you are using to denote that.
In many cases the user would just leave the date field empty because you cannot use invalid dates in a field that is supposed to be date field.

So you do something like....

where (tbl.datefield>forms!formname!startdate or isnull(forms!formname!startdate)) and .....
Random Solutions  
 
programming4us programming4us