SELECT [downtime 1].Date
, [downtime 1].DESCRIPTION
, Left([description],6) AS linetype
, [downtime 1].[reason code]
, [downtime 1].comments
, [downtime 1].duration
, [downtime 1].dtstart
, [downtime 1].dtfinish
, [downtime 1].dtevent
, [downtime 1].[start time]
, [downtime 1].[finish time]
, [downtime 1].shift
FROM [downtime 1]
WHERE [downtime 1].shift=[Forms]![Downtime Report]![Combo58] OR
[Forms]![Downtime Report]![Combo58] is Null
I suspect that the error is occuring in the DownTime 1 query.
Try the following expression:
IIf(IsDate([Start Time]),Null
, IIF(Hour([Start Time]) Between 7 And 14, 1,
IIf(Hour([start time]) Between 15 And 22, 2, 3))
Is Start Time a dateTime field or is it a string that looks like a time?
IF the latter you could have data that cannot be interpreted as a time
and therefore is causing an error. ISDATE will test the value in Start
Time and make sure it is a valid DateTime or a string that can be
interpreted as a valid DateTime.
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
Here is the SQL:
SELECT [downtime 1].Date, [downtime 1].DESCRIPTION, Left([description],6) AS
linetype, [downtime 1].[reason code], [downtime 1].comments, [downtime
1].duration, [downtime 1].dtstart, [downtime 1].dtfinish, [downtime
1].dtevent, [downtime 1].[start time], [downtime 1].[finish time], [downtime
1].shift
FROM [downtime 1]
WHERE ((([downtime 1].shift)=IIf([Forms]![Downtime Report]![Combo58] Is Not
Null,[Forms]![Downtime Report]![Combo58],nz([shift],"*"))));
The failure is in the WHERE statement...this will work if I take it out, but
fails no matter what I put in it.
Jerry Whittle said:
What is the criteria that you are attempting to use?
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
:
I have a query that calculates a shift number by looking at the start time of
an event: shift:
IIf(DateDiff("h",#12:00:00 AM#,[start time]) Between 7 And
14,"1st",IIf(DateDiff("h",#12:00:00 AM#,[start time]) Between 15 And
22,"2nd","3rd"))
Now, if I try to criteria against this output, I get a type mismatch. No
matter what I try. I have tried to force a CStr, Cint (by changing 1st to
1), but nothing seems to make a difference.