I have a query that runs fine in datasheet view but when attached to report it bombs.

It has to be related to the expression field I put in to select to proper types from two different tables. (EXP1

Hear is the code.

SELECT Count(qryExamErrorsByDate.LicenseNum) AS CountOfLicenseNum, Sum(qryExamErrorsByDate.REFUNDS) AS SumOfREFUNDS, qryExamErrorsByDate.ReportingMonth, IIf(IsNull(dbo_dcd2009Licensees.LicenseType),[dbo_2009ddlcDDL-Licensees2].LicenseType,dbo_dcd2009Licensees.LicenseType) AS expr1
FROM qryExamErrorsByDate
GROUP BY qryExamErrorsByDate.ReportingMonth, qryExamErrorsByDate.[dbo_2009ddlcDDL-Licensees2].LicenseType, qryExamErrorsByDate.dbo_dcd2009Licensees.LicenseTy pe, IIf(IsNull(dbo_dcd2009Licensees.LicenseType),[dbo_2009ddlcDDL-Licensees2].LicenseType,dbo_dcd2009Licensees.LicenseType);

Any help would really be appreciated.

Thanks