specialist
Programmer
Greetings-
I am trying to write an error handler using an If/Then statement in order to prevent the below error
in case the value is zero. The idea here, is to determine the MTTR (Mean Time to Repair) in a table on an ASP page.
I have the formula working, but when I select a start and end date where the end result = zero, I get the following error:
Microsoft VBScript runtime error '800a0006'
Overflow
/test/SQLtest.asp, line 312
Here is the MTTR calculation used in order to display the result. This works perfectly by the way. If no records meet the criteria, I get the above mentioned error.
------------------------
sqlstr = "SELECT datediff(d, BeginingDate2, FinishDate2) AS totalday FROM tblInfo WHERE FinishDate2 BETWEEN '" & StartDate & "' AND '" & EndDate & "' AND Category = 3"
Set qryMTTR_Ala1 = db.Execute(sqlstr)
diffDay = 0
totdiffDay=0
Do While Not qryMTTR_Ala1.EOF
diffDay = qryMTTR_Ala1.fields("totalday") '*** each record's datediff from database ***
totdiffDay = totdiffDay + diffDay '*** accumulates all datediff records ***
qryMTTR_Ala1.MoveNext
Loop
-------------------------
result:
(Line 312) <%response.write round(totdiffDay/qryCA("prnRecs"))%>
I tried the following statment which returned the error:
If qryMTTR_Ala1 >= 1 Then
Value = qryCA("prnRecs")
Else
Value = 0
End If
FYI qryCA("prnRecs")) = Count of records.
Any advice on how to correct this would be great and warmly welcomed. Like I said, the MTTR calculation works very well, only problem is this error if the result is zero. Thank you in advance for any assistance.
Happy Holidays to all,
Mike
I am trying to write an error handler using an If/Then statement in order to prevent the below error
in case the value is zero. The idea here, is to determine the MTTR (Mean Time to Repair) in a table on an ASP page.
I have the formula working, but when I select a start and end date where the end result = zero, I get the following error:
Microsoft VBScript runtime error '800a0006'
Overflow
/test/SQLtest.asp, line 312
Here is the MTTR calculation used in order to display the result. This works perfectly by the way. If no records meet the criteria, I get the above mentioned error.
------------------------
sqlstr = "SELECT datediff(d, BeginingDate2, FinishDate2) AS totalday FROM tblInfo WHERE FinishDate2 BETWEEN '" & StartDate & "' AND '" & EndDate & "' AND Category = 3"
Set qryMTTR_Ala1 = db.Execute(sqlstr)
diffDay = 0
totdiffDay=0
Do While Not qryMTTR_Ala1.EOF
diffDay = qryMTTR_Ala1.fields("totalday") '*** each record's datediff from database ***
totdiffDay = totdiffDay + diffDay '*** accumulates all datediff records ***
qryMTTR_Ala1.MoveNext
Loop
-------------------------
result:
(Line 312) <%response.write round(totdiffDay/qryCA("prnRecs"))%>
I tried the following statment which returned the error:
If qryMTTR_Ala1 >= 1 Then
Value = qryCA("prnRecs")
Else
Value = 0
End If
FYI qryCA("prnRecs")) = Count of records.
Any advice on how to correct this would be great and warmly welcomed. Like I said, the MTTR calculation works very well, only problem is this error if the result is zero. Thank you in advance for any assistance.
Happy Holidays to all,
Mike