L
Leslie Isaacs
Hello All
Yesterday I created the following query, which worked fine - took about 1-2
seconds to run.
Today, running the same, unaltered query, I get 'Overflow' and the query
doesn't run.
I have compacted and repaired the mdb, closed other applications, no effect.
How can the query be generating an 'overflow' today when it didn't
yetsreday?
Irrespective of the answer to that question, can anyone see how I could
simplify the query to make it run - today, tomorrow and the next day!
Thanks
Les
The query:
SELECT Staff.[staff name], Staff.[hours per week],
[montot]+[tuetot]+[wedtot]+[thutot]+[fritot]+[sattot] AS [calc hrs], [hours
per week]-[calc hrs] AS [hrs disc], Staff.[days per week], Staff.holidays,
IIf([holidays]="1",4*[hours per week]+([hours per week]/[calc
days]),IIf([holidays]="2",5*[hours per week],IIf([holidays]="3",5*[hours per
week]+([hours per week]/[calc days]),IIf([holidays]="4",6*[hours per
week],0)))) AS [calc hol hrs], Staff.[tax code], [calc hol hrs]-[tax code]
AS [hols disc], (IIf([mon pm hrs] Is Null,0,DateDiff("n",CDate(Left([mon pm
hrs],InStr([mon pm hrs],"-")-1)),CDate(Mid([mon pm hrs],InStr([mon pm
hrs],"-")+1))))+IIf([mon am hrs] Is Null,0,DateDiff("n",CDate(Left([mon am
hrs],InStr([mon am hrs],"-")-1)),CDate(Mid([mon am hrs],InStr([mon am
hrs],"-")+1)))))/60 AS montot, (IIf([tue pm hrs] Is
Null,0,DateDiff("n",CDate(Left([tue pm hrs],InStr([tue pm
hrs],"-")-1)),CDate(Mid([tue pm hrs],InStr([tue pm hrs],"-")+1))))+IIf([tue
am hrs] Is Null,0,DateDiff("n",CDate(Left([tue am hrs],InStr([tue am
hrs],"-")-1)),CDate(Mid([tue am hrs],InStr([tue am hrs],"-")+1)))))/60 AS
tuetot, (IIf([wed pm hrs] Is Null,0,DateDiff("n",CDate(Left([wed pm
hrs],InStr([wed pm hrs],"-")-1)),CDate(Mid([wed pm hrs],InStr([wed pm
hrs],"-")+1))))+IIf([wed am hrs] Is Null,0,DateDiff("n",CDate(Left([wed am
hrs],InStr([wed am hrs],"-")-1)),CDate(Mid([wed am hrs],InStr([wed am
hrs],"-")+1)))))/60 AS wedtot, (IIf([thu pm hrs] Is
Null,0,DateDiff("n",CDate(Left([thu pm hrs],InStr([thu pm
hrs],"-")-1)),CDate(Mid([thu pm hrs],InStr([thu pm hrs],"-")+1))))+IIf([thu
am hrs] Is Null,0,DateDiff("n",CDate(Left([thu am hrs],InStr([thu am
hrs],"-")-1)),CDate(Mid([thu am hrs],InStr([thu am hrs],"-")+1)))))/60 AS
thutot, (IIf([fri pm hrs] Is Null,0,DateDiff("n",CDate(Left([fri pm
hrs],InStr([fri pm hrs],"-")-1)),CDate(Mid([fri pm hrs],InStr([fri pm
hrs],"-")+1))))+IIf([fri am hrs] Is Null,0,DateDiff("n",CDate(Left([fri am
hrs],InStr([fri am hrs],"-")-1)),CDate(Mid([fri am hrs],InStr([fri am
hrs],"-")+1)))))/60 AS fritot, IIf([sat am hrs] Is Null,0,0) AS sattot,
IIf([montot]>0,1,0)+IIf([tuetot]>0,1,0)+IIf([wedtot]>0,1,0)+IIf([thutot]>0,1,0)+IIf([fritot]>0,1,0)+IIf([sattot]>0,1,0)
AS [calc days], [calc days]-[days per week] AS [days disc]
FROM Staff;
Yesterday I created the following query, which worked fine - took about 1-2
seconds to run.
Today, running the same, unaltered query, I get 'Overflow' and the query
doesn't run.
I have compacted and repaired the mdb, closed other applications, no effect.
How can the query be generating an 'overflow' today when it didn't
yetsreday?
Irrespective of the answer to that question, can anyone see how I could
simplify the query to make it run - today, tomorrow and the next day!
Thanks
Les
The query:
SELECT Staff.[staff name], Staff.[hours per week],
[montot]+[tuetot]+[wedtot]+[thutot]+[fritot]+[sattot] AS [calc hrs], [hours
per week]-[calc hrs] AS [hrs disc], Staff.[days per week], Staff.holidays,
IIf([holidays]="1",4*[hours per week]+([hours per week]/[calc
days]),IIf([holidays]="2",5*[hours per week],IIf([holidays]="3",5*[hours per
week]+([hours per week]/[calc days]),IIf([holidays]="4",6*[hours per
week],0)))) AS [calc hol hrs], Staff.[tax code], [calc hol hrs]-[tax code]
AS [hols disc], (IIf([mon pm hrs] Is Null,0,DateDiff("n",CDate(Left([mon pm
hrs],InStr([mon pm hrs],"-")-1)),CDate(Mid([mon pm hrs],InStr([mon pm
hrs],"-")+1))))+IIf([mon am hrs] Is Null,0,DateDiff("n",CDate(Left([mon am
hrs],InStr([mon am hrs],"-")-1)),CDate(Mid([mon am hrs],InStr([mon am
hrs],"-")+1)))))/60 AS montot, (IIf([tue pm hrs] Is
Null,0,DateDiff("n",CDate(Left([tue pm hrs],InStr([tue pm
hrs],"-")-1)),CDate(Mid([tue pm hrs],InStr([tue pm hrs],"-")+1))))+IIf([tue
am hrs] Is Null,0,DateDiff("n",CDate(Left([tue am hrs],InStr([tue am
hrs],"-")-1)),CDate(Mid([tue am hrs],InStr([tue am hrs],"-")+1)))))/60 AS
tuetot, (IIf([wed pm hrs] Is Null,0,DateDiff("n",CDate(Left([wed pm
hrs],InStr([wed pm hrs],"-")-1)),CDate(Mid([wed pm hrs],InStr([wed pm
hrs],"-")+1))))+IIf([wed am hrs] Is Null,0,DateDiff("n",CDate(Left([wed am
hrs],InStr([wed am hrs],"-")-1)),CDate(Mid([wed am hrs],InStr([wed am
hrs],"-")+1)))))/60 AS wedtot, (IIf([thu pm hrs] Is
Null,0,DateDiff("n",CDate(Left([thu pm hrs],InStr([thu pm
hrs],"-")-1)),CDate(Mid([thu pm hrs],InStr([thu pm hrs],"-")+1))))+IIf([thu
am hrs] Is Null,0,DateDiff("n",CDate(Left([thu am hrs],InStr([thu am
hrs],"-")-1)),CDate(Mid([thu am hrs],InStr([thu am hrs],"-")+1)))))/60 AS
thutot, (IIf([fri pm hrs] Is Null,0,DateDiff("n",CDate(Left([fri pm
hrs],InStr([fri pm hrs],"-")-1)),CDate(Mid([fri pm hrs],InStr([fri pm
hrs],"-")+1))))+IIf([fri am hrs] Is Null,0,DateDiff("n",CDate(Left([fri am
hrs],InStr([fri am hrs],"-")-1)),CDate(Mid([fri am hrs],InStr([fri am
hrs],"-")+1)))))/60 AS fritot, IIf([sat am hrs] Is Null,0,0) AS sattot,
IIf([montot]>0,1,0)+IIf([tuetot]>0,1,0)+IIf([wedtot]>0,1,0)+IIf([thutot]>0,1,0)+IIf([fritot]>0,1,0)+IIf([sattot]>0,1,0)
AS [calc days], [calc days]-[days per week] AS [days disc]
FROM Staff;