jennypretty
IS-IT--Management
Hello friends,
I am trying to calculate the NUMERIC fields together but it generate an error "type mismatch", at this line : aRemaining(i) = rs2.Fields(5) - (rs1.Fields(4) + rs2.Fields(4))
totODCstra, incTotal, totalAl fields are all numeric. There are a few Nulls rows.
Below is part of the script, can you please help?
Thanks,
Jenny.
rsStr1 = "SELECT job_id, job_title, Sum(con_exp.la) AS totla, Sum(con_exp.ODC + con_exp.tra) AS totODCstra, Sum(con_exp.incTotal) AS totinc " & _
"FROM con_exp, proj " & _
"where proj.proj_num = '" & prjValue & "' " & _
"and periodfrom < (select jen_begin_date from jen_date where jen_date_id = " & jenValue & ") " & _
"and con_exp.proj_Id = proj.proj_Id " & _
"GROUP BY job_id, job_title order by job_id"
rsStr2 = "SELECT job_id, job_title, la, (odc + tra) as odcstra, incTotal, totalAl " & _
"FROM con_exp, proj " & _
"where proj.proj_num = '" & prjValue & "' " & _
"and periodfrom between (select jen_begin_date from jen_date where jen_date_id = " & jenValue & ") " & _
"and (select jen_end_date from jen_date where jen_date_id = " & jenValue & ")" & _
"and con_exp.proj_Id = proj.proj_Id " & _
"order by job_id"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open rsStr1, dbConn, adOpenForwardOnly, adLockReadOnly, 0
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.Open rsStr2, dbConn, adOpenForwardOnly, adLockReadOnly, 0
'Build an array for the field category and series arrays.
ReDim aRemaining(1)
ReDim ala(1)
ReDim alaPrior(1)
ReDim aOdc(1)
ReDim aOdcPrior(1)
ReDim aSubNames(1)
Dim i
i = 0
Do While Not rs1.EOF or Not rs2.EOF
if (i > 0) then
ReDim Preserve aRemaining(i + 1)
ReDim Preserve ala(i + 1)
ReDim Preserve alaPrior(i + 1)
ReDim Preserve aOdc(i + 1)
ReDim Preserve aOdcPrior(i + 1)
ReDim Preserve aSubNames(i + 1)
end if
'
' NOTE: If not records are displayed check that the first field values are unique.
'
if (not rs1.EOF) then
aSubNames(i) = rs1.Fields(1)
alaPrior(i) = rs1.Fields(2)
aOdcPrior(i) = rs1.Fields(3)
end if
if (not rs2.EOF) then
aSubNames(i) = rs2.Fields(1)
ala(i) = rs2.Fields(2)
aOdc(i) = rs2.Fields(3)
aRemaining(i) = rs2.Fields(5) - (rs1.Fields(4) + rs2.Fields(4))
end if
I am trying to calculate the NUMERIC fields together but it generate an error "type mismatch", at this line : aRemaining(i) = rs2.Fields(5) - (rs1.Fields(4) + rs2.Fields(4))
totODCstra, incTotal, totalAl fields are all numeric. There are a few Nulls rows.
Below is part of the script, can you please help?
Thanks,
Jenny.
rsStr1 = "SELECT job_id, job_title, Sum(con_exp.la) AS totla, Sum(con_exp.ODC + con_exp.tra) AS totODCstra, Sum(con_exp.incTotal) AS totinc " & _
"FROM con_exp, proj " & _
"where proj.proj_num = '" & prjValue & "' " & _
"and periodfrom < (select jen_begin_date from jen_date where jen_date_id = " & jenValue & ") " & _
"and con_exp.proj_Id = proj.proj_Id " & _
"GROUP BY job_id, job_title order by job_id"
rsStr2 = "SELECT job_id, job_title, la, (odc + tra) as odcstra, incTotal, totalAl " & _
"FROM con_exp, proj " & _
"where proj.proj_num = '" & prjValue & "' " & _
"and periodfrom between (select jen_begin_date from jen_date where jen_date_id = " & jenValue & ") " & _
"and (select jen_end_date from jen_date where jen_date_id = " & jenValue & ")" & _
"and con_exp.proj_Id = proj.proj_Id " & _
"order by job_id"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open rsStr1, dbConn, adOpenForwardOnly, adLockReadOnly, 0
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.Open rsStr2, dbConn, adOpenForwardOnly, adLockReadOnly, 0
'Build an array for the field category and series arrays.
ReDim aRemaining(1)
ReDim ala(1)
ReDim alaPrior(1)
ReDim aOdc(1)
ReDim aOdcPrior(1)
ReDim aSubNames(1)
Dim i
i = 0
Do While Not rs1.EOF or Not rs2.EOF
if (i > 0) then
ReDim Preserve aRemaining(i + 1)
ReDim Preserve ala(i + 1)
ReDim Preserve alaPrior(i + 1)
ReDim Preserve aOdc(i + 1)
ReDim Preserve aOdcPrior(i + 1)
ReDim Preserve aSubNames(i + 1)
end if
'
' NOTE: If not records are displayed check that the first field values are unique.
'
if (not rs1.EOF) then
aSubNames(i) = rs1.Fields(1)
alaPrior(i) = rs1.Fields(2)
aOdcPrior(i) = rs1.Fields(3)
end if
if (not rs2.EOF) then
aSubNames(i) = rs2.Fields(1)
ala(i) = rs2.Fields(2)
aOdc(i) = rs2.Fields(3)
aRemaining(i) = rs2.Fields(5) - (rs1.Fields(4) + rs2.Fields(4))
end if