Hey everyone,
I've searched the forums, and found some stuff on this topic, but somehow it doesn't seem to quite answer my question.
I'm creating a db in two parts. The users have part One already and use it. It's been going pretty well, but then this problem occured.
I made a copy of the db to work on the second part, which i plan to export to the first part when it is completed.
Anyway, yesterday the first part did something strange. A user was trying to run a report from a combo box I'd created. The report prompts you to type in a date for the report, and calculates information based on that date. She typed in the date 11/1/02 and got this error message:
"This expression is typed incorrectly or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables"
So I thought something must be going on with the query. I ran the query the report is based on and it first displays the results, then an error message pops up immediately that says "Data type mismatch in criteria expression."
I tried the same query and report on the part of the db I was working on, and it worked fine, so I exported it to the first db. Same error. I tried running the queries that are part of the structure of the query the report is based on, and that worked fine.
The sql for the query the report is based on is:
SELECT qryProbations.DateToday, qryProbations.Employee, tblEmployees.PositionNo, tblPositions.ClassCode, qryProbations.DateHired, qryProbations.ProbationStatus, qrySupervisors.Supervisor,
IIf([qryProbations].[ProbationStatus]="no",IIf([qryProbations].[mdatetoday]-[qryProbations].[mhire]<=0,12+([qryProbations].[mdatetoday]-[qryProbations].[mhire]),[qryProbations].[mdatetoday]-[qryProbations].[mhire])) AS EvalAnnual,
IIf([EvalAnnual]=12,"Annual","Not Annual") AS EvalType
FROM qrySupervisors INNER JOIN (tblPositions RIGHT JOIN (qryProbations INNER JOIN tblEmployees ON qryProbations.TDNo = tblEmployees.TDNo) ON tblPositions.PositionNo = tblEmployees.PositionNo) ON qrySupervisors.TDNo = tblEmployees.TDNo
WHERE (((qryProbations.ProbationStatus)="No") AND ((IIf([qryProbations].[ProbationStatus]="no",IIf([qryProbations].[mdatetoday]-[qryProbations].[mhire]<=0,12+([qryProbations].[mdatetoday]-[qryProbations].[mhire]),[qryProbations].[mdatetoday]-[qryProbations].[mhire])))=12));
the SQL for qryProbations is:
PARAMETERS [Enter_Report_Date] DateTime;
SELECT [Enter_Report_Date] AS DateToday, tblEmployees.TDNo, tblEmployees.[Last] & ", " & [First] AS Employee, tblEmployees.HireDate AS DateHired, Format([DateHired],"m") AS Mhire, tblEmployees.ProbDate AS ProbationDate, IIf([ProbationDate] Is Null,[mDateToday],Format([ProbationDate],"m")) AS MProbation, Format([DateToday],"m") AS MDateToday, IIf([ProbationStatus]="Yes",IIf([MDateToday]-[MProbation]<0,12+([MDateToday]-[MProbation]),IIf([MDateToday]-[MProbation]=0,12,[MDateToday]-[MProbation])),"0") AS MonthProbation, IIf([ProbationDate]>[DateToday],"Probation date is after today",Format([DateToday]-[ProbationDate],"yy")) AS YearProbation, IIf([ProbationDate] Is Null,"No",IIf(IsNumeric([YearProbation]),IIf([YearProbation]>0,"No","Yes"),"No")) AS ProbationStatus, IIf([ProbationStatus]="no",IIf([mdatetoday]-[mhire]<=0,12+([mdatetoday]-[mhire]),[mdatetoday]-[mhire])) AS EvalAnnual
FROM tblEmployees;
I wish I knew more about sql... I don't, though... but i think it's really strange that the queries are exactly the same as the ones in my copy of the database which works.
Any help is greatly appreciated. Please let me know if I need to clarify anything.
Thanks in advance. If you've made it this far, wow.
--Sara
I've searched the forums, and found some stuff on this topic, but somehow it doesn't seem to quite answer my question.
I'm creating a db in two parts. The users have part One already and use it. It's been going pretty well, but then this problem occured.
I made a copy of the db to work on the second part, which i plan to export to the first part when it is completed.
Anyway, yesterday the first part did something strange. A user was trying to run a report from a combo box I'd created. The report prompts you to type in a date for the report, and calculates information based on that date. She typed in the date 11/1/02 and got this error message:
"This expression is typed incorrectly or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables"
So I thought something must be going on with the query. I ran the query the report is based on and it first displays the results, then an error message pops up immediately that says "Data type mismatch in criteria expression."
I tried the same query and report on the part of the db I was working on, and it worked fine, so I exported it to the first db. Same error. I tried running the queries that are part of the structure of the query the report is based on, and that worked fine.
The sql for the query the report is based on is:
SELECT qryProbations.DateToday, qryProbations.Employee, tblEmployees.PositionNo, tblPositions.ClassCode, qryProbations.DateHired, qryProbations.ProbationStatus, qrySupervisors.Supervisor,
IIf([qryProbations].[ProbationStatus]="no",IIf([qryProbations].[mdatetoday]-[qryProbations].[mhire]<=0,12+([qryProbations].[mdatetoday]-[qryProbations].[mhire]),[qryProbations].[mdatetoday]-[qryProbations].[mhire])) AS EvalAnnual,
IIf([EvalAnnual]=12,"Annual","Not Annual") AS EvalType
FROM qrySupervisors INNER JOIN (tblPositions RIGHT JOIN (qryProbations INNER JOIN tblEmployees ON qryProbations.TDNo = tblEmployees.TDNo) ON tblPositions.PositionNo = tblEmployees.PositionNo) ON qrySupervisors.TDNo = tblEmployees.TDNo
WHERE (((qryProbations.ProbationStatus)="No") AND ((IIf([qryProbations].[ProbationStatus]="no",IIf([qryProbations].[mdatetoday]-[qryProbations].[mhire]<=0,12+([qryProbations].[mdatetoday]-[qryProbations].[mhire]),[qryProbations].[mdatetoday]-[qryProbations].[mhire])))=12));
the SQL for qryProbations is:
PARAMETERS [Enter_Report_Date] DateTime;
SELECT [Enter_Report_Date] AS DateToday, tblEmployees.TDNo, tblEmployees.[Last] & ", " & [First] AS Employee, tblEmployees.HireDate AS DateHired, Format([DateHired],"m") AS Mhire, tblEmployees.ProbDate AS ProbationDate, IIf([ProbationDate] Is Null,[mDateToday],Format([ProbationDate],"m")) AS MProbation, Format([DateToday],"m") AS MDateToday, IIf([ProbationStatus]="Yes",IIf([MDateToday]-[MProbation]<0,12+([MDateToday]-[MProbation]),IIf([MDateToday]-[MProbation]=0,12,[MDateToday]-[MProbation])),"0") AS MonthProbation, IIf([ProbationDate]>[DateToday],"Probation date is after today",Format([DateToday]-[ProbationDate],"yy")) AS YearProbation, IIf([ProbationDate] Is Null,"No",IIf(IsNumeric([YearProbation]),IIf([YearProbation]>0,"No","Yes"),"No")) AS ProbationStatus, IIf([ProbationStatus]="no",IIf([mdatetoday]-[mhire]<=0,12+([mdatetoday]-[mhire]),[mdatetoday]-[mhire])) AS EvalAnnual
FROM tblEmployees;
I wish I knew more about sql... I don't, though... but i think it's really strange that the queries are exactly the same as the ones in my copy of the database which works.
Any help is greatly appreciated. Please let me know if I need to clarify anything.
Thanks in advance. If you've made it this far, wow.
--Sara