One more ! Calculating Recordset Values

R

RobA

Can anyone point me in the direction of some guidance for handling recordset
values.

I am trying to calculate a resultant value (total) of adding 2 values and
mulitplying by the third.

Eventually I wanted to get total for the resultant value (all the totals
added together) for the whole recordset!

<%
Dim Total
Do While not aScrRst.EOF
Do While not eScrRst.EOF
Do While not iScrRst.EOF
Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")

Response.Write "Total"

aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext


Loop
Loop
Loop
%>
 
P

p c

To anser your uestions, can you provide more informaion? How many
recordsets do you have? What's in each one? How are you retrieving the
records.

Give an example of what's in each value.

...PC
 
K

Kevin Spencer

<%
Dim Total
Dim GrandTotal
GrandTotal = 0
Do While not aScrRst.EOF
Do While not eScrRst.EOF
Do While not iScrRst.EOF
Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
GrandTotal = GrandTotal + Total

Response.Write "Total: " & Total

aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext

Loop
Loop
Loop
Response.Write "GrandTotal: " & GrandTotal

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.
 
R

RobA

There are 3 recordsets, each containing about 20 numeric values.

I was using the script below to retreive them, it was my attempt at
calculating them.
 
R

RobA

This is the code to I was using to retreive the recordsets.

aSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'A' AND iauID= " &
UID
Set aScrRst = objConn.Execute (aSQLstr)
eSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'E' AND iauID= " &
UID
Set eScrRst = objConn.Execute (aSQLstr)
iSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'I' AND iauID= " &
UID
Set iScrRst = objConn.Execute (aSQLstr)
 
S

Stefan B Rusynko

Validate your data types in each loop while testing using say:

<%
Do While not aScrRst.EOF
aScore = aScrRst("Score")
Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test line
Do While not eScrRst.EOF
eScore = eScrRst("Score")
Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test line
Do While not iScrRst.EOF
iScore = iScrRst("Score")
Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test line
Total = iScore + eScore * aScore
Response.Write "Total: " & Total & "<br>" 'test line
GrandTotal = GrandTotal + Total
iScrRst.MoveNext
eScrRst.MoveNext
aScrRst.MoveNext
Loop
Loop
Loop
Response.Write "GrandTotal: " & GrandTotal
%>

I suspect 1 of your loops may be returning an EOF since your logic is requiring all 3 recordsets to have 3 "identical" sets of
qualifying data in each loop (a null value or empty string in any recordset will also cause the loops to fail)

PS
Plus your logic will result in unreliable results since there is no attempt to order or group the recordset results in any
associated way that is consistent or related to iScore, eScore, or aScore as a group
So you will be doing math on 3 random numbers (depending on each recordset order returned)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thanks but I am still getting a type mismatch error.
| | > <%
| > Dim Total
| > Dim GrandTotal
| > GrandTotal = 0
| > Do While not aScrRst.EOF
| > Do While not eScrRst.EOF
| > Do While not iScrRst.EOF
| > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| > GrandTotal = GrandTotal + Total
| >
| > Response.Write "Total: " & Total
| >
| > aScrRst.MoveNext
| > eScrRst.MoveNext
| > iScrRst.MoveNext
| >
| > Loop
| > Loop
| > Loop
| > Response.Write "GrandTotal: " & GrandTotal
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > .Net Developer
| > A watched clock never boils.
| >
| >
| > | >> Can anyone point me in the direction of some guidance for handling
| >> recordset values.
| >>
| >> I am trying to calculate a resultant value (total) of adding 2 values and
| >> mulitplying by the third.
| >>
| >> Eventually I wanted to get total for the resultant value (all the totals
| >> added together) for the whole recordset!
| >>
| >> <%
| >> Dim Total
| >> Do While not aScrRst.EOF
| >> Do While not eScrRst.EOF
| >> Do While not iScrRst.EOF
| >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>
| >> Response.Write "Total"
| >>
| >> aScrRst.MoveNext
| >> eScrRst.MoveNext
| >> iScrRst.MoveNext
| >>
| >>
| >> Loop
| >> Loop
| >> Loop
| >> %>
| >>
| >
| >
|
|
 
R

RobA

Cheers for that Stefan,

I had been working along the same principle - but I must be getting
something wrong. I have included my script !!!
The db where the data is being drawn from requires a value for each of the
recordset fields (it is a , so there shouln't be a return of an EOF, this
page can't be ran until all the values are input. (although I am hoping a
value of 0 wont be returned as a NULL).

I just keep getting a

Type mismatch
/ia/calc01.asp, line 175

which seems to happen whenever I attempt any caluculations.

<%
Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal, Total,
aStrengthTotal

aTot = 0
eTot = 0
iTot = 0
pSubTot = 0
aStrengthSubTot = 0
pTotal = 0
SubTotal = 0
aStrengthTotal = 0

'Create Table Header
Response.Write "<Table align=center border=1 cellpadding=0 cellspacing=0>"
Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial Size=3>Score</TD><TD
WIDTH=60 ><FONT Face=Arial Size=3>Score</TD><TD WIDTH=120 ><FONT Face=Arial
Size=3>Potential Value</TD<TD WIDTH=120 ><TD><FONT Face=Arial
Size=3>Calculated Value</TD><TD WIDTH=120><FONT Face=Arial Size=3>Asset
Strength</TD></TR>"

' Start Processes
'Transfer recordset values to equation values
Do While not aScrRst.EOF
aTot = aScrRst("Score")
Do While not eScrRst.EOF
eTot = eScrRst("Score")
Do While not iScrRst.EOF
iTot = iScrRst("Score")





'The Calculated Value = 1st and 2nd scores added then multiplied by 3rd
(this calculation is where the error is returned)
SubTotal = aTot + eTot * eTot

'The Potential Value Sub Total = 3rd score multiplied by 20 mulitplied by
20
pSubTot = iTot * 20 * 20

'The Asset Strength Sub Total = Calculated Value devided by the Potential
Value multiplied 100
aStrengthSubTot = SubTotal / pSubTot * 100

'Total = The sum of all the SubTotals
Total = Total + Subtotal

'Potential Total
pTotal = pTotal + pSubTot


Response.Write "<Table align=center border=1 cellpadding=0 cellspacing=0>"

Response.Write "<TR ALIGN=CENTER>"

Response.Write "<TD WIDTH=60>"
Response.Write aTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=60>"
Response.Write eTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=60>"
Response.Write iTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write pSubTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write SubTotal
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write aStrength
Response.Write "</TD>"

Response.Write "</TR>"

Response.Write "<Table>"


aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext


Loop
Loop
Loop
Response.Write "Total=" & Total
Response.Write "Potential Total= " & PTotal
aStrengthTotal = Total /PTotal * 100
Response.Write "Asset Strength= " & aStrengthTotal


%>
Stefan B Rusynko said:
Validate your data types in each loop while testing using say:

<%
Do While not aScrRst.EOF
aScore = aScrRst("Score")
Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test line
Do While not eScrRst.EOF
eScore = eScrRst("Score")
Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test line
Do While not iScrRst.EOF
iScore = iScrRst("Score")
Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test line
Total = iScore + eScore * aScore
Response.Write "Total: " & Total & "<br>" 'test line
GrandTotal = GrandTotal + Total
iScrRst.MoveNext
eScrRst.MoveNext
aScrRst.MoveNext
Loop
Loop
Loop
Response.Write "GrandTotal: " & GrandTotal
%>

I suspect 1 of your loops may be returning an EOF since your logic is
requiring all 3 recordsets to have 3 "identical" sets of
qualifying data in each loop (a null value or empty string in any
recordset will also cause the loops to fail)

PS
Plus your logic will result in unreliable results since there is no
attempt to order or group the recordset results in any
associated way that is consistent or related to iScore, eScore, or aScore
as a group
So you will be doing math on 3 random numbers (depending on each recordset
order returned)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thanks but I am still getting a type mismatch error.
| | > <%
| > Dim Total
| > Dim GrandTotal
| > GrandTotal = 0
| > Do While not aScrRst.EOF
| > Do While not eScrRst.EOF
| > Do While not iScrRst.EOF
| > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| > GrandTotal = GrandTotal + Total
| >
| > Response.Write "Total: " & Total
| >
| > aScrRst.MoveNext
| > eScrRst.MoveNext
| > iScrRst.MoveNext
| >
| > Loop
| > Loop
| > Loop
| > Response.Write "GrandTotal: " & GrandTotal
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > .Net Developer
| > A watched clock never boils.
| >
| >
| > | >> Can anyone point me in the direction of some guidance for handling
| >> recordset values.
| >>
| >> I am trying to calculate a resultant value (total) of adding 2 values
and
| >> mulitplying by the third.
| >>
| >> Eventually I wanted to get total for the resultant value (all the
totals
| >> added together) for the whole recordset!
| >>
| >> <%
| >> Dim Total
| >> Do While not aScrRst.EOF
| >> Do While not eScrRst.EOF
| >> Do While not iScrRst.EOF
| >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>
| >> Response.Write "Total"
| >>
| >> aScrRst.MoveNext
| >> eScrRst.MoveNext
| >> iScrRst.MoveNext
| >>
| >>
| >> Loop
| >> Loop
| >> Loop
| >> %>
| >>
| >
| >
|
|
 
K

Kevin Spencer

What is the dat type of these fields?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

RobA said:
Cheers for that Stefan,

I had been working along the same principle - but I must be getting
something wrong. I have included my script !!!
The db where the data is being drawn from requires a value for each of the
recordset fields (it is a , so there shouln't be a return of an EOF, this
page can't be ran until all the values are input. (although I am hoping a
value of 0 wont be returned as a NULL).

I just keep getting a

Type mismatch
/ia/calc01.asp, line 175

which seems to happen whenever I attempt any caluculations.

<%
Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal, Total,
aStrengthTotal

aTot = 0
eTot = 0
iTot = 0
pSubTot = 0
aStrengthSubTot = 0
pTotal = 0
SubTotal = 0
aStrengthTotal = 0

'Create Table Header
Response.Write "<Table align=center border=1 cellpadding=0 cellspacing=0>"
Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial Size=3>Score</TD><TD
WIDTH=60 ><FONT Face=Arial Size=3>Score</TD><TD WIDTH=120 ><FONT
Face=Arial Size=3>Potential Value</TD<TD WIDTH=120 ><TD><FONT Face=Arial
Size=3>Calculated Value</TD><TD WIDTH=120><FONT Face=Arial Size=3>Asset
Strength</TD></TR>"

' Start Processes
'Transfer recordset values to equation values
Do While not aScrRst.EOF
aTot = aScrRst("Score")
Do While not eScrRst.EOF
eTot = eScrRst("Score")
Do While not iScrRst.EOF
iTot = iScrRst("Score")





'The Calculated Value = 1st and 2nd scores added then multiplied by 3rd
(this calculation is where the error is returned)
SubTotal = aTot + eTot * eTot

'The Potential Value Sub Total = 3rd score multiplied by 20 mulitplied by
20
pSubTot = iTot * 20 * 20

'The Asset Strength Sub Total = Calculated Value devided by the Potential
Value multiplied 100
aStrengthSubTot = SubTotal / pSubTot * 100

'Total = The sum of all the SubTotals
Total = Total + Subtotal

'Potential Total
pTotal = pTotal + pSubTot


Response.Write "<Table align=center border=1 cellpadding=0 cellspacing=0>"

Response.Write "<TR ALIGN=CENTER>"

Response.Write "<TD WIDTH=60>"
Response.Write aTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=60>"
Response.Write eTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=60>"
Response.Write iTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write pSubTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write SubTotal
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write aStrength
Response.Write "</TD>"

Response.Write "</TR>"

Response.Write "<Table>"


aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext


Loop
Loop
Loop
Response.Write "Total=" & Total
Response.Write "Potential Total= " & PTotal
aStrengthTotal = Total /PTotal * 100
Response.Write "Asset Strength= " & aStrengthTotal


%>
Stefan B Rusynko said:
Validate your data types in each loop while testing using say:

<%
Do While not aScrRst.EOF
aScore = aScrRst("Score")
Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test line
Do While not eScrRst.EOF
eScore = eScrRst("Score")
Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test line
Do While not iScrRst.EOF
iScore = iScrRst("Score")
Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test line
Total = iScore + eScore * aScore
Response.Write "Total: " & Total & "<br>" 'test line
GrandTotal = GrandTotal + Total
iScrRst.MoveNext
eScrRst.MoveNext
aScrRst.MoveNext
Loop
Loop
Loop
Response.Write "GrandTotal: " & GrandTotal
%>

I suspect 1 of your loops may be returning an EOF since your logic is
requiring all 3 recordsets to have 3 "identical" sets of
qualifying data in each loop (a null value or empty string in any
recordset will also cause the loops to fail)

PS
Plus your logic will result in unreliable results since there is no
attempt to order or group the recordset results in any
associated way that is consistent or related to iScore, eScore, or aScore
as a group
So you will be doing math on 3 random numbers (depending on each
recordset order returned)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thanks but I am still getting a type mismatch error.
| | > <%
| > Dim Total
| > Dim GrandTotal
| > GrandTotal = 0
| > Do While not aScrRst.EOF
| > Do While not eScrRst.EOF
| > Do While not iScrRst.EOF
| > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| > GrandTotal = GrandTotal + Total
| >
| > Response.Write "Total: " & Total
| >
| > aScrRst.MoveNext
| > eScrRst.MoveNext
| > iScrRst.MoveNext
| >
| > Loop
| > Loop
| > Loop
| > Response.Write "GrandTotal: " & GrandTotal
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > .Net Developer
| > A watched clock never boils.
| >
| >
| > | >> Can anyone point me in the direction of some guidance for handling
| >> recordset values.
| >>
| >> I am trying to calculate a resultant value (total) of adding 2
values and
| >> mulitplying by the third.
| >>
| >> Eventually I wanted to get total for the resultant value (all the
totals
| >> added together) for the whole recordset!
| >>
| >> <%
| >> Dim Total
| >> Do While not aScrRst.EOF
| >> Do While not eScrRst.EOF
| >> Do While not iScrRst.EOF
| >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>
| >> Response.Write "Total"
| >>
| >> aScrRst.MoveNext
| >> eScrRst.MoveNext
| >> iScrRst.MoveNext
| >>
| >>
| >> Loop
| >> Loop
| >> Loop
| >> %>
| >>
| >
| >
|
|
 
K

Kevin Spencer

Hi Rob,

EOF means that the end of the RecordSet has been reached. Unless you can be
sure that all 3 RecordSets contain the exact same number of records, you
could indeed have the problem that Stefan described.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

RobA said:
Cheers for that Stefan,

I had been working along the same principle - but I must be getting
something wrong. I have included my script !!!
The db where the data is being drawn from requires a value for each of the
recordset fields (it is a , so there shouln't be a return of an EOF, this
page can't be ran until all the values are input. (although I am hoping a
value of 0 wont be returned as a NULL).

I just keep getting a

Type mismatch
/ia/calc01.asp, line 175

which seems to happen whenever I attempt any caluculations.

<%
Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal, Total,
aStrengthTotal

aTot = 0
eTot = 0
iTot = 0
pSubTot = 0
aStrengthSubTot = 0
pTotal = 0
SubTotal = 0
aStrengthTotal = 0

'Create Table Header
Response.Write "<Table align=center border=1 cellpadding=0 cellspacing=0>"
Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial Size=3>Score</TD><TD
WIDTH=60 ><FONT Face=Arial Size=3>Score</TD><TD WIDTH=120 ><FONT
Face=Arial Size=3>Potential Value</TD<TD WIDTH=120 ><TD><FONT Face=Arial
Size=3>Calculated Value</TD><TD WIDTH=120><FONT Face=Arial Size=3>Asset
Strength</TD></TR>"

' Start Processes
'Transfer recordset values to equation values
Do While not aScrRst.EOF
aTot = aScrRst("Score")
Do While not eScrRst.EOF
eTot = eScrRst("Score")
Do While not iScrRst.EOF
iTot = iScrRst("Score")





'The Calculated Value = 1st and 2nd scores added then multiplied by 3rd
(this calculation is where the error is returned)
SubTotal = aTot + eTot * eTot

'The Potential Value Sub Total = 3rd score multiplied by 20 mulitplied by
20
pSubTot = iTot * 20 * 20

'The Asset Strength Sub Total = Calculated Value devided by the Potential
Value multiplied 100
aStrengthSubTot = SubTotal / pSubTot * 100

'Total = The sum of all the SubTotals
Total = Total + Subtotal

'Potential Total
pTotal = pTotal + pSubTot


Response.Write "<Table align=center border=1 cellpadding=0 cellspacing=0>"

Response.Write "<TR ALIGN=CENTER>"

Response.Write "<TD WIDTH=60>"
Response.Write aTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=60>"
Response.Write eTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=60>"
Response.Write iTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write pSubTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write SubTotal
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write aStrength
Response.Write "</TD>"

Response.Write "</TR>"

Response.Write "<Table>"


aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext


Loop
Loop
Loop
Response.Write "Total=" & Total
Response.Write "Potential Total= " & PTotal
aStrengthTotal = Total /PTotal * 100
Response.Write "Asset Strength= " & aStrengthTotal


%>
Stefan B Rusynko said:
Validate your data types in each loop while testing using say:

<%
Do While not aScrRst.EOF
aScore = aScrRst("Score")
Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test line
Do While not eScrRst.EOF
eScore = eScrRst("Score")
Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test line
Do While not iScrRst.EOF
iScore = iScrRst("Score")
Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test line
Total = iScore + eScore * aScore
Response.Write "Total: " & Total & "<br>" 'test line
GrandTotal = GrandTotal + Total
iScrRst.MoveNext
eScrRst.MoveNext
aScrRst.MoveNext
Loop
Loop
Loop
Response.Write "GrandTotal: " & GrandTotal
%>

I suspect 1 of your loops may be returning an EOF since your logic is
requiring all 3 recordsets to have 3 "identical" sets of
qualifying data in each loop (a null value or empty string in any
recordset will also cause the loops to fail)

PS
Plus your logic will result in unreliable results since there is no
attempt to order or group the recordset results in any
associated way that is consistent or related to iScore, eScore, or aScore
as a group
So you will be doing math on 3 random numbers (depending on each
recordset order returned)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thanks but I am still getting a type mismatch error.
| | > <%
| > Dim Total
| > Dim GrandTotal
| > GrandTotal = 0
| > Do While not aScrRst.EOF
| > Do While not eScrRst.EOF
| > Do While not iScrRst.EOF
| > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| > GrandTotal = GrandTotal + Total
| >
| > Response.Write "Total: " & Total
| >
| > aScrRst.MoveNext
| > eScrRst.MoveNext
| > iScrRst.MoveNext
| >
| > Loop
| > Loop
| > Loop
| > Response.Write "GrandTotal: " & GrandTotal
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > .Net Developer
| > A watched clock never boils.
| >
| >
| > | >> Can anyone point me in the direction of some guidance for handling
| >> recordset values.
| >>
| >> I am trying to calculate a resultant value (total) of adding 2
values and
| >> mulitplying by the third.
| >>
| >> Eventually I wanted to get total for the resultant value (all the
totals
| >> added together) for the whole recordset!
| >>
| >> <%
| >> Dim Total
| >> Do While not aScrRst.EOF
| >> Do While not eScrRst.EOF
| >> Do While not iScrRst.EOF
| >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>
| >> Response.Write "Total"
| >>
| >> aScrRst.MoveNext
| >> eScrRst.MoveNext
| >> iScrRst.MoveNext
| >>
| >>
| >> Loop
| >> Loop
| >> Loop
| >> %>
| >>
| >
| >
|
|
 
R

RobA

It is a decimal field in the database that is being pulled into the
recordset.

There are the same amount of records in each recordset.

I have tested it without the calculations and all of the recordset values
are returned and can be written, just can't do any calculation.

Rob
Kevin Spencer said:
What is the dat type of these fields?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Complex things are made up of
Lots of simple things.

RobA said:
Cheers for that Stefan,

I had been working along the same principle - but I must be getting
something wrong. I have included my script !!!
The db where the data is being drawn from requires a value for each of
the recordset fields (it is a , so there shouln't be a return of an EOF,
this page can't be ran until all the values are input. (although I am
hoping a value of 0 wont be returned as a NULL).

I just keep getting a

Type mismatch
/ia/calc01.asp, line 175

which seems to happen whenever I attempt any caluculations.

<%
Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal,
Total, aStrengthTotal

aTot = 0
eTot = 0
iTot = 0
pSubTot = 0
aStrengthSubTot = 0
pTotal = 0
SubTotal = 0
aStrengthTotal = 0

'Create Table Header
Response.Write "<Table align=center border=1 cellpadding=0
cellspacing=0>"
Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
Size=3>Score said:
<TD><FONT Face=Arial Size=3>Calculated Value</TD><TD WIDTH=120><FONT
Face=Arial Size=3>Asset Strength</TD></TR>"

' Start Processes
'Transfer recordset values to equation values
Do While not aScrRst.EOF
aTot = aScrRst("Score")
Do While not eScrRst.EOF
eTot = eScrRst("Score")
Do While not iScrRst.EOF
iTot = iScrRst("Score")





'The Calculated Value = 1st and 2nd scores added then multiplied by 3rd
(this calculation is where the error is returned)
SubTotal = aTot + eTot * eTot

'The Potential Value Sub Total = 3rd score multiplied by 20 mulitplied by
20
pSubTot = iTot * 20 * 20

'The Asset Strength Sub Total = Calculated Value devided by the Potential
Value multiplied 100
aStrengthSubTot = SubTotal / pSubTot * 100

'Total = The sum of all the SubTotals
Total = Total + Subtotal

'Potential Total
pTotal = pTotal + pSubTot


Response.Write "<Table align=center border=1 cellpadding=0
cellspacing=0>"

Response.Write "<TR ALIGN=CENTER>"

Response.Write "<TD WIDTH=60>"
Response.Write aTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=60>"
Response.Write eTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=60>"
Response.Write iTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write pSubTot
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write SubTotal
Response.Write "</TD>"

Response.Write "<TD WIDTH=120>"
Response.Write aStrength
Response.Write "</TD>"

Response.Write "</TR>"

Response.Write "<Table>"


aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext


Loop
Loop
Loop
Response.Write "Total=" & Total
Response.Write "Potential Total= " & PTotal
aStrengthTotal = Total /PTotal * 100
Response.Write "Asset Strength= " & aStrengthTotal


%>
Stefan B Rusynko said:
Validate your data types in each loop while testing using say:

<%
Do While not aScrRst.EOF
aScore = aScrRst("Score")
Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test line
Do While not eScrRst.EOF
eScore = eScrRst("Score")
Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test line
Do While not iScrRst.EOF
iScore = iScrRst("Score")
Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test line
Total = iScore + eScore * aScore
Response.Write "Total: " & Total & "<br>" 'test line
GrandTotal = GrandTotal + Total
iScrRst.MoveNext
eScrRst.MoveNext
aScrRst.MoveNext
Loop
Loop
Loop
Response.Write "GrandTotal: " & GrandTotal
%>

I suspect 1 of your loops may be returning an EOF since your logic is
requiring all 3 recordsets to have 3 "identical" sets of
qualifying data in each loop (a null value or empty string in any
recordset will also cause the loops to fail)

PS
Plus your logic will result in unreliable results since there is no
attempt to order or group the recordset results in any
associated way that is consistent or related to iScore, eScore, or
aScore as a group
So you will be doing math on 3 random numbers (depending on each
recordset order returned)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thanks but I am still getting a type mismatch error.
| | > <%
| > Dim Total
| > Dim GrandTotal
| > GrandTotal = 0
| > Do While not aScrRst.EOF
| > Do While not eScrRst.EOF
| > Do While not iScrRst.EOF
| > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| > GrandTotal = GrandTotal + Total
| >
| > Response.Write "Total: " & Total
| >
| > aScrRst.MoveNext
| > eScrRst.MoveNext
| > iScrRst.MoveNext
| >
| > Loop
| > Loop
| > Loop
| > Response.Write "GrandTotal: " & GrandTotal
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > .Net Developer
| > A watched clock never boils.
| >
| >
| > | >> Can anyone point me in the direction of some guidance for handling
| >> recordset values.
| >>
| >> I am trying to calculate a resultant value (total) of adding 2
values and
| >> mulitplying by the third.
| >>
| >> Eventually I wanted to get total for the resultant value (all the
totals
| >> added together) for the whole recordset!
| >>
| >> <%
| >> Dim Total
| >> Do While not aScrRst.EOF
| >> Do While not eScrRst.EOF
| >> Do While not iScrRst.EOF
| >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>
| >> Response.Write "Total"
| >>
| >> aScrRst.MoveNext
| >> eScrRst.MoveNext
| >> iScrRst.MoveNext
| >>
| >>
| >> Loop
| >> Loop
| >> Loop
| >> %>
| >>
| >
| >
|
|
 
S

Stefan B Rusynko

Did you really test it w/i each of the loops using the VBscript function:
TypeName("yourvarname")
- per my 1st post?

PS
A zero in some of the fields will give you divide by 0 errors unless you test for them 1st

And again your whole logic appears to be flawed since there is nothing controlling the order (or grouping) of the numbers you are
doing math on - the results will be totally random
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| It is a decimal field in the database that is being pulled into the
| recordset.
|
| There are the same amount of records in each recordset.
|
| I have tested it without the calculations and all of the recordset values
| are returned and can be written, just can't do any calculation.
|
| Rob
| | > What is the dat type of these fields?
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > .Net Developer
| > Complex things are made up of
| > Lots of simple things.
| >
| > | >> Cheers for that Stefan,
| >>
| >> I had been working along the same principle - but I must be getting
| >> something wrong. I have included my script !!!
| >> The db where the data is being drawn from requires a value for each of
| >> the recordset fields (it is a , so there shouln't be a return of an EOF,
| >> this page can't be ran until all the values are input. (although I am
| >> hoping a value of 0 wont be returned as a NULL).
| >>
| >> I just keep getting a
| >>
| >> Type mismatch
| >> /ia/calc01.asp, line 175
| >>
| >> which seems to happen whenever I attempt any caluculations.
| >>
| >> <%
| >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal,
| >> Total, aStrengthTotal
| >>
| >> aTot = 0
| >> eTot = 0
| >> iTot = 0
| >> pSubTot = 0
| >> aStrengthSubTot = 0
| >> pTotal = 0
| >> SubTotal = 0
| >> aStrengthTotal = 0
| >>
| >> 'Create Table Header
| >> Response.Write "<Table align=center border=1 cellpadding=0
| >> cellspacing=0>"
| >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
| >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial Size=3>Score</TD><TD
| >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD WIDTH=120
| >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD WIDTH=120><FONT
| >> Face=Arial Size=3>Asset Strength</TD></TR>"
| >>
| >> ' Start Processes
| >> 'Transfer recordset values to equation values
| >> Do While not aScrRst.EOF
| >> aTot = aScrRst("Score")
| >> Do While not eScrRst.EOF
| >> eTot = eScrRst("Score")
| >> Do While not iScrRst.EOF
| >> iTot = iScrRst("Score")
| >>
| >>
| >>
| >>
| >>
| >> 'The Calculated Value = 1st and 2nd scores added then multiplied by 3rd
| >> (this calculation is where the error is returned)
| >> SubTotal = aTot + eTot * eTot
| >>
| >> 'The Potential Value Sub Total = 3rd score multiplied by 20 mulitplied by
| >> 20
| >> pSubTot = iTot * 20 * 20
| >>
| >> 'The Asset Strength Sub Total = Calculated Value devided by the Potential
| >> Value multiplied 100
| >> aStrengthSubTot = SubTotal / pSubTot * 100
| >>
| >> 'Total = The sum of all the SubTotals
| >> Total = Total + Subtotal
| >>
| >> 'Potential Total
| >> pTotal = pTotal + pSubTot
| >>
| >>
| >> Response.Write "<Table align=center border=1 cellpadding=0
| >> cellspacing=0>"
| >>
| >> Response.Write "<TR ALIGN=CENTER>"
| >>
| >> Response.Write "<TD WIDTH=60>"
| >> Response.Write aTot
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=60>"
| >> Response.Write eTot
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=60>"
| >> Response.Write iTot
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=120>"
| >> Response.Write pSubTot
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=120>"
| >> Response.Write SubTotal
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=120>"
| >> Response.Write aStrength
| >> Response.Write "</TD>"
| >>
| >> Response.Write "</TR>"
| >>
| >> Response.Write "<Table>"
| >>
| >>
| >> aScrRst.MoveNext
| >> eScrRst.MoveNext
| >> iScrRst.MoveNext
| >>
| >>
| >> Loop
| >> Loop
| >> Loop
| >> Response.Write "Total=" & Total
| >> Response.Write "Potential Total= " & PTotal
| >> aStrengthTotal = Total /PTotal * 100
| >> Response.Write "Asset Strength= " & aStrengthTotal
| >>
| >>
| >> %>
| >> | >>> Validate your data types in each loop while testing using say:
| >>>
| >>> <%
| >>> Do While not aScrRst.EOF
| >>> aScore = aScrRst("Score")
| >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test line
| >>> Do While not eScrRst.EOF
| >>> eScore = eScrRst("Score")
| >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test line
| >>> Do While not iScrRst.EOF
| >>> iScore = iScrRst("Score")
| >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test line
| >>> Total = iScore + eScore * aScore
| >>> Response.Write "Total: " & Total & "<br>" 'test line
| >>> GrandTotal = GrandTotal + Total
| >>> iScrRst.MoveNext
| >>> eScrRst.MoveNext
| >>> aScrRst.MoveNext
| >>> Loop
| >>> Loop
| >>> Loop
| >>> Response.Write "GrandTotal: " & GrandTotal
| >>> %>
| >>>
| >>> I suspect 1 of your loops may be returning an EOF since your logic is
| >>> requiring all 3 recordsets to have 3 "identical" sets of
| >>> qualifying data in each loop (a null value or empty string in any
| >>> recordset will also cause the loops to fail)
| >>>
| >>> PS
| >>> Plus your logic will result in unreliable results since there is no
| >>> attempt to order or group the recordset results in any
| >>> associated way that is consistent or related to iScore, eScore, or
| >>> aScore as a group
| >>> So you will be doing math on 3 random numbers (depending on each
| >>> recordset order returned)
| >>> --
| >>>
| >>> _____________________________________________
| >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>> "Warning - Using the F1 Key will not break anything!" (-;
| >>> To find the best Newsgroup for FrontPage support see:
| >>> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >>> _____________________________________________
| >>>
| >>>
| >>> | >>> | Thanks but I am still getting a type mismatch error.
| >>> | | >>> | > <%
| >>> | > Dim Total
| >>> | > Dim GrandTotal
| >>> | > GrandTotal = 0
| >>> | > Do While not aScrRst.EOF
| >>> | > Do While not eScrRst.EOF
| >>> | > Do While not iScrRst.EOF
| >>> | > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>> | > GrandTotal = GrandTotal + Total
| >>> | >
| >>> | > Response.Write "Total: " & Total
| >>> | >
| >>> | > aScrRst.MoveNext
| >>> | > eScrRst.MoveNext
| >>> | > iScrRst.MoveNext
| >>> | >
| >>> | > Loop
| >>> | > Loop
| >>> | > Loop
| >>> | > Response.Write "GrandTotal: " & GrandTotal
| >>> | >
| >>> | > --
| >>> | > HTH,
| >>> | >
| >>> | > Kevin Spencer
| >>> | > Microsoft MVP
| >>> | > .Net Developer
| >>> | > A watched clock never boils.
| >>> | >
| >>> | >
| >>> | > | >>> | >> Can anyone point me in the direction of some guidance for handling
| >>> | >> recordset values.
| >>> | >>
| >>> | >> I am trying to calculate a resultant value (total) of adding 2
| >>> values and
| >>> | >> mulitplying by the third.
| >>> | >>
| >>> | >> Eventually I wanted to get total for the resultant value (all the
| >>> totals
| >>> | >> added together) for the whole recordset!
| >>> | >>
| >>> | >> <%
| >>> | >> Dim Total
| >>> | >> Do While not aScrRst.EOF
| >>> | >> Do While not eScrRst.EOF
| >>> | >> Do While not iScrRst.EOF
| >>> | >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>> | >>
| >>> | >> Response.Write "Total"
| >>> | >>
| >>> | >> aScrRst.MoveNext
| >>> | >> eScrRst.MoveNext
| >>> | >> iScrRst.MoveNext
| >>> | >>
| >>> | >>
| >>> | >> Loop
| >>> | >> Loop
| >>> | >> Loop
| >>> | >> %>
| >>> | >>
| >>> | >
| >>> | >
| >>> |
| >>> |
| >>>
| >>>
| >>
| >>
| >
| >
|
|
 
R

RobA

I did test it, however, I had the same value in each of the fields so I
couldn't really see what you were meaning.

I now realise that the I am nutter lol. It is back to the drawing board by
the looks of things.


Thanks for you help though.

Rob


Stefan B Rusynko said:
Did you really test it w/i each of the loops using the VBscript function:
TypeName("yourvarname")
- per my 1st post?

PS
A zero in some of the fields will give you divide by 0 errors unless you
test for them 1st

And again your whole logic appears to be flawed since there is nothing
controlling the order (or grouping) of the numbers you are
doing math on - the results will be totally random
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| It is a decimal field in the database that is being pulled into the
| recordset.
|
| There are the same amount of records in each recordset.
|
| I have tested it without the calculations and all of the recordset
values
| are returned and can be written, just can't do any calculation.
|
| Rob
| | > What is the dat type of these fields?
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > .Net Developer
| > Complex things are made up of
| > Lots of simple things.
| >
| > | >> Cheers for that Stefan,
| >>
| >> I had been working along the same principle - but I must be getting
| >> something wrong. I have included my script !!!
| >> The db where the data is being drawn from requires a value for each
of
| >> the recordset fields (it is a , so there shouln't be a return of an
EOF,
| >> this page can't be ran until all the values are input. (although I am
| >> hoping a value of 0 wont be returned as a NULL).
| >>
| >> I just keep getting a
| >>
| >> Type mismatch
| >> /ia/calc01.asp, line 175
| >>
| >> which seems to happen whenever I attempt any caluculations.
| >>
| >> <%
| >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal,
| >> Total, aStrengthTotal
| >>
| >> aTot = 0
| >> eTot = 0
| >> iTot = 0
| >> pSubTot = 0
| >> aStrengthSubTot = 0
| >> pTotal = 0
| >> SubTotal = 0
| >> aStrengthTotal = 0
| >>
| >> 'Create Table Header
| >> Response.Write "<Table align=center border=1 cellpadding=0
| >> cellspacing=0>"
| >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
| >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial Size=3>Score</TD><TD
| >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD WIDTH=120
| >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
WIDTH=120><FONT
| >> Face=Arial Size=3>Asset Strength</TD></TR>"
| >>
| >> ' Start Processes
| >> 'Transfer recordset values to equation values
| >> Do While not aScrRst.EOF
| >> aTot = aScrRst("Score")
| >> Do While not eScrRst.EOF
| >> eTot = eScrRst("Score")
| >> Do While not iScrRst.EOF
| >> iTot = iScrRst("Score")
| >>
| >>
| >>
| >>
| >>
| >> 'The Calculated Value = 1st and 2nd scores added then multiplied by
3rd
| >> (this calculation is where the error is returned)
| >> SubTotal = aTot + eTot * eTot
| >>
| >> 'The Potential Value Sub Total = 3rd score multiplied by 20
mulitplied by
| >> 20
| >> pSubTot = iTot * 20 * 20
| >>
| >> 'The Asset Strength Sub Total = Calculated Value devided by the
Potential
| >> Value multiplied 100
| >> aStrengthSubTot = SubTotal / pSubTot * 100
| >>
| >> 'Total = The sum of all the SubTotals
| >> Total = Total + Subtotal
| >>
| >> 'Potential Total
| >> pTotal = pTotal + pSubTot
| >>
| >>
| >> Response.Write "<Table align=center border=1 cellpadding=0
| >> cellspacing=0>"
| >>
| >> Response.Write "<TR ALIGN=CENTER>"
| >>
| >> Response.Write "<TD WIDTH=60>"
| >> Response.Write aTot
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=60>"
| >> Response.Write eTot
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=60>"
| >> Response.Write iTot
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=120>"
| >> Response.Write pSubTot
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=120>"
| >> Response.Write SubTotal
| >> Response.Write "</TD>"
| >>
| >> Response.Write "<TD WIDTH=120>"
| >> Response.Write aStrength
| >> Response.Write "</TD>"
| >>
| >> Response.Write "</TR>"
| >>
| >> Response.Write "<Table>"
| >>
| >>
| >> aScrRst.MoveNext
| >> eScrRst.MoveNext
| >> iScrRst.MoveNext
| >>
| >>
| >> Loop
| >> Loop
| >> Loop
| >> Response.Write "Total=" & Total
| >> Response.Write "Potential Total= " & PTotal
| >> aStrengthTotal = Total /PTotal * 100
| >> Response.Write "Asset Strength= " & aStrengthTotal
| >>
| >>
| >> %>
| >> | >>> Validate your data types in each loop while testing using say:
| >>>
| >>> <%
| >>> Do While not aScrRst.EOF
| >>> aScore = aScrRst("Score")
| >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test
line
| >>> Do While not eScrRst.EOF
| >>> eScore = eScrRst("Score")
| >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test
line
| >>> Do While not iScrRst.EOF
| >>> iScore = iScrRst("Score")
| >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test
line
| >>> Total = iScore + eScore * aScore
| >>> Response.Write "Total: " & Total & "<br>" 'test line
| >>> GrandTotal = GrandTotal + Total
| >>> iScrRst.MoveNext
| >>> eScrRst.MoveNext
| >>> aScrRst.MoveNext
| >>> Loop
| >>> Loop
| >>> Loop
| >>> Response.Write "GrandTotal: " & GrandTotal
| >>> %>
| >>>
| >>> I suspect 1 of your loops may be returning an EOF since your logic
is
| >>> requiring all 3 recordsets to have 3 "identical" sets of
| >>> qualifying data in each loop (a null value or empty string in any
| >>> recordset will also cause the loops to fail)
| >>>
| >>> PS
| >>> Plus your logic will result in unreliable results since there is no
| >>> attempt to order or group the recordset results in any
| >>> associated way that is consistent or related to iScore, eScore, or
| >>> aScore as a group
| >>> So you will be doing math on 3 random numbers (depending on each
| >>> recordset order returned)
| >>> --
| >>>
| >>> _____________________________________________
| >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>> "Warning - Using the F1 Key will not break anything!" (-;
| >>> To find the best Newsgroup for FrontPage support see:
| >>>
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >>> _____________________________________________
| >>>
| >>>
| >>> | >>> | Thanks but I am still getting a type mismatch error.
message
| >>> | | >>> | > <%
| >>> | > Dim Total
| >>> | > Dim GrandTotal
| >>> | > GrandTotal = 0
| >>> | > Do While not aScrRst.EOF
| >>> | > Do While not eScrRst.EOF
| >>> | > Do While not iScrRst.EOF
| >>> | > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>> | > GrandTotal = GrandTotal + Total
| >>> | >
| >>> | > Response.Write "Total: " & Total
| >>> | >
| >>> | > aScrRst.MoveNext
| >>> | > eScrRst.MoveNext
| >>> | > iScrRst.MoveNext
| >>> | >
| >>> | > Loop
| >>> | > Loop
| >>> | > Loop
| >>> | > Response.Write "GrandTotal: " & GrandTotal
| >>> | >
| >>> | > --
| >>> | > HTH,
| >>> | >
| >>> | > Kevin Spencer
| >>> | > Microsoft MVP
| >>> | > .Net Developer
| >>> | > A watched clock never boils.
| >>> | >
| >>> | >
| >>> | > | >>> | >> Can anyone point me in the direction of some guidance for
handling
| >>> | >> recordset values.
| >>> | >>
| >>> | >> I am trying to calculate a resultant value (total) of adding 2
| >>> values and
| >>> | >> mulitplying by the third.
| >>> | >>
| >>> | >> Eventually I wanted to get total for the resultant value (all
the
| >>> totals
| >>> | >> added together) for the whole recordset!
| >>> | >>
| >>> | >> <%
| >>> | >> Dim Total
| >>> | >> Do While not aScrRst.EOF
| >>> | >> Do While not eScrRst.EOF
| >>> | >> Do While not iScrRst.EOF
| >>> | >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| >>> | >>
| >>> | >> Response.Write "Total"
| >>> | >>
| >>> | >> aScrRst.MoveNext
| >>> | >> eScrRst.MoveNext
| >>> | >> iScrRst.MoveNext
| >>> | >>
| >>> | >>
| >>> | >> Loop
| >>> | >> Loop
| >>> | >> Loop
| >>> | >> %>
| >>> | >>
| >>> | >
| >>> | >
| >>> |
| >>> |
| >>>
| >>>
| >>
| >>
| >
| >
|
|
 
S

Stefan B Rusynko

Before you start, learn about your data being returned by your nested loops
Just paste this in a page (where you have opened your 3 connections)

<table align="center" border="1" cellpadding="0" cellspacing="0" id="table2">
<tr><th>Info</th><th>Score a</th><th>Score e</th><th>Score i</th></tr>
<%
Do While not aScrRst.EOF
aTot = aScrRst("Score")
Do While not eScrRst.EOF
eTot = eScrRst("Score")
Do While not iScrRst.EOF
iTot = iScrRst("Score")
%>
<tr><td>Data / Type</td>
<td><%=aTot & " / " & Typename(aTot)%></td>
<td><%=eTot & " / " & Typename(eTot)%></td>
<td><%=iTot & " / " & Typename(iTot)%></td>
</tr>
<%
aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext
Loop
Loop
Loop
%>
</table>

It also appears you need to start by correctly grouping the data for the 3 QLIDs (a,e,i) based on something in your table like QID
- consider creating 1 recordset and building an array

PS
Also look at your math - you need to use () to set precedence of calculations to get correct results
SubTotal = aTot + eTot * eTot
is not the same as
SubTotal = (aTot + eTot) * eTot
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I did test it, however, I had the same value in each of the fields so I
| couldn't really see what you were meaning.
|
| I now realise that the I am nutter lol. It is back to the drawing board by
| the looks of things.
|
|
| Thanks for you help though.
|
| Rob
|
|
| | > Did you really test it w/i each of the loops using the VBscript function:
| > TypeName("yourvarname")
| > - per my 1st post?
| >
| > PS
| > A zero in some of the fields will give you divide by 0 errors unless you
| > test for them 1st
| >
| > And again your whole logic appears to be flawed since there is nothing
| > controlling the order (or grouping) of the numbers you are
| > doing math on - the results will be totally random
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | > | It is a decimal field in the database that is being pulled into the
| > | recordset.
| > |
| > | There are the same amount of records in each recordset.
| > |
| > | I have tested it without the calculations and all of the recordset
| > values
| > | are returned and can be written, just can't do any calculation.
| > |
| > | Rob
| > | | > | > What is the dat type of these fields?
| > | >
| > | > --
| > | > HTH,
| > | >
| > | > Kevin Spencer
| > | > Microsoft MVP
| > | > .Net Developer
| > | > Complex things are made up of
| > | > Lots of simple things.
| > | >
| > | > | > | >> Cheers for that Stefan,
| > | >>
| > | >> I had been working along the same principle - but I must be getting
| > | >> something wrong. I have included my script !!!
| > | >> The db where the data is being drawn from requires a value for each
| > of
| > | >> the recordset fields (it is a , so there shouln't be a return of an
| > EOF,
| > | >> this page can't be ran until all the values are input. (although I am
| > | >> hoping a value of 0 wont be returned as a NULL).
| > | >>
| > | >> I just keep getting a
| > | >>
| > | >> Type mismatch
| > | >> /ia/calc01.asp, line 175
| > | >>
| > | >> which seems to happen whenever I attempt any caluculations.
| > | >>
| > | >> <%
| > | >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal,
| > | >> Total, aStrengthTotal
| > | >>
| > | >> aTot = 0
| > | >> eTot = 0
| > | >> iTot = 0
| > | >> pSubTot = 0
| > | >> aStrengthSubTot = 0
| > | >> pTotal = 0
| > | >> SubTotal = 0
| > | >> aStrengthTotal = 0
| > | >>
| > | >> 'Create Table Header
| > | >> Response.Write "<Table align=center border=1 cellpadding=0
| > | >> cellspacing=0>"
| > | >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
| > | >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| > | >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial Size=3>Score</TD><TD
| > | >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD WIDTH=120
| > | >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
| > WIDTH=120><FONT
| > | >> Face=Arial Size=3>Asset Strength</TD></TR>"
| > | >>
| > | >> ' Start Processes
| > | >> 'Transfer recordset values to equation values
| > | >> Do While not aScrRst.EOF
| > | >> aTot = aScrRst("Score")
| > | >> Do While not eScrRst.EOF
| > | >> eTot = eScrRst("Score")
| > | >> Do While not iScrRst.EOF
| > | >> iTot = iScrRst("Score")
| > | >>
| > | >>
| > | >>
| > | >>
| > | >>
| > | >> 'The Calculated Value = 1st and 2nd scores added then multiplied by
| > 3rd
| > | >> (this calculation is where the error is returned)
| > | >> SubTotal = aTot + eTot * eTot
| > | >>
| > | >> 'The Potential Value Sub Total = 3rd score multiplied by 20
| > mulitplied by
| > | >> 20
| > | >> pSubTot = iTot * 20 * 20
| > | >>
| > | >> 'The Asset Strength Sub Total = Calculated Value devided by the
| > Potential
| > | >> Value multiplied 100
| > | >> aStrengthSubTot = SubTotal / pSubTot * 100
| > | >>
| > | >> 'Total = The sum of all the SubTotals
| > | >> Total = Total + Subtotal
| > | >>
| > | >> 'Potential Total
| > | >> pTotal = pTotal + pSubTot
| > | >>
| > | >>
| > | >> Response.Write "<Table align=center border=1 cellpadding=0
| > | >> cellspacing=0>"
| > | >>
| > | >> Response.Write "<TR ALIGN=CENTER>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write aTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write eTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write iTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write pSubTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write SubTotal
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write aStrength
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "</TR>"
| > | >>
| > | >> Response.Write "<Table>"
| > | >>
| > | >>
| > | >> aScrRst.MoveNext
| > | >> eScrRst.MoveNext
| > | >> iScrRst.MoveNext
| > | >>
| > | >>
| > | >> Loop
| > | >> Loop
| > | >> Loop
| > | >> Response.Write "Total=" & Total
| > | >> Response.Write "Potential Total= " & PTotal
| > | >> aStrengthTotal = Total /PTotal * 100
| > | >> Response.Write "Asset Strength= " & aStrengthTotal
| > | >>
| > | >>
| > | >> %>
| > | >> | > | >>> Validate your data types in each loop while testing using say:
| > | >>>
| > | >>> <%
| > | >>> Do While not aScrRst.EOF
| > | >>> aScore = aScrRst("Score")
| > | >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>" 'test
| > line
| > | >>> Do While not eScrRst.EOF
| > | >>> eScore = eScrRst("Score")
| > | >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>" 'test
| > line
| > | >>> Do While not iScrRst.EOF
| > | >>> iScore = iScrRst("Score")
| > | >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>" 'test
| > line
| > | >>> Total = iScore + eScore * aScore
| > | >>> Response.Write "Total: " & Total & "<br>" 'test line
| > | >>> GrandTotal = GrandTotal + Total
| > | >>> iScrRst.MoveNext
| > | >>> eScrRst.MoveNext
| > | >>> aScrRst.MoveNext
| > | >>> Loop
| > | >>> Loop
| > | >>> Loop
| > | >>> Response.Write "GrandTotal: " & GrandTotal
| > | >>> %>
| > | >>>
| > | >>> I suspect 1 of your loops may be returning an EOF since your logic
| > is
| > | >>> requiring all 3 recordsets to have 3 "identical" sets of
| > | >>> qualifying data in each loop (a null value or empty string in any
| > | >>> recordset will also cause the loops to fail)
| > | >>>
| > | >>> PS
| > | >>> Plus your logic will result in unreliable results since there is no
| > | >>> attempt to order or group the recordset results in any
| > | >>> associated way that is consistent or related to iScore, eScore, or
| > | >>> aScore as a group
| > | >>> So you will be doing math on 3 random numbers (depending on each
| > | >>> recordset order returned)
| > | >>> --
| > | >>>
| > | >>> _____________________________________________
| > | >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | >>> "Warning - Using the F1 Key will not break anything!" (-;
| > | >>> To find the best Newsgroup for FrontPage support see:
| > | >>>
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | >>> _____________________________________________
| > | >>>
| > | >>>
| > | >>> | > | >>> | Thanks but I am still getting a type mismatch error.
| > message
| > | >>> | | > | >>> | > <%
| > | >>> | > Dim Total
| > | >>> | > Dim GrandTotal
| > | >>> | > GrandTotal = 0
| > | >>> | > Do While not aScrRst.EOF
| > | >>> | > Do While not eScrRst.EOF
| > | >>> | > Do While not iScrRst.EOF
| > | >>> | > Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| > | >>> | > GrandTotal = GrandTotal + Total
| > | >>> | >
| > | >>> | > Response.Write "Total: " & Total
| > | >>> | >
| > | >>> | > aScrRst.MoveNext
| > | >>> | > eScrRst.MoveNext
| > | >>> | > iScrRst.MoveNext
| > | >>> | >
| > | >>> | > Loop
| > | >>> | > Loop
| > | >>> | > Loop
| > | >>> | > Response.Write "GrandTotal: " & GrandTotal
| > | >>> | >
| > | >>> | > --
| > | >>> | > HTH,
| > | >>> | >
| > | >>> | > Kevin Spencer
| > | >>> | > Microsoft MVP
| > | >>> | > .Net Developer
| > | >>> | > A watched clock never boils.
| > | >>> | >
| > | >>> | >
| > | >>> | > | > | >>> | >> Can anyone point me in the direction of some guidance for
| > handling
| > | >>> | >> recordset values.
| > | >>> | >>
| > | >>> | >> I am trying to calculate a resultant value (total) of adding 2
| > | >>> values and
| > | >>> | >> mulitplying by the third.
| > | >>> | >>
| > | >>> | >> Eventually I wanted to get total for the resultant value (all
| > the
| > | >>> totals
| > | >>> | >> added together) for the whole recordset!
| > | >>> | >>
| > | >>> | >> <%
| > | >>> | >> Dim Total
| > | >>> | >> Do While not aScrRst.EOF
| > | >>> | >> Do While not eScrRst.EOF
| > | >>> | >> Do While not iScrRst.EOF
| > | >>> | >> Total = iScrRst("Score") + eScrRst("Score") * aScrRst("Score")
| > | >>> | >>
| > | >>> | >> Response.Write "Total"
| > | >>> | >>
| > | >>> | >> aScrRst.MoveNext
| > | >>> | >> eScrRst.MoveNext
| > | >>> | >> iScrRst.MoveNext
| > | >>> | >>
| > | >>> | >>
| > | >>> | >> Loop
| > | >>> | >> Loop
| > | >>> | >> Loop
| > | >>> | >> %>
| > | >>> | >>
| > | >>> | >
| > | >>> | >
| > | >>> |
| > | >>> |
| > | >>>
| > | >>>
| > | >>
| > | >>
| > | >
| > | >
| > |
| > |
| >
| >
|
|
 
K

Kevin Spencer

Just a side note: This looks like it could be done with a single RecordSet,
and a JOIN or UNION query.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

Stefan B Rusynko said:
Before you start, learn about your data being returned by your nested
loops
Just paste this in a page (where you have opened your 3 connections)

<table align="center" border="1" cellpadding="0" cellspacing="0"
id="table2">
<tr><th>Info</th><th>Score a</th><th>Score e</th><th>Score i</th></tr>
<%
Do While not aScrRst.EOF
aTot = aScrRst("Score")
Do While not eScrRst.EOF
eTot = eScrRst("Score")
Do While not iScrRst.EOF
iTot = iScrRst("Score")
%>
<tr><td>Data / Type</td>
<td><%=aTot & " / " & Typename(aTot)%></td>
<td><%=eTot & " / " & Typename(eTot)%></td>
<td><%=iTot & " / " & Typename(iTot)%></td>
</tr>
<%
aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext
Loop
Loop
Loop
%>
</table>

It also appears you need to start by correctly grouping the data for the 3
QLIDs (a,e,i) based on something in your table like QID
- consider creating 1 recordset and building an array

PS
Also look at your math - you need to use () to set precedence of
calculations to get correct results
SubTotal = aTot + eTot * eTot
is not the same as
SubTotal = (aTot + eTot) * eTot
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I did test it, however, I had the same value in each of the fields so I
| couldn't really see what you were meaning.
|
| I now realise that the I am nutter lol. It is back to the drawing board
by
| the looks of things.
|
|
| Thanks for you help though.
|
| Rob
|
|
| | > Did you really test it w/i each of the loops using the VBscript
function:
| > TypeName("yourvarname")
| > - per my 1st post?
| >
| > PS
| > A zero in some of the fields will give you divide by 0 errors unless
you
| > test for them 1st
| >
| > And again your whole logic appears to be flawed since there is nothing
| > controlling the order (or grouping) of the numbers you are
| > doing math on - the results will be totally random
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| >
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | > | It is a decimal field in the database that is being pulled into the
| > | recordset.
| > |
| > | There are the same amount of records in each recordset.
| > |
| > | I have tested it without the calculations and all of the recordset
| > values
| > | are returned and can be written, just can't do any calculation.
| > |
| > | Rob
| > | | > | > What is the dat type of these fields?
| > | >
| > | > --
| > | > HTH,
| > | >
| > | > Kevin Spencer
| > | > Microsoft MVP
| > | > .Net Developer
| > | > Complex things are made up of
| > | > Lots of simple things.
| > | >
| > | > | > | >> Cheers for that Stefan,
| > | >>
| > | >> I had been working along the same principle - but I must be
getting
| > | >> something wrong. I have included my script !!!
| > | >> The db where the data is being drawn from requires a value for
each
| > of
| > | >> the recordset fields (it is a , so there shouln't be a return of
an
| > EOF,
| > | >> this page can't be ran until all the values are input. (although
I am
| > | >> hoping a value of 0 wont be returned as a NULL).
| > | >>
| > | >> I just keep getting a
| > | >>
| > | >> Type mismatch
| > | >> /ia/calc01.asp, line 175
| > | >>
| > | >> which seems to happen whenever I attempt any caluculations.
| > | >>
| > | >> <%
| > | >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal,
SubTotal,
| > | >> Total, aStrengthTotal
| > | >>
| > | >> aTot = 0
| > | >> eTot = 0
| > | >> iTot = 0
| > | >> pSubTot = 0
| > | >> aStrengthSubTot = 0
| > | >> pTotal = 0
| > | >> SubTotal = 0
| > | >> aStrengthTotal = 0
| > | >>
| > | >> 'Create Table Header
| > | >> Response.Write "<Table align=center border=1 cellpadding=0
| > | >> cellspacing=0>"
| > | >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
| > | >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| > | >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial
Size=3>Score</TD><TD
| > | >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD
WIDTH=120
| > | >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
| > WIDTH=120><FONT
| > | >> Face=Arial Size=3>Asset Strength</TD></TR>"
| > | >>
| > | >> ' Start Processes
| > | >> 'Transfer recordset values to equation values
| > | >> Do While not aScrRst.EOF
| > | >> aTot = aScrRst("Score")
| > | >> Do While not eScrRst.EOF
| > | >> eTot = eScrRst("Score")
| > | >> Do While not iScrRst.EOF
| > | >> iTot = iScrRst("Score")
| > | >>
| > | >>
| > | >>
| > | >>
| > | >>
| > | >> 'The Calculated Value = 1st and 2nd scores added then multiplied
by
| > 3rd
| > | >> (this calculation is where the error is returned)
| > | >> SubTotal = aTot + eTot * eTot
| > | >>
| > | >> 'The Potential Value Sub Total = 3rd score multiplied by 20
| > mulitplied by
| > | >> 20
| > | >> pSubTot = iTot * 20 * 20
| > | >>
| > | >> 'The Asset Strength Sub Total = Calculated Value devided by the
| > Potential
| > | >> Value multiplied 100
| > | >> aStrengthSubTot = SubTotal / pSubTot * 100
| > | >>
| > | >> 'Total = The sum of all the SubTotals
| > | >> Total = Total + Subtotal
| > | >>
| > | >> 'Potential Total
| > | >> pTotal = pTotal + pSubTot
| > | >>
| > | >>
| > | >> Response.Write "<Table align=center border=1 cellpadding=0
| > | >> cellspacing=0>"
| > | >>
| > | >> Response.Write "<TR ALIGN=CENTER>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write aTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write eTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write iTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write pSubTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write SubTotal
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write aStrength
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "</TR>"
| > | >>
| > | >> Response.Write "<Table>"
| > | >>
| > | >>
| > | >> aScrRst.MoveNext
| > | >> eScrRst.MoveNext
| > | >> iScrRst.MoveNext
| > | >>
| > | >>
| > | >> Loop
| > | >> Loop
| > | >> Loop
| > | >> Response.Write "Total=" & Total
| > | >> Response.Write "Potential Total= " & PTotal
| > | >> aStrengthTotal = Total /PTotal * 100
| > | >> Response.Write "Asset Strength= " & aStrengthTotal
| > | >>
| > | >>
| > | >> %>
| > | >> | > | >>> Validate your data types in each loop while testing using say:
| > | >>>
| > | >>> <%
| > | >>> Do While not aScrRst.EOF
| > | >>> aScore = aScrRst("Score")
| > | >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>"
'test
| > line
| > | >>> Do While not eScrRst.EOF
| > | >>> eScore = eScrRst("Score")
| > | >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>"
'test
| > line
| > | >>> Do While not iScrRst.EOF
| > | >>> iScore = iScrRst("Score")
| > | >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>"
'test
| > line
| > | >>> Total = iScore + eScore * aScore
| > | >>> Response.Write "Total: " & Total & "<br>" 'test line
| > | >>> GrandTotal = GrandTotal + Total
| > | >>> iScrRst.MoveNext
| > | >>> eScrRst.MoveNext
| > | >>> aScrRst.MoveNext
| > | >>> Loop
| > | >>> Loop
| > | >>> Loop
| > | >>> Response.Write "GrandTotal: " & GrandTotal
| > | >>> %>
| > | >>>
| > | >>> I suspect 1 of your loops may be returning an EOF since your
logic
| > is
| > | >>> requiring all 3 recordsets to have 3 "identical" sets of
| > | >>> qualifying data in each loop (a null value or empty string in
any
| > | >>> recordset will also cause the loops to fail)
| > | >>>
| > | >>> PS
| > | >>> Plus your logic will result in unreliable results since there is
no
| > | >>> attempt to order or group the recordset results in any
| > | >>> associated way that is consistent or related to iScore, eScore,
or
| > | >>> aScore as a group
| > | >>> So you will be doing math on 3 random numbers (depending on each
| > | >>> recordset order returned)
| > | >>> --
| > | >>>
| > | >>> _____________________________________________
| > | >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | >>> "Warning - Using the F1 Key will not break anything!" (-;
| > | >>> To find the best Newsgroup for FrontPage support see:
| > | >>>
| > http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | >>> _____________________________________________
| > | >>>
| > | >>>
| > | >>> | > | >>> | Thanks but I am still getting a type mismatch error.
| > message
| > | >>> | | > | >>> | > <%
| > | >>> | > Dim Total
| > | >>> | > Dim GrandTotal
| > | >>> | > GrandTotal = 0
| > | >>> | > Do While not aScrRst.EOF
| > | >>> | > Do While not eScrRst.EOF
| > | >>> | > Do While not iScrRst.EOF
| > | >>> | > Total = iScrRst("Score") + eScrRst("Score") *
aScrRst("Score")
| > | >>> | > GrandTotal = GrandTotal + Total
| > | >>> | >
| > | >>> | > Response.Write "Total: " & Total
| > | >>> | >
| > | >>> | > aScrRst.MoveNext
| > | >>> | > eScrRst.MoveNext
| > | >>> | > iScrRst.MoveNext
| > | >>> | >
| > | >>> | > Loop
| > | >>> | > Loop
| > | >>> | > Loop
| > | >>> | > Response.Write "GrandTotal: " & GrandTotal
| > | >>> | >
| > | >>> | > --
| > | >>> | > HTH,
| > | >>> | >
| > | >>> | > Kevin Spencer
| > | >>> | > Microsoft MVP
| > | >>> | > .Net Developer
| > | >>> | > A watched clock never boils.
| > | >>> | >
| > | >>> | >
| > | >>> | > | > | >>> | >> Can anyone point me in the direction of some guidance for
| > handling
| > | >>> | >> recordset values.
| > | >>> | >>
| > | >>> | >> I am trying to calculate a resultant value (total) of
adding 2
| > | >>> values and
| > | >>> | >> mulitplying by the third.
| > | >>> | >>
| > | >>> | >> Eventually I wanted to get total for the resultant value
(all
| > the
| > | >>> totals
| > | >>> | >> added together) for the whole recordset!
| > | >>> | >>
| > | >>> | >> <%
| > | >>> | >> Dim Total
| > | >>> | >> Do While not aScrRst.EOF
| > | >>> | >> Do While not eScrRst.EOF
| > | >>> | >> Do While not iScrRst.EOF
| > | >>> | >> Total = iScrRst("Score") + eScrRst("Score") *
aScrRst("Score")
| > | >>> | >>
| > | >>> | >> Response.Write "Total"
| > | >>> | >>
| > | >>> | >> aScrRst.MoveNext
| > | >>> | >> eScrRst.MoveNext
| > | >>> | >> iScrRst.MoveNext
| > | >>> | >>
| > | >>> | >>
| > | >>> | >> Loop
| > | >>> | >> Loop
| > | >>> | >> Loop
| > | >>> | >> %>
| > | >>> | >>
| > | >>> | >
| > | >>> | >
| > | >>> |
| > | >>> |
| > | >>>
| > | >>>
| > | >>
| > | >>
| > | >
| > | >
| > |
| > |
| >
| >
|
|
 
R

RobA

Thanks,

Could you point me to a reference on join or union query which could create
the singel recordset.

Rob


Kevin Spencer said:
Just a side note: This looks like it could be done with a single
RecordSet, and a JOIN or UNION query.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Complex things are made up of
Lots of simple things.

Stefan B Rusynko said:
Before you start, learn about your data being returned by your nested
loops
Just paste this in a page (where you have opened your 3 connections)

<table align="center" border="1" cellpadding="0" cellspacing="0"
id="table2">
<tr><th>Info</th><th>Score a</th><th>Score e</th><th>Score i</th></tr>
<%
Do While not aScrRst.EOF
aTot = aScrRst("Score")
Do While not eScrRst.EOF
eTot = eScrRst("Score")
Do While not iScrRst.EOF
iTot = iScrRst("Score")
%>
<tr><td>Data / Type</td>
<td><%=aTot & " / " & Typename(aTot)%></td>
<td><%=eTot & " / " & Typename(eTot)%></td>
<td><%=iTot & " / " & Typename(iTot)%></td>
</tr>
<%
aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext
Loop
Loop
Loop
%>
</table>

It also appears you need to start by correctly grouping the data for the
3 QLIDs (a,e,i) based on something in your table like QID
- consider creating 1 recordset and building an array

PS
Also look at your math - you need to use () to set precedence of
calculations to get correct results
SubTotal = aTot + eTot * eTot
is not the same as
SubTotal = (aTot + eTot) * eTot
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I did test it, however, I had the same value in each of the fields so I
| couldn't really see what you were meaning.
|
| I now realise that the I am nutter lol. It is back to the drawing
board by
| the looks of things.
|
|
| Thanks for you help though.
|
| Rob
|
|
| | > Did you really test it w/i each of the loops using the VBscript
function:
| > TypeName("yourvarname")
| > - per my 1st post?
| >
| > PS
| > A zero in some of the fields will give you divide by 0 errors unless
you
| > test for them 1st
| >
| > And again your whole logic appears to be flawed since there is
nothing
| > controlling the order (or grouping) of the numbers you are
| > doing math on - the results will be totally random
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| >
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | > | It is a decimal field in the database that is being pulled into the
| > | recordset.
| > |
| > | There are the same amount of records in each recordset.
| > |
| > | I have tested it without the calculations and all of the recordset
| > values
| > | are returned and can be written, just can't do any calculation.
| > |
| > | Rob
| > | | > | > What is the dat type of these fields?
| > | >
| > | > --
| > | > HTH,
| > | >
| > | > Kevin Spencer
| > | > Microsoft MVP
| > | > .Net Developer
| > | > Complex things are made up of
| > | > Lots of simple things.
| > | >
| > | > | > | >> Cheers for that Stefan,
| > | >>
| > | >> I had been working along the same principle - but I must be
getting
| > | >> something wrong. I have included my script !!!
| > | >> The db where the data is being drawn from requires a value for
each
| > of
| > | >> the recordset fields (it is a , so there shouln't be a return
of an
| > EOF,
| > | >> this page can't be ran until all the values are input. (although
I am
| > | >> hoping a value of 0 wont be returned as a NULL).
| > | >>
| > | >> I just keep getting a
| > | >>
| > | >> Type mismatch
| > | >> /ia/calc01.asp, line 175
| > | >>
| > | >> which seems to happen whenever I attempt any caluculations.
| > | >>
| > | >> <%
| > | >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal,
SubTotal,
| > | >> Total, aStrengthTotal
| > | >>
| > | >> aTot = 0
| > | >> eTot = 0
| > | >> iTot = 0
| > | >> pSubTot = 0
| > | >> aStrengthSubTot = 0
| > | >> pTotal = 0
| > | >> SubTotal = 0
| > | >> aStrengthTotal = 0
| > | >>
| > | >> 'Create Table Header
| > | >> Response.Write "<Table align=center border=1 cellpadding=0
| > | >> cellspacing=0>"
| > | >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
| > | >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| > | >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial
Size=3>Score</TD><TD
| > | >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD
WIDTH=120
| > | >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
| > WIDTH=120><FONT
| > | >> Face=Arial Size=3>Asset Strength</TD></TR>"
| > | >>
| > | >> ' Start Processes
| > | >> 'Transfer recordset values to equation values
| > | >> Do While not aScrRst.EOF
| > | >> aTot = aScrRst("Score")
| > | >> Do While not eScrRst.EOF
| > | >> eTot = eScrRst("Score")
| > | >> Do While not iScrRst.EOF
| > | >> iTot = iScrRst("Score")
| > | >>
| > | >>
| > | >>
| > | >>
| > | >>
| > | >> 'The Calculated Value = 1st and 2nd scores added then multiplied
by
| > 3rd
| > | >> (this calculation is where the error is returned)
| > | >> SubTotal = aTot + eTot * eTot
| > | >>
| > | >> 'The Potential Value Sub Total = 3rd score multiplied by 20
| > mulitplied by
| > | >> 20
| > | >> pSubTot = iTot * 20 * 20
| > | >>
| > | >> 'The Asset Strength Sub Total = Calculated Value devided by the
| > Potential
| > | >> Value multiplied 100
| > | >> aStrengthSubTot = SubTotal / pSubTot * 100
| > | >>
| > | >> 'Total = The sum of all the SubTotals
| > | >> Total = Total + Subtotal
| > | >>
| > | >> 'Potential Total
| > | >> pTotal = pTotal + pSubTot
| > | >>
| > | >>
| > | >> Response.Write "<Table align=center border=1 cellpadding=0
| > | >> cellspacing=0>"
| > | >>
| > | >> Response.Write "<TR ALIGN=CENTER>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write aTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write eTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write iTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write pSubTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write SubTotal
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write aStrength
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "</TR>"
| > | >>
| > | >> Response.Write "<Table>"
| > | >>
| > | >>
| > | >> aScrRst.MoveNext
| > | >> eScrRst.MoveNext
| > | >> iScrRst.MoveNext
| > | >>
| > | >>
| > | >> Loop
| > | >> Loop
| > | >> Loop
| > | >> Response.Write "Total=" & Total
| > | >> Response.Write "Potential Total= " & PTotal
| > | >> aStrengthTotal = Total /PTotal * 100
| > | >> Response.Write "Asset Strength= " & aStrengthTotal
| > | >>
| > | >>
| > | >> %>
| > | >> | > | >>> Validate your data types in each loop while testing using say:
| > | >>>
| > | >>> <%
| > | >>> Do While not aScrRst.EOF
| > | >>> aScore = aScrRst("Score")
| > | >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>"
'test
| > line
| > | >>> Do While not eScrRst.EOF
| > | >>> eScore = eScrRst("Score")
| > | >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>"
'test
| > line
| > | >>> Do While not iScrRst.EOF
| > | >>> iScore = iScrRst("Score")
| > | >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>"
'test
| > line
| > | >>> Total = iScore + eScore * aScore
| > | >>> Response.Write "Total: " & Total & "<br>" 'test line
| > | >>> GrandTotal = GrandTotal + Total
| > | >>> iScrRst.MoveNext
| > | >>> eScrRst.MoveNext
| > | >>> aScrRst.MoveNext
| > | >>> Loop
| > | >>> Loop
| > | >>> Loop
| > | >>> Response.Write "GrandTotal: " & GrandTotal
| > | >>> %>
| > | >>>
| > | >>> I suspect 1 of your loops may be returning an EOF since your
logic
| > is
| > | >>> requiring all 3 recordsets to have 3 "identical" sets of
| > | >>> qualifying data in each loop (a null value or empty string in
any
| > | >>> recordset will also cause the loops to fail)
| > | >>>
| > | >>> PS
| > | >>> Plus your logic will result in unreliable results since there
is no
| > | >>> attempt to order or group the recordset results in any
| > | >>> associated way that is consistent or related to iScore, eScore,
or
| > | >>> aScore as a group
| > | >>> So you will be doing math on 3 random numbers (depending on
each
| > | >>> recordset order returned)
| > | >>> --
| > | >>>
| > | >>> _____________________________________________
| > | >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | >>> "Warning - Using the F1 Key will not break anything!" (-;
| > | >>> To find the best Newsgroup for FrontPage support see:
| > | >>>
| >
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | >>> _____________________________________________
| > | >>>
| > | >>>
| > | >>> | > | >>> | Thanks but I am still getting a type mismatch error.
| > message
| > | >>> | | > | >>> | > <%
| > | >>> | > Dim Total
| > | >>> | > Dim GrandTotal
| > | >>> | > GrandTotal = 0
| > | >>> | > Do While not aScrRst.EOF
| > | >>> | > Do While not eScrRst.EOF
| > | >>> | > Do While not iScrRst.EOF
| > | >>> | > Total = iScrRst("Score") + eScrRst("Score") *
aScrRst("Score")
| > | >>> | > GrandTotal = GrandTotal + Total
| > | >>> | >
| > | >>> | > Response.Write "Total: " & Total
| > | >>> | >
| > | >>> | > aScrRst.MoveNext
| > | >>> | > eScrRst.MoveNext
| > | >>> | > iScrRst.MoveNext
| > | >>> | >
| > | >>> | > Loop
| > | >>> | > Loop
| > | >>> | > Loop
| > | >>> | > Response.Write "GrandTotal: " & GrandTotal
| > | >>> | >
| > | >>> | > --
| > | >>> | > HTH,
| > | >>> | >
| > | >>> | > Kevin Spencer
| > | >>> | > Microsoft MVP
| > | >>> | > .Net Developer
| > | >>> | > A watched clock never boils.
| > | >>> | >
| > | >>> | >
| > | >>> | > | > | >>> | >> Can anyone point me in the direction of some guidance for
| > handling
| > | >>> | >> recordset values.
| > | >>> | >>
| > | >>> | >> I am trying to calculate a resultant value (total) of
adding 2
| > | >>> values and
| > | >>> | >> mulitplying by the third.
| > | >>> | >>
| > | >>> | >> Eventually I wanted to get total for the resultant value
(all
| > the
| > | >>> totals
| > | >>> | >> added together) for the whole recordset!
| > | >>> | >>
| > | >>> | >> <%
| > | >>> | >> Dim Total
| > | >>> | >> Do While not aScrRst.EOF
| > | >>> | >> Do While not eScrRst.EOF
| > | >>> | >> Do While not iScrRst.EOF
| > | >>> | >> Total = iScrRst("Score") + eScrRst("Score") *
aScrRst("Score")
| > | >>> | >>
| > | >>> | >> Response.Write "Total"
| > | >>> | >>
| > | >>> | >> aScrRst.MoveNext
| > | >>> | >> eScrRst.MoveNext
| > | >>> | >> iScrRst.MoveNext
| > | >>> | >>
| > | >>> | >>
| > | >>> | >> Loop
| > | >>> | >> Loop
| > | >>> | >> Loop
| > | >>> | >> %>
| > | >>> | >>
| > | >>> | >
| > | >>> | >
| > | >>> |
| > | >>> |
| > | >>>
| > | >>>
| > | >>
| > | >>
| > | >
| > | >
| > |
| > |
| >
| >
|
|
 
K

Kevin Spencer

What database are you using?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.

RobA said:
Thanks,

Could you point me to a reference on join or union query which could
create the singel recordset.

Rob


Kevin Spencer said:
Just a side note: This looks like it could be done with a single
RecordSet, and a JOIN or UNION query.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Complex things are made up of
Lots of simple things.

Stefan B Rusynko said:
Before you start, learn about your data being returned by your nested
loops
Just paste this in a page (where you have opened your 3 connections)

<table align="center" border="1" cellpadding="0" cellspacing="0"
id="table2">
<tr><th>Info</th><th>Score a</th><th>Score e</th><th>Score i</th></tr>
<%
Do While not aScrRst.EOF
aTot = aScrRst("Score")
Do While not eScrRst.EOF
eTot = eScrRst("Score")
Do While not iScrRst.EOF
iTot = iScrRst("Score")
%>
<tr><td>Data / Type</td>
<td><%=aTot & " / " & Typename(aTot)%></td>
<td><%=eTot & " / " & Typename(eTot)%></td>
<td><%=iTot & " / " & Typename(iTot)%></td>
</tr>
<%
aScrRst.MoveNext
eScrRst.MoveNext
iScrRst.MoveNext
Loop
Loop
Loop
%>
</table>

It also appears you need to start by correctly grouping the data for the
3 QLIDs (a,e,i) based on something in your table like QID
- consider creating 1 recordset and building an array

PS
Also look at your math - you need to use () to set precedence of
calculations to get correct results
SubTotal = aTot + eTot * eTot
is not the same as
SubTotal = (aTot + eTot) * eTot
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|I did test it, however, I had the same value in each of the fields so I
| couldn't really see what you were meaning.
|
| I now realise that the I am nutter lol. It is back to the drawing
board by
| the looks of things.
|
|
| Thanks for you help though.
|
| Rob
|
|
| | > Did you really test it w/i each of the loops using the VBscript
function:
| > TypeName("yourvarname")
| > - per my 1st post?
| >
| > PS
| > A zero in some of the fields will give you divide by 0 errors unless
you
| > test for them 1st
| >
| > And again your whole logic appears to be flawed since there is
nothing
| > controlling the order (or grouping) of the numbers you are
| > doing math on - the results will be totally random
| > --
| >
| > _____________________________________________
| > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > "Warning - Using the F1 Key will not break anything!" (-;
| > To find the best Newsgroup for FrontPage support see:
| >
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > _____________________________________________
| >
| >
| > | > | It is a decimal field in the database that is being pulled into
the
| > | recordset.
| > |
| > | There are the same amount of records in each recordset.
| > |
| > | I have tested it without the calculations and all of the recordset
| > values
| > | are returned and can be written, just can't do any calculation.
| > |
| > | Rob
message
| > | | > | > What is the dat type of these fields?
| > | >
| > | > --
| > | > HTH,
| > | >
| > | > Kevin Spencer
| > | > Microsoft MVP
| > | > .Net Developer
| > | > Complex things are made up of
| > | > Lots of simple things.
| > | >
| > | > | > | >> Cheers for that Stefan,
| > | >>
| > | >> I had been working along the same principle - but I must be
getting
| > | >> something wrong. I have included my script !!!
| > | >> The db where the data is being drawn from requires a value for
each
| > of
| > | >> the recordset fields (it is a , so there shouln't be a return
of an
| > EOF,
| > | >> this page can't be ran until all the values are input.
(although I am
| > | >> hoping a value of 0 wont be returned as a NULL).
| > | >>
| > | >> I just keep getting a
| > | >>
| > | >> Type mismatch
| > | >> /ia/calc01.asp, line 175
| > | >>
| > | >> which seems to happen whenever I attempt any caluculations.
| > | >>
| > | >> <%
| > | >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal,
SubTotal,
| > | >> Total, aStrengthTotal
| > | >>
| > | >> aTot = 0
| > | >> eTot = 0
| > | >> iTot = 0
| > | >> pSubTot = 0
| > | >> aStrengthSubTot = 0
| > | >> pTotal = 0
| > | >> SubTotal = 0
| > | >> aStrengthTotal = 0
| > | >>
| > | >> 'Create Table Header
| > | >> Response.Write "<Table align=center border=1 cellpadding=0
| > | >> cellspacing=0>"
| > | >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
| > | >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| > | >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial
Size=3>Score</TD><TD
| > | >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD
WIDTH=120
| > | >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
| > WIDTH=120><FONT
| > | >> Face=Arial Size=3>Asset Strength</TD></TR>"
| > | >>
| > | >> ' Start Processes
| > | >> 'Transfer recordset values to equation values
| > | >> Do While not aScrRst.EOF
| > | >> aTot = aScrRst("Score")
| > | >> Do While not eScrRst.EOF
| > | >> eTot = eScrRst("Score")
| > | >> Do While not iScrRst.EOF
| > | >> iTot = iScrRst("Score")
| > | >>
| > | >>
| > | >>
| > | >>
| > | >>
| > | >> 'The Calculated Value = 1st and 2nd scores added then
multiplied by
| > 3rd
| > | >> (this calculation is where the error is returned)
| > | >> SubTotal = aTot + eTot * eTot
| > | >>
| > | >> 'The Potential Value Sub Total = 3rd score multiplied by 20
| > mulitplied by
| > | >> 20
| > | >> pSubTot = iTot * 20 * 20
| > | >>
| > | >> 'The Asset Strength Sub Total = Calculated Value devided by the
| > Potential
| > | >> Value multiplied 100
| > | >> aStrengthSubTot = SubTotal / pSubTot * 100
| > | >>
| > | >> 'Total = The sum of all the SubTotals
| > | >> Total = Total + Subtotal
| > | >>
| > | >> 'Potential Total
| > | >> pTotal = pTotal + pSubTot
| > | >>
| > | >>
| > | >> Response.Write "<Table align=center border=1 cellpadding=0
| > | >> cellspacing=0>"
| > | >>
| > | >> Response.Write "<TR ALIGN=CENTER>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write aTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write eTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=60>"
| > | >> Response.Write iTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write pSubTot
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write SubTotal
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "<TD WIDTH=120>"
| > | >> Response.Write aStrength
| > | >> Response.Write "</TD>"
| > | >>
| > | >> Response.Write "</TR>"
| > | >>
| > | >> Response.Write "<Table>"
| > | >>
| > | >>
| > | >> aScrRst.MoveNext
| > | >> eScrRst.MoveNext
| > | >> iScrRst.MoveNext
| > | >>
| > | >>
| > | >> Loop
| > | >> Loop
| > | >> Loop
| > | >> Response.Write "Total=" & Total
| > | >> Response.Write "Potential Total= " & PTotal
| > | >> aStrengthTotal = Total /PTotal * 100
| > | >> Response.Write "Asset Strength= " & aStrengthTotal
| > | >>
| > | >>
| > | >> %>
| > | >> | > | >>> Validate your data types in each loop while testing using say:
| > | >>>
| > | >>> <%
| > | >>> Do While not aScrRst.EOF
| > | >>> aScore = aScrRst("Score")
| > | >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>"
'test
| > line
| > | >>> Do While not eScrRst.EOF
| > | >>> eScore = eScrRst("Score")
| > | >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>"
'test
| > line
| > | >>> Do While not iScrRst.EOF
| > | >>> iScore = iScrRst("Score")
| > | >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>"
'test
| > line
| > | >>> Total = iScore + eScore * aScore
| > | >>> Response.Write "Total: " & Total & "<br>" 'test line
| > | >>> GrandTotal = GrandTotal + Total
| > | >>> iScrRst.MoveNext
| > | >>> eScrRst.MoveNext
| > | >>> aScrRst.MoveNext
| > | >>> Loop
| > | >>> Loop
| > | >>> Loop
| > | >>> Response.Write "GrandTotal: " & GrandTotal
| > | >>> %>
| > | >>>
| > | >>> I suspect 1 of your loops may be returning an EOF since your
logic
| > is
| > | >>> requiring all 3 recordsets to have 3 "identical" sets of
| > | >>> qualifying data in each loop (a null value or empty string in
any
| > | >>> recordset will also cause the loops to fail)
| > | >>>
| > | >>> PS
| > | >>> Plus your logic will result in unreliable results since there
is no
| > | >>> attempt to order or group the recordset results in any
| > | >>> associated way that is consistent or related to iScore,
eScore, or
| > | >>> aScore as a group
| > | >>> So you will be doing math on 3 random numbers (depending on
each
| > | >>> recordset order returned)
| > | >>> --
| > | >>>
| > | >>> _____________________________________________
| > | >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| > | >>> "Warning - Using the F1 Key will not break anything!" (-;
| > | >>> To find the best Newsgroup for FrontPage support see:
| > | >>>
| >
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| > | >>> _____________________________________________
| > | >>>
| > | >>>
| > | >>> | > | >>> | Thanks but I am still getting a type mismatch error.
| > message
| > | >>> | | > | >>> | > <%
| > | >>> | > Dim Total
| > | >>> | > Dim GrandTotal
| > | >>> | > GrandTotal = 0
| > | >>> | > Do While not aScrRst.EOF
| > | >>> | > Do While not eScrRst.EOF
| > | >>> | > Do While not iScrRst.EOF
| > | >>> | > Total = iScrRst("Score") + eScrRst("Score") *
aScrRst("Score")
| > | >>> | > GrandTotal = GrandTotal + Total
| > | >>> | >
| > | >>> | > Response.Write "Total: " & Total
| > | >>> | >
| > | >>> | > aScrRst.MoveNext
| > | >>> | > eScrRst.MoveNext
| > | >>> | > iScrRst.MoveNext
| > | >>> | >
| > | >>> | > Loop
| > | >>> | > Loop
| > | >>> | > Loop
| > | >>> | > Response.Write "GrandTotal: " & GrandTotal
| > | >>> | >
| > | >>> | > --
| > | >>> | > HTH,
| > | >>> | >
| > | >>> | > Kevin Spencer
| > | >>> | > Microsoft MVP
| > | >>> | > .Net Developer
| > | >>> | > A watched clock never boils.
| > | >>> | >
| > | >>> | >
| > | >>> | > | > | >>> | >> Can anyone point me in the direction of some guidance for
| > handling
| > | >>> | >> recordset values.
| > | >>> | >>
| > | >>> | >> I am trying to calculate a resultant value (total) of
adding 2
| > | >>> values and
| > | >>> | >> mulitplying by the third.
| > | >>> | >>
| > | >>> | >> Eventually I wanted to get total for the resultant value
(all
| > the
| > | >>> totals
| > | >>> | >> added together) for the whole recordset!
| > | >>> | >>
| > | >>> | >> <%
| > | >>> | >> Dim Total
| > | >>> | >> Do While not aScrRst.EOF
| > | >>> | >> Do While not eScrRst.EOF
| > | >>> | >> Do While not iScrRst.EOF
| > | >>> | >> Total = iScrRst("Score") + eScrRst("Score") *
aScrRst("Score")
| > | >>> | >>
| > | >>> | >> Response.Write "Total"
| > | >>> | >>
| > | >>> | >> aScrRst.MoveNext
| > | >>> | >> eScrRst.MoveNext
| > | >>> | >> iScrRst.MoveNext
| > | >>> | >>
| > | >>> | >>
| > | >>> | >> Loop
| > | >>> | >> Loop
| > | >>> | >> Loop
| > | >>> | >> %>
| > | >>> | >>
| > | >>> | >
| > | >>> | >
| > | >>> |
| > | >>> |
| > | >>>
| > | >>>
| > | >>
| > | >>
| > | >
| > | >
| > |
| > |
| >
| >
|
|
 
S

Stefan B Rusynko

You can look at
http://home.att.net/~codelibrary/FrontPage/detail.htm
But a Join won't help since all your data is in 1 table and a Join or Union is normally used for table relationships of multiple
tables

Suggest you look at your basic data structure and decide if it is correct for your goal

IMHO
using a single field "Score" for all 3 score values is the start of your correlation problem

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thanks,
|
| Could you point me to a reference on join or union query which could create
| the singel recordset.
|
| Rob
|
|
| | > Just a side note: This looks like it could be done with a single
| > RecordSet, and a JOIN or UNION query.
| >
| > --
| > HTH,
| >
| > Kevin Spencer
| > Microsoft MVP
| > .Net Developer
| > Complex things are made up of
| > Lots of simple things.
| >
| > | >> Before you start, learn about your data being returned by your nested
| >> loops
| >> Just paste this in a page (where you have opened your 3 connections)
| >>
| >> <table align="center" border="1" cellpadding="0" cellspacing="0"
| >> id="table2">
| >> <tr><th>Info</th><th>Score a</th><th>Score e</th><th>Score i</th></tr>
| >> <%
| >> Do While not aScrRst.EOF
| >> aTot = aScrRst("Score")
| >> Do While not eScrRst.EOF
| >> eTot = eScrRst("Score")
| >> Do While not iScrRst.EOF
| >> iTot = iScrRst("Score")
| >> %>
| >> <tr><td>Data / Type</td>
| >> <td><%=aTot & " / " & Typename(aTot)%></td>
| >> <td><%=eTot & " / " & Typename(eTot)%></td>
| >> <td><%=iTot & " / " & Typename(iTot)%></td>
| >> </tr>
| >> <%
| >> aScrRst.MoveNext
| >> eScrRst.MoveNext
| >> iScrRst.MoveNext
| >> Loop
| >> Loop
| >> Loop
| >> %>
| >> </table>
| >>
| >> It also appears you need to start by correctly grouping the data for the
| >> 3 QLIDs (a,e,i) based on something in your table like QID
| >> - consider creating 1 recordset and building an array
| >>
| >> PS
| >> Also look at your math - you need to use () to set precedence of
| >> calculations to get correct results
| >> SubTotal = aTot + eTot * eTot
| >> is not the same as
| >> SubTotal = (aTot + eTot) * eTot
| >> --
| >>
| >> _____________________________________________
| >> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >> "Warning - Using the F1 Key will not break anything!" (-;
| >> To find the best Newsgroup for FrontPage support see:
| >> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >> _____________________________________________
| >>
| >>
| >> | >> |I did test it, however, I had the same value in each of the fields so I
| >> | couldn't really see what you were meaning.
| >> |
| >> | I now realise that the I am nutter lol. It is back to the drawing
| >> board by
| >> | the looks of things.
| >> |
| >> |
| >> | Thanks for you help though.
| >> |
| >> | Rob
| >> |
| >> |
| >> | | >> | > Did you really test it w/i each of the loops using the VBscript
| >> function:
| >> | > TypeName("yourvarname")
| >> | > - per my 1st post?
| >> | >
| >> | > PS
| >> | > A zero in some of the fields will give you divide by 0 errors unless
| >> you
| >> | > test for them 1st
| >> | >
| >> | > And again your whole logic appears to be flawed since there is
| >> nothing
| >> | > controlling the order (or grouping) of the numbers you are
| >> | > doing math on - the results will be totally random
| >> | > --
| >> | >
| >> | > _____________________________________________
| >> | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >> | > "Warning - Using the F1 Key will not break anything!" (-;
| >> | > To find the best Newsgroup for FrontPage support see:
| >> | >
| >> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >> | > _____________________________________________
| >> | >
| >> | >
| >> | > | >> | > | It is a decimal field in the database that is being pulled into the
| >> | > | recordset.
| >> | > |
| >> | > | There are the same amount of records in each recordset.
| >> | > |
| >> | > | I have tested it without the calculations and all of the recordset
| >> | > values
| >> | > | are returned and can be written, just can't do any calculation.
| >> | > |
| >> | > | Rob
| >> | > | | >> | > | > What is the dat type of these fields?
| >> | > | >
| >> | > | > --
| >> | > | > HTH,
| >> | > | >
| >> | > | > Kevin Spencer
| >> | > | > Microsoft MVP
| >> | > | > .Net Developer
| >> | > | > Complex things are made up of
| >> | > | > Lots of simple things.
| >> | > | >
| >> | > | > | >> | > | >> Cheers for that Stefan,
| >> | > | >>
| >> | > | >> I had been working along the same principle - but I must be
| >> getting
| >> | > | >> something wrong. I have included my script !!!
| >> | > | >> The db where the data is being drawn from requires a value for
| >> each
| >> | > of
| >> | > | >> the recordset fields (it is a , so there shouln't be a return
| >> of an
| >> | > EOF,
| >> | > | >> this page can't be ran until all the values are input. (although
| >> I am
| >> | > | >> hoping a value of 0 wont be returned as a NULL).
| >> | > | >>
| >> | > | >> I just keep getting a
| >> | > | >>
| >> | > | >> Type mismatch
| >> | > | >> /ia/calc01.asp, line 175
| >> | > | >>
| >> | > | >> which seems to happen whenever I attempt any caluculations.
| >> | > | >>
| >> | > | >> <%
| >> | > | >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal,
| >> SubTotal,
| >> | > | >> Total, aStrengthTotal
| >> | > | >>
| >> | > | >> aTot = 0
| >> | > | >> eTot = 0
| >> | > | >> iTot = 0
| >> | > | >> pSubTot = 0
| >> | > | >> aStrengthSubTot = 0
| >> | > | >> pTotal = 0
| >> | > | >> SubTotal = 0
| >> | > | >> aStrengthTotal = 0
| >> | > | >>
| >> | > | >> 'Create Table Header
| >> | > | >> Response.Write "<Table align=center border=1 cellpadding=0
| >> | > | >> cellspacing=0>"
| >> | > | >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
| >> | > | >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| >> | > | >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial
| >> Size=3>Score</TD><TD
| >> | > | >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD
| >> WIDTH=120
| >> | > | >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
| >> | > WIDTH=120><FONT
| >> | > | >> Face=Arial Size=3>Asset Strength</TD></TR>"
| >> | > | >>
| >> | > | >> ' Start Processes
| >> | > | >> 'Transfer recordset values to equation values
| >> | > | >> Do While not aScrRst.EOF
| >> | > | >> aTot = aScrRst("Score")
| >> | > | >> Do While not eScrRst.EOF
| >> | > | >> eTot = eScrRst("Score")
| >> | > | >> Do While not iScrRst.EOF
| >> | > | >> iTot = iScrRst("Score")
| >> | > | >>
| >> | > | >>
| >> | > | >>
| >> | > | >>
| >> | > | >>
| >> | > | >> 'The Calculated Value = 1st and 2nd scores added then multiplied
| >> by
| >> | > 3rd
| >> | > | >> (this calculation is where the error is returned)
| >> | > | >> SubTotal = aTot + eTot * eTot
| >> | > | >>
| >> | > | >> 'The Potential Value Sub Total = 3rd score multiplied by 20
| >> | > mulitplied by
| >> | > | >> 20
| >> | > | >> pSubTot = iTot * 20 * 20
| >> | > | >>
| >> | > | >> 'The Asset Strength Sub Total = Calculated Value devided by the
| >> | > Potential
| >> | > | >> Value multiplied 100
| >> | > | >> aStrengthSubTot = SubTotal / pSubTot * 100
| >> | > | >>
| >> | > | >> 'Total = The sum of all the SubTotals
| >> | > | >> Total = Total + Subtotal
| >> | > | >>
| >> | > | >> 'Potential Total
| >> | > | >> pTotal = pTotal + pSubTot
| >> | > | >>
| >> | > | >>
| >> | > | >> Response.Write "<Table align=center border=1 cellpadding=0
| >> | > | >> cellspacing=0>"
| >> | > | >>
| >> | > | >> Response.Write "<TR ALIGN=CENTER>"
| >> | > | >>
| >> | > | >> Response.Write "<TD WIDTH=60>"
| >> | > | >> Response.Write aTot
| >> | > | >> Response.Write "</TD>"
| >> | > | >>
| >> | > | >> Response.Write "<TD WIDTH=60>"
| >> | > | >> Response.Write eTot
| >> | > | >> Response.Write "</TD>"
| >> | > | >>
| >> | > | >> Response.Write "<TD WIDTH=60>"
| >> | > | >> Response.Write iTot
| >> | > | >> Response.Write "</TD>"
| >> | > | >>
| >> | > | >> Response.Write "<TD WIDTH=120>"
| >> | > | >> Response.Write pSubTot
| >> | > | >> Response.Write "</TD>"
| >> | > | >>
| >> | > | >> Response.Write "<TD WIDTH=120>"
| >> | > | >> Response.Write SubTotal
| >> | > | >> Response.Write "</TD>"
| >> | > | >>
| >> | > | >> Response.Write "<TD WIDTH=120>"
| >> | > | >> Response.Write aStrength
| >> | > | >> Response.Write "</TD>"
| >> | > | >>
| >> | > | >> Response.Write "</TR>"
| >> | > | >>
| >> | > | >> Response.Write "<Table>"
| >> | > | >>
| >> | > | >>
| >> | > | >> aScrRst.MoveNext
| >> | > | >> eScrRst.MoveNext
| >> | > | >> iScrRst.MoveNext
| >> | > | >>
| >> | > | >>
| >> | > | >> Loop
| >> | > | >> Loop
| >> | > | >> Loop
| >> | > | >> Response.Write "Total=" & Total
| >> | > | >> Response.Write "Potential Total= " & PTotal
| >> | > | >> aStrengthTotal = Total /PTotal * 100
| >> | > | >> Response.Write "Asset Strength= " & aStrengthTotal
| >> | > | >>
| >> | > | >>
| >> | > | >> %>
| >> | > | >> | >> | > | >>> Validate your data types in each loop while testing using say:
| >> | > | >>>
| >> | > | >>> <%
| >> | > | >>> Do While not aScrRst.EOF
| >> | > | >>> aScore = aScrRst("Score")
| >> | > | >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>"
| >> 'test
| >> | > line
| >> | > | >>> Do While not eScrRst.EOF
| >> | > | >>> eScore = eScrRst("Score")
| >> | > | >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>"
| >> 'test
| >> | > line
| >> | > | >>> Do While not iScrRst.EOF
| >> | > | >>> iScore = iScrRst("Score")
| >> | > | >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>"
| >> 'test
| >> | > line
| >> | > | >>> Total = iScore + eScore * aScore
| >> | > | >>> Response.Write "Total: " & Total & "<br>" 'test line
| >> | > | >>> GrandTotal = GrandTotal + Total
| >> | > | >>> iScrRst.MoveNext
| >> | > | >>> eScrRst.MoveNext
| >> | > | >>> aScrRst.MoveNext
| >> | > | >>> Loop
| >> | > | >>> Loop
| >> | > | >>> Loop
| >> | > | >>> Response.Write "GrandTotal: " & GrandTotal
| >> | > | >>> %>
| >> | > | >>>
| >> | > | >>> I suspect 1 of your loops may be returning an EOF since your
| >> logic
| >> | > is
| >> | > | >>> requiring all 3 recordsets to have 3 "identical" sets of
| >> | > | >>> qualifying data in each loop (a null value or empty string in
| >> any
| >> | > | >>> recordset will also cause the loops to fail)
| >> | > | >>>
| >> | > | >>> PS
| >> | > | >>> Plus your logic will result in unreliable results since there
| >> is no
| >> | > | >>> attempt to order or group the recordset results in any
| >> | > | >>> associated way that is consistent or related to iScore, eScore,
| >> or
| >> | > | >>> aScore as a group
| >> | > | >>> So you will be doing math on 3 random numbers (depending on
| >> each
| >> | > | >>> recordset order returned)
| >> | > | >>> --
| >> | > | >>>
| >> | > | >>> _____________________________________________
| >> | > | >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >> | > | >>> "Warning - Using the F1 Key will not break anything!" (-;
| >> | > | >>> To find the best Newsgroup for FrontPage support see:
| >> | > | >>>
| >> | >
| >> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >> | > | >>> _____________________________________________
| >> | > | >>>
| >> | > | >>>
| >> | > | >>> | >> | > | >>> | Thanks but I am still getting a type mismatch error.
| >> | > message
| >> | > | >>> | | >> | > | >>> | > <%
| >> | > | >>> | > Dim Total
| >> | > | >>> | > Dim GrandTotal
| >> | > | >>> | > GrandTotal = 0
| >> | > | >>> | > Do While not aScrRst.EOF
| >> | > | >>> | > Do While not eScrRst.EOF
| >> | > | >>> | > Do While not iScrRst.EOF
| >> | > | >>> | > Total = iScrRst("Score") + eScrRst("Score") *
| >> aScrRst("Score")
| >> | > | >>> | > GrandTotal = GrandTotal + Total
| >> | > | >>> | >
| >> | > | >>> | > Response.Write "Total: " & Total
| >> | > | >>> | >
| >> | > | >>> | > aScrRst.MoveNext
| >> | > | >>> | > eScrRst.MoveNext
| >> | > | >>> | > iScrRst.MoveNext
| >> | > | >>> | >
| >> | > | >>> | > Loop
| >> | > | >>> | > Loop
| >> | > | >>> | > Loop
| >> | > | >>> | > Response.Write "GrandTotal: " & GrandTotal
| >> | > | >>> | >
| >> | > | >>> | > --
| >> | > | >>> | > HTH,
| >> | > | >>> | >
| >> | > | >>> | > Kevin Spencer
| >> | > | >>> | > Microsoft MVP
| >> | > | >>> | > .Net Developer
| >> | > | >>> | > A watched clock never boils.
| >> | > | >>> | >
| >> | > | >>> | >
| >> | > | >>> | > | >> | > | >>> | >> Can anyone point me in the direction of some guidance for
| >> | > handling
| >> | > | >>> | >> recordset values.
| >> | > | >>> | >>
| >> | > | >>> | >> I am trying to calculate a resultant value (total) of
| >> adding 2
| >> | > | >>> values and
| >> | > | >>> | >> mulitplying by the third.
| >> | > | >>> | >>
| >> | > | >>> | >> Eventually I wanted to get total for the resultant value
| >> (all
| >> | > the
| >> | > | >>> totals
| >> | > | >>> | >> added together) for the whole recordset!
| >> | > | >>> | >>
| >> | > | >>> | >> <%
| >> | > | >>> | >> Dim Total
| >> | > | >>> | >> Do While not aScrRst.EOF
| >> | > | >>> | >> Do While not eScrRst.EOF
| >> | > | >>> | >> Do While not iScrRst.EOF
| >> | > | >>> | >> Total = iScrRst("Score") + eScrRst("Score") *
| >> aScrRst("Score")
| >> | > | >>> | >>
| >> | > | >>> | >> Response.Write "Total"
| >> | > | >>> | >>
| >> | > | >>> | >> aScrRst.MoveNext
| >> | > | >>> | >> eScrRst.MoveNext
| >> | > | >>> | >> iScrRst.MoveNext
| >> | > | >>> | >>
| >> | > | >>> | >>
| >> | > | >>> | >> Loop
| >> | > | >>> | >> Loop
| >> | > | >>> | >> Loop
| >> | > | >>> | >> %>
| >> | > | >>> | >>
| >> | > | >>> | >
| >> | > | >>> | >
| >> | > | >>> |
| >> | > | >>> |
| >> | > | >>>
| >> | > | >>>
| >> | > | >>
| >> | > | >>
| >> | > | >
| >> | > | >
| >> | > |
| >> | > |
| >> | >
| >> | >
| >> |
| >> |
| >>
| >>
| >
| >
|
|
 
S

Stefan B Rusynko

Kevin

He is using 1 db/table w/ 3 rs calls on it

aSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'A' AND iauID= " & UID
Set aScrRst = objConn.Execute (aSQLstr)
eSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'E' AND iauID= " & UID
Set eScrRst = objConn.Execute (aSQLstr)
iSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'I' AND iauID= " & UID
Set iScrRst = objConn.Execute (aSQLstr)

As I have pointed out to him in my other responses, there is no correlation of his 3 "sets" being in sync or all having valid data
- I think he needs to go back to basics and get his DB table correct to simplify the process
(probably by generating the data for all 3 scores in 1 record as aScore, eScore, iScore rather than using the QLID as a qualifier,
or using QID, if it links the 3 related sets, as a grouping of the data)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| What database are you using?
|
| --
| HTH,
|
| Kevin Spencer
| Microsoft MVP
| .Net Developer
| Complex things are made up of
| Lots of simple things.
|
| | > Thanks,
| >
| > Could you point me to a reference on join or union query which could
| > create the singel recordset.
| >
| > Rob
| >
| >
| > | >> Just a side note: This looks like it could be done with a single
| >> RecordSet, and a JOIN or UNION query.
| >>
| >> --
| >> HTH,
| >>
| >> Kevin Spencer
| >> Microsoft MVP
| >> .Net Developer
| >> Complex things are made up of
| >> Lots of simple things.
| >>
| >> | >>> Before you start, learn about your data being returned by your nested
| >>> loops
| >>> Just paste this in a page (where you have opened your 3 connections)
| >>>
| >>> <table align="center" border="1" cellpadding="0" cellspacing="0"
| >>> id="table2">
| >>> <tr><th>Info</th><th>Score a</th><th>Score e</th><th>Score i</th></tr>
| >>> <%
| >>> Do While not aScrRst.EOF
| >>> aTot = aScrRst("Score")
| >>> Do While not eScrRst.EOF
| >>> eTot = eScrRst("Score")
| >>> Do While not iScrRst.EOF
| >>> iTot = iScrRst("Score")
| >>> %>
| >>> <tr><td>Data / Type</td>
| >>> <td><%=aTot & " / " & Typename(aTot)%></td>
| >>> <td><%=eTot & " / " & Typename(eTot)%></td>
| >>> <td><%=iTot & " / " & Typename(iTot)%></td>
| >>> </tr>
| >>> <%
| >>> aScrRst.MoveNext
| >>> eScrRst.MoveNext
| >>> iScrRst.MoveNext
| >>> Loop
| >>> Loop
| >>> Loop
| >>> %>
| >>> </table>
| >>>
| >>> It also appears you need to start by correctly grouping the data for the
| >>> 3 QLIDs (a,e,i) based on something in your table like QID
| >>> - consider creating 1 recordset and building an array
| >>>
| >>> PS
| >>> Also look at your math - you need to use () to set precedence of
| >>> calculations to get correct results
| >>> SubTotal = aTot + eTot * eTot
| >>> is not the same as
| >>> SubTotal = (aTot + eTot) * eTot
| >>> --
| >>>
| >>> _____________________________________________
| >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>> "Warning - Using the F1 Key will not break anything!" (-;
| >>> To find the best Newsgroup for FrontPage support see:
| >>> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >>> _____________________________________________
| >>>
| >>>
| >>> | >>> |I did test it, however, I had the same value in each of the fields so I
| >>> | couldn't really see what you were meaning.
| >>> |
| >>> | I now realise that the I am nutter lol. It is back to the drawing
| >>> board by
| >>> | the looks of things.
| >>> |
| >>> |
| >>> | Thanks for you help though.
| >>> |
| >>> | Rob
| >>> |
| >>> |
| >>> | | >>> | > Did you really test it w/i each of the loops using the VBscript
| >>> function:
| >>> | > TypeName("yourvarname")
| >>> | > - per my 1st post?
| >>> | >
| >>> | > PS
| >>> | > A zero in some of the fields will give you divide by 0 errors unless
| >>> you
| >>> | > test for them 1st
| >>> | >
| >>> | > And again your whole logic appears to be flawed since there is
| >>> nothing
| >>> | > controlling the order (or grouping) of the numbers you are
| >>> | > doing math on - the results will be totally random
| >>> | > --
| >>> | >
| >>> | > _____________________________________________
| >>> | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>> | > "Warning - Using the F1 Key will not break anything!" (-;
| >>> | > To find the best Newsgroup for FrontPage support see:
| >>> | >
| >>> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >>> | > _____________________________________________
| >>> | >
| >>> | >
| >>> | > | >>> | > | It is a decimal field in the database that is being pulled into
| >>> the
| >>> | > | recordset.
| >>> | > |
| >>> | > | There are the same amount of records in each recordset.
| >>> | > |
| >>> | > | I have tested it without the calculations and all of the recordset
| >>> | > values
| >>> | > | are returned and can be written, just can't do any calculation.
| >>> | > |
| >>> | > | Rob
| >>> message
| >>> | > | | >>> | > | > What is the dat type of these fields?
| >>> | > | >
| >>> | > | > --
| >>> | > | > HTH,
| >>> | > | >
| >>> | > | > Kevin Spencer
| >>> | > | > Microsoft MVP
| >>> | > | > .Net Developer
| >>> | > | > Complex things are made up of
| >>> | > | > Lots of simple things.
| >>> | > | >
| >>> | > | > | >>> | > | >> Cheers for that Stefan,
| >>> | > | >>
| >>> | > | >> I had been working along the same principle - but I must be
| >>> getting
| >>> | > | >> something wrong. I have included my script !!!
| >>> | > | >> The db where the data is being drawn from requires a value for
| >>> each
| >>> | > of
| >>> | > | >> the recordset fields (it is a , so there shouln't be a return
| >>> of an
| >>> | > EOF,
| >>> | > | >> this page can't be ran until all the values are input.
| >>> (although I am
| >>> | > | >> hoping a value of 0 wont be returned as a NULL).
| >>> | > | >>
| >>> | > | >> I just keep getting a
| >>> | > | >>
| >>> | > | >> Type mismatch
| >>> | > | >> /ia/calc01.asp, line 175
| >>> | > | >>
| >>> | > | >> which seems to happen whenever I attempt any caluculations.
| >>> | > | >>
| >>> | > | >> <%
| >>> | > | >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal,
| >>> SubTotal,
| >>> | > | >> Total, aStrengthTotal
| >>> | > | >>
| >>> | > | >> aTot = 0
| >>> | > | >> eTot = 0
| >>> | > | >> iTot = 0
| >>> | > | >> pSubTot = 0
| >>> | > | >> aStrengthSubTot = 0
| >>> | > | >> pTotal = 0
| >>> | > | >> SubTotal = 0
| >>> | > | >> aStrengthTotal = 0
| >>> | > | >>
| >>> | > | >> 'Create Table Header
| >>> | > | >> Response.Write "<Table align=center border=1 cellpadding=0
| >>> | > | >> cellspacing=0>"
| >>> | > | >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT Face=Arial
| >>> | > | >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| >>> | > | >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial
| >>> Size=3>Score</TD><TD
| >>> | > | >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD
| >>> WIDTH=120
| >>> | > | >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
| >>> | > WIDTH=120><FONT
| >>> | > | >> Face=Arial Size=3>Asset Strength</TD></TR>"
| >>> | > | >>
| >>> | > | >> ' Start Processes
| >>> | > | >> 'Transfer recordset values to equation values
| >>> | > | >> Do While not aScrRst.EOF
| >>> | > | >> aTot = aScrRst("Score")
| >>> | > | >> Do While not eScrRst.EOF
| >>> | > | >> eTot = eScrRst("Score")
| >>> | > | >> Do While not iScrRst.EOF
| >>> | > | >> iTot = iScrRst("Score")
| >>> | > | >>
| >>> | > | >>
| >>> | > | >>
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> 'The Calculated Value = 1st and 2nd scores added then
| >>> multiplied by
| >>> | > 3rd
| >>> | > | >> (this calculation is where the error is returned)
| >>> | > | >> SubTotal = aTot + eTot * eTot
| >>> | > | >>
| >>> | > | >> 'The Potential Value Sub Total = 3rd score multiplied by 20
| >>> | > mulitplied by
| >>> | > | >> 20
| >>> | > | >> pSubTot = iTot * 20 * 20
| >>> | > | >>
| >>> | > | >> 'The Asset Strength Sub Total = Calculated Value devided by the
| >>> | > Potential
| >>> | > | >> Value multiplied 100
| >>> | > | >> aStrengthSubTot = SubTotal / pSubTot * 100
| >>> | > | >>
| >>> | > | >> 'Total = The sum of all the SubTotals
| >>> | > | >> Total = Total + Subtotal
| >>> | > | >>
| >>> | > | >> 'Potential Total
| >>> | > | >> pTotal = pTotal + pSubTot
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> Response.Write "<Table align=center border=1 cellpadding=0
| >>> | > | >> cellspacing=0>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TR ALIGN=CENTER>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=60>"
| >>> | > | >> Response.Write aTot
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=60>"
| >>> | > | >> Response.Write eTot
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=60>"
| >>> | > | >> Response.Write iTot
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=120>"
| >>> | > | >> Response.Write pSubTot
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=120>"
| >>> | > | >> Response.Write SubTotal
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=120>"
| >>> | > | >> Response.Write aStrength
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "</TR>"
| >>> | > | >>
| >>> | > | >> Response.Write "<Table>"
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> aScrRst.MoveNext
| >>> | > | >> eScrRst.MoveNext
| >>> | > | >> iScrRst.MoveNext
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> Loop
| >>> | > | >> Loop
| >>> | > | >> Loop
| >>> | > | >> Response.Write "Total=" & Total
| >>> | > | >> Response.Write "Potential Total= " & PTotal
| >>> | > | >> aStrengthTotal = Total /PTotal * 100
| >>> | > | >> Response.Write "Asset Strength= " & aStrengthTotal
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> %>
| >>> | > | >> | >>> | > | >>> Validate your data types in each loop while testing using say:
| >>> | > | >>>
| >>> | > | >>> <%
| >>> | > | >>> Do While not aScrRst.EOF
| >>> | > | >>> aScore = aScrRst("Score")
| >>> | > | >>> Response.write "aScrRst = " & TypeName("aScore") &"<br>"
| >>> 'test
| >>> | > line
| >>> | > | >>> Do While not eScrRst.EOF
| >>> | > | >>> eScore = eScrRst("Score")
| >>> | > | >>> Response.write "eScrRst = " & TypeName("eScore") &"<br>"
| >>> 'test
| >>> | > line
| >>> | > | >>> Do While not iScrRst.EOF
| >>> | > | >>> iScore = iScrRst("Score")
| >>> | > | >>> Response.write "iScrRst = " & TypeName("iScore") &"<br>"
| >>> 'test
| >>> | > line
| >>> | > | >>> Total = iScore + eScore * aScore
| >>> | > | >>> Response.Write "Total: " & Total & "<br>" 'test line
| >>> | > | >>> GrandTotal = GrandTotal + Total
| >>> | > | >>> iScrRst.MoveNext
| >>> | > | >>> eScrRst.MoveNext
| >>> | > | >>> aScrRst.MoveNext
| >>> | > | >>> Loop
| >>> | > | >>> Loop
| >>> | > | >>> Loop
| >>> | > | >>> Response.Write "GrandTotal: " & GrandTotal
| >>> | > | >>> %>
| >>> | > | >>>
| >>> | > | >>> I suspect 1 of your loops may be returning an EOF since your
| >>> logic
| >>> | > is
| >>> | > | >>> requiring all 3 recordsets to have 3 "identical" sets of
| >>> | > | >>> qualifying data in each loop (a null value or empty string in
| >>> any
| >>> | > | >>> recordset will also cause the loops to fail)
| >>> | > | >>>
| >>> | > | >>> PS
| >>> | > | >>> Plus your logic will result in unreliable results since there
| >>> is no
| >>> | > | >>> attempt to order or group the recordset results in any
| >>> | > | >>> associated way that is consistent or related to iScore,
| >>> eScore, or
| >>> | > | >>> aScore as a group
| >>> | > | >>> So you will be doing math on 3 random numbers (depending on
| >>> each
| >>> | > | >>> recordset order returned)
| >>> | > | >>> --
| >>> | > | >>>
| >>> | > | >>> _____________________________________________
| >>> | > | >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>> | > | >>> "Warning - Using the F1 Key will not break anything!" (-;
| >>> | > | >>> To find the best Newsgroup for FrontPage support see:
| >>> | > | >>>
| >>> | >
| >>> http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >>> | > | >>> _____________________________________________
| >>> | > | >>>
| >>> | > | >>>
| >>> | > | >>> | >>> | > | >>> | Thanks but I am still getting a type mismatch error.
| >>> | > message
| >>> | > | >>> | | >>> | > | >>> | > <%
| >>> | > | >>> | > Dim Total
| >>> | > | >>> | > Dim GrandTotal
| >>> | > | >>> | > GrandTotal = 0
| >>> | > | >>> | > Do While not aScrRst.EOF
| >>> | > | >>> | > Do While not eScrRst.EOF
| >>> | > | >>> | > Do While not iScrRst.EOF
| >>> | > | >>> | > Total = iScrRst("Score") + eScrRst("Score") *
| >>> aScrRst("Score")
| >>> | > | >>> | > GrandTotal = GrandTotal + Total
| >>> | > | >>> | >
| >>> | > | >>> | > Response.Write "Total: " & Total
| >>> | > | >>> | >
| >>> | > | >>> | > aScrRst.MoveNext
| >>> | > | >>> | > eScrRst.MoveNext
| >>> | > | >>> | > iScrRst.MoveNext
| >>> | > | >>> | >
| >>> | > | >>> | > Loop
| >>> | > | >>> | > Loop
| >>> | > | >>> | > Loop
| >>> | > | >>> | > Response.Write "GrandTotal: " & GrandTotal
| >>> | > | >>> | >
| >>> | > | >>> | > --
| >>> | > | >>> | > HTH,
| >>> | > | >>> | >
| >>> | > | >>> | > Kevin Spencer
| >>> | > | >>> | > Microsoft MVP
| >>> | > | >>> | > .Net Developer
| >>> | > | >>> | > A watched clock never boils.
| >>> | > | >>> | >
| >>> | > | >>> | >
| >>> | > | >>> | > | >>> | > | >>> | >> Can anyone point me in the direction of some guidance for
| >>> | > handling
| >>> | > | >>> | >> recordset values.
| >>> | > | >>> | >>
| >>> | > | >>> | >> I am trying to calculate a resultant value (total) of
| >>> adding 2
| >>> | > | >>> values and
| >>> | > | >>> | >> mulitplying by the third.
| >>> | > | >>> | >>
| >>> | > | >>> | >> Eventually I wanted to get total for the resultant value
| >>> (all
| >>> | > the
| >>> | > | >>> totals
| >>> | > | >>> | >> added together) for the whole recordset!
| >>> | > | >>> | >>
| >>> | > | >>> | >> <%
| >>> | > | >>> | >> Dim Total
| >>> | > | >>> | >> Do While not aScrRst.EOF
| >>> | > | >>> | >> Do While not eScrRst.EOF
| >>> | > | >>> | >> Do While not iScrRst.EOF
| >>> | > | >>> | >> Total = iScrRst("Score") + eScrRst("Score") *
| >>> aScrRst("Score")
| >>> | > | >>> | >>
| >>> | > | >>> | >> Response.Write "Total"
| >>> | > | >>> | >>
| >>> | > | >>> | >> aScrRst.MoveNext
| >>> | > | >>> | >> eScrRst.MoveNext
| >>> | > | >>> | >> iScrRst.MoveNext
| >>> | > | >>> | >>
| >>> | > | >>> | >>
| >>> | > | >>> | >> Loop
| >>> | > | >>> | >> Loop
| >>> | > | >>> | >> Loop
| >>> | > | >>> | >> %>
| >>> | > | >>> | >>
| >>> | > | >>> | >
| >>> | > | >>> | >
| >>> | > | >>> |
| >>> | > | >>> |
| >>> | > | >>>
| >>> | > | >>>
| >>> | > | >>
| >>> | > | >>
| >>> | > | >
| >>> | > | >
| >>> | > |
| >>> | > |
| >>> | >
| >>> | >
| >>> |
| >>> |
| >>>
| >>>
| >>
| >>
| >
| >
|
|
 
K

Kevin Spencer

You could certainly do a UNION. The result of a SELECT statement is a
cursor, or table, if you will. You can perform a UNION of all three queries
in one SELECT statement: I put the following together with the SQL Server
Northwind Database:

SELECT 'Products1' As TableName,
productName As Product,
unitsinstock As Units
FROM PRODUCTS P1
WHERE SupplierID = 8

UNION

SELECT 'Products2' As TableName,
productName As Product,
unitsinstock As Units
FROM PRODUCTS P2
WHERE SupplierID = 9

UNION
SELECT 'Products3' As TableName,
productName As Product,
unitsinstock As Units
FROM PRODUCTS P2
WHERE SupplierID = 9

ORDER BY TableName

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.



Stefan B Rusynko said:
Kevin

He is using 1 db/table w/ 3 rs calls on it

aSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'A' AND iauID= " &
UID
Set aScrRst = objConn.Execute (aSQLstr)
eSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'E' AND iauID= " &
UID
Set eScrRst = objConn.Execute (aSQLstr)
iSQLstr = "SELECT QID, Score FROM iaVals WHERE QLID= 'I' AND iauID= " &
UID
Set iScrRst = objConn.Execute (aSQLstr)

As I have pointed out to him in my other responses, there is no
correlation of his 3 "sets" being in sync or all having valid data
- I think he needs to go back to basics and get his DB table correct to
simplify the process
(probably by generating the data for all 3 scores in 1 record as aScore,
eScore, iScore rather than using the QLID as a qualifier,
or using QID, if it links the 3 related sets, as a grouping of the data)
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| What database are you using?
|
| --
| HTH,
|
| Kevin Spencer
| Microsoft MVP
| .Net Developer
| Complex things are made up of
| Lots of simple things.
|
| | > Thanks,
| >
| > Could you point me to a reference on join or union query which could
| > create the singel recordset.
| >
| > Rob
| >
| >
| > | >> Just a side note: This looks like it could be done with a single
| >> RecordSet, and a JOIN or UNION query.
| >>
| >> --
| >> HTH,
| >>
| >> Kevin Spencer
| >> Microsoft MVP
| >> .Net Developer
| >> Complex things are made up of
| >> Lots of simple things.
| >>
| >> | >>> Before you start, learn about your data being returned by your
nested
| >>> loops
| >>> Just paste this in a page (where you have opened your 3 connections)
| >>>
| >>> <table align="center" border="1" cellpadding="0" cellspacing="0"
| >>> id="table2">
| >>> <tr><th>Info</th><th>Score a</th><th>Score e</th><th>Score
i</th></tr>
| >>> <%
| >>> Do While not aScrRst.EOF
| >>> aTot = aScrRst("Score")
| >>> Do While not eScrRst.EOF
| >>> eTot = eScrRst("Score")
| >>> Do While not iScrRst.EOF
| >>> iTot = iScrRst("Score")
| >>> %>
| >>> <tr><td>Data / Type</td>
| >>> <td><%=aTot & " / " & Typename(aTot)%></td>
| >>> <td><%=eTot & " / " & Typename(eTot)%></td>
| >>> <td><%=iTot & " / " & Typename(iTot)%></td>
| >>> </tr>
| >>> <%
| >>> aScrRst.MoveNext
| >>> eScrRst.MoveNext
| >>> iScrRst.MoveNext
| >>> Loop
| >>> Loop
| >>> Loop
| >>> %>
| >>> </table>
| >>>
| >>> It also appears you need to start by correctly grouping the data for
the
| >>> 3 QLIDs (a,e,i) based on something in your table like QID
| >>> - consider creating 1 recordset and building an array
| >>>
| >>> PS
| >>> Also look at your math - you need to use () to set precedence of
| >>> calculations to get correct results
| >>> SubTotal = aTot + eTot * eTot
| >>> is not the same as
| >>> SubTotal = (aTot + eTot) * eTot
| >>> --
| >>>
| >>> _____________________________________________
| >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>> "Warning - Using the F1 Key will not break anything!" (-;
| >>> To find the best Newsgroup for FrontPage support see:
| >>>
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >>> _____________________________________________
| >>>
| >>>
| >>> | >>> |I did test it, however, I had the same value in each of the fields
so I
| >>> | couldn't really see what you were meaning.
| >>> |
| >>> | I now realise that the I am nutter lol. It is back to the drawing
| >>> board by
| >>> | the looks of things.
| >>> |
| >>> |
| >>> | Thanks for you help though.
| >>> |
| >>> | Rob
| >>> |
| >>> |
| >>> | | >>> | > Did you really test it w/i each of the loops using the VBscript
| >>> function:
| >>> | > TypeName("yourvarname")
| >>> | > - per my 1st post?
| >>> | >
| >>> | > PS
| >>> | > A zero in some of the fields will give you divide by 0 errors
unless
| >>> you
| >>> | > test for them 1st
| >>> | >
| >>> | > And again your whole logic appears to be flawed since there is
| >>> nothing
| >>> | > controlling the order (or grouping) of the numbers you are
| >>> | > doing math on - the results will be totally random
| >>> | > --
| >>> | >
| >>> | > _____________________________________________
| >>> | > SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>> | > "Warning - Using the F1 Key will not break anything!" (-;
| >>> | > To find the best Newsgroup for FrontPage support see:
| >>> | >
| >>>
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >>> | > _____________________________________________
| >>> | >
| >>> | >
| >>> | > | >>> | > | It is a decimal field in the database that is being pulled
into
| >>> the
| >>> | > | recordset.
| >>> | > |
| >>> | > | There are the same amount of records in each recordset.
| >>> | > |
| >>> | > | I have tested it without the calculations and all of the
recordset
| >>> | > values
| >>> | > | are returned and can be written, just can't do any
calculation.
| >>> | > |
| >>> | > | Rob
| >>> message
| >>> | > | | >>> | > | > What is the dat type of these fields?
| >>> | > | >
| >>> | > | > --
| >>> | > | > HTH,
| >>> | > | >
| >>> | > | > Kevin Spencer
| >>> | > | > Microsoft MVP
| >>> | > | > .Net Developer
| >>> | > | > Complex things are made up of
| >>> | > | > Lots of simple things.
| >>> | > | >
| >>> | > | > | >>> | > | >> Cheers for that Stefan,
| >>> | > | >>
| >>> | > | >> I had been working along the same principle - but I must be
| >>> getting
| >>> | > | >> something wrong. I have included my script !!!
| >>> | > | >> The db where the data is being drawn from requires a value
for
| >>> each
| >>> | > of
| >>> | > | >> the recordset fields (it is a , so there shouln't be a
return
| >>> of an
| >>> | > EOF,
| >>> | > | >> this page can't be ran until all the values are input.
| >>> (although I am
| >>> | > | >> hoping a value of 0 wont be returned as a NULL).
| >>> | > | >>
| >>> | > | >> I just keep getting a
| >>> | > | >>
| >>> | > | >> Type mismatch
| >>> | > | >> /ia/calc01.asp, line 175
| >>> | > | >>
| >>> | > | >> which seems to happen whenever I attempt any caluculations.
| >>> | > | >>
| >>> | > | >> <%
| >>> | > | >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal,
| >>> SubTotal,
| >>> | > | >> Total, aStrengthTotal
| >>> | > | >>
| >>> | > | >> aTot = 0
| >>> | > | >> eTot = 0
| >>> | > | >> iTot = 0
| >>> | > | >> pSubTot = 0
| >>> | > | >> aStrengthSubTot = 0
| >>> | > | >> pTotal = 0
| >>> | > | >> SubTotal = 0
| >>> | > | >> aStrengthTotal = 0
| >>> | > | >>
| >>> | > | >> 'Create Table Header
| >>> | > | >> Response.Write "<Table align=center border=1 cellpadding=0
| >>> | > | >> cellspacing=0>"
| >>> | > | >> Response.Write "<TR ALIGN=CENTER ><TD WIDTH=60><FONT
Face=Arial
| >>> | > | >> Size=3>Score</Font></TD><TD WIDTH=60><FONT Face=Arial
| >>> | > | >> Size=3>Score</TD><TD WIDTH=60 ><FONT Face=Arial
| >>> Size=3>Score</TD><TD
| >>> | > | >> WIDTH=120 ><FONT Face=Arial Size=3>Potential Value</TD<TD
| >>> WIDTH=120
| >>> | > | >> ><TD><FONT Face=Arial Size=3>Calculated Value</TD><TD
| >>> | > WIDTH=120><FONT
| >>> | > | >> Face=Arial Size=3>Asset Strength</TD></TR>"
| >>> | > | >>
| >>> | > | >> ' Start Processes
| >>> | > | >> 'Transfer recordset values to equation values
| >>> | > | >> Do While not aScrRst.EOF
| >>> | > | >> aTot = aScrRst("Score")
| >>> | > | >> Do While not eScrRst.EOF
| >>> | > | >> eTot = eScrRst("Score")
| >>> | > | >> Do While not iScrRst.EOF
| >>> | > | >> iTot = iScrRst("Score")
| >>> | > | >>
| >>> | > | >>
| >>> | > | >>
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> 'The Calculated Value = 1st and 2nd scores added then
| >>> multiplied by
| >>> | > 3rd
| >>> | > | >> (this calculation is where the error is returned)
| >>> | > | >> SubTotal = aTot + eTot * eTot
| >>> | > | >>
| >>> | > | >> 'The Potential Value Sub Total = 3rd score multiplied by 20
| >>> | > mulitplied by
| >>> | > | >> 20
| >>> | > | >> pSubTot = iTot * 20 * 20
| >>> | > | >>
| >>> | > | >> 'The Asset Strength Sub Total = Calculated Value devided by
the
| >>> | > Potential
| >>> | > | >> Value multiplied 100
| >>> | > | >> aStrengthSubTot = SubTotal / pSubTot * 100
| >>> | > | >>
| >>> | > | >> 'Total = The sum of all the SubTotals
| >>> | > | >> Total = Total + Subtotal
| >>> | > | >>
| >>> | > | >> 'Potential Total
| >>> | > | >> pTotal = pTotal + pSubTot
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> Response.Write "<Table align=center border=1 cellpadding=0
| >>> | > | >> cellspacing=0>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TR ALIGN=CENTER>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=60>"
| >>> | > | >> Response.Write aTot
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=60>"
| >>> | > | >> Response.Write eTot
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=60>"
| >>> | > | >> Response.Write iTot
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=120>"
| >>> | > | >> Response.Write pSubTot
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=120>"
| >>> | > | >> Response.Write SubTotal
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "<TD WIDTH=120>"
| >>> | > | >> Response.Write aStrength
| >>> | > | >> Response.Write "</TD>"
| >>> | > | >>
| >>> | > | >> Response.Write "</TR>"
| >>> | > | >>
| >>> | > | >> Response.Write "<Table>"
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> aScrRst.MoveNext
| >>> | > | >> eScrRst.MoveNext
| >>> | > | >> iScrRst.MoveNext
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> Loop
| >>> | > | >> Loop
| >>> | > | >> Loop
| >>> | > | >> Response.Write "Total=" & Total
| >>> | > | >> Response.Write "Potential Total= " & PTotal
| >>> | > | >> aStrengthTotal = Total /PTotal * 100
| >>> | > | >> Response.Write "Asset Strength= " & aStrengthTotal
| >>> | > | >>
| >>> | > | >>
| >>> | > | >> %>
| >>> | > | >> | >>> | > | >>> Validate your data types in each loop while testing using
say:
| >>> | > | >>>
| >>> | > | >>> <%
| >>> | > | >>> Do While not aScrRst.EOF
| >>> | > | >>> aScore = aScrRst("Score")
| >>> | > | >>> Response.write "aScrRst = " & TypeName("aScore")
&"<br>"
| >>> 'test
| >>> | > line
| >>> | > | >>> Do While not eScrRst.EOF
| >>> | > | >>> eScore = eScrRst("Score")
| >>> | > | >>> Response.write "eScrRst = " & TypeName("eScore")
&"<br>"
| >>> 'test
| >>> | > line
| >>> | > | >>> Do While not iScrRst.EOF
| >>> | > | >>> iScore = iScrRst("Score")
| >>> | > | >>> Response.write "iScrRst = " & TypeName("iScore")
&"<br>"
| >>> 'test
| >>> | > line
| >>> | > | >>> Total = iScore + eScore * aScore
| >>> | > | >>> Response.Write "Total: " & Total & "<br>" 'test line
| >>> | > | >>> GrandTotal = GrandTotal + Total
| >>> | > | >>> iScrRst.MoveNext
| >>> | > | >>> eScrRst.MoveNext
| >>> | > | >>> aScrRst.MoveNext
| >>> | > | >>> Loop
| >>> | > | >>> Loop
| >>> | > | >>> Loop
| >>> | > | >>> Response.Write "GrandTotal: " & GrandTotal
| >>> | > | >>> %>
| >>> | > | >>>
| >>> | > | >>> I suspect 1 of your loops may be returning an EOF since
your
| >>> logic
| >>> | > is
| >>> | > | >>> requiring all 3 recordsets to have 3 "identical" sets of
| >>> | > | >>> qualifying data in each loop (a null value or empty string
in
| >>> any
| >>> | > | >>> recordset will also cause the loops to fail)
| >>> | > | >>>
| >>> | > | >>> PS
| >>> | > | >>> Plus your logic will result in unreliable results since
there
| >>> is no
| >>> | > | >>> attempt to order or group the recordset results in any
| >>> | > | >>> associated way that is consistent or related to iScore,
| >>> eScore, or
| >>> | > | >>> aScore as a group
| >>> | > | >>> So you will be doing math on 3 random numbers (depending
on
| >>> each
| >>> | > | >>> recordset order returned)
| >>> | > | >>> --
| >>> | > | >>>
| >>> | > | >>> _____________________________________________
| >>> | > | >>> SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
| >>> | > | >>> "Warning - Using the F1 Key will not break anything!" (-;
| >>> | > | >>> To find the best Newsgroup for FrontPage support see:
| >>> | > | >>>
| >>> | >
| >>>
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
| >>> | > | >>> _____________________________________________
| >>> | > | >>>
| >>> | > | >>>
| >>> | > | >>> | >>> | > | >>> | Thanks but I am still getting a type mismatch error.
in
| >>> | > message
| >>> | > | >>> | | >>> | > | >>> | > <%
| >>> | > | >>> | > Dim Total
| >>> | > | >>> | > Dim GrandTotal
| >>> | > | >>> | > GrandTotal = 0
| >>> | > | >>> | > Do While not aScrRst.EOF
| >>> | > | >>> | > Do While not eScrRst.EOF
| >>> | > | >>> | > Do While not iScrRst.EOF
| >>> | > | >>> | > Total = iScrRst("Score") + eScrRst("Score") *
| >>> aScrRst("Score")
| >>> | > | >>> | > GrandTotal = GrandTotal + Total
| >>> | > | >>> | >
| >>> | > | >>> | > Response.Write "Total: " & Total
| >>> | > | >>> | >
| >>> | > | >>> | > aScrRst.MoveNext
| >>> | > | >>> | > eScrRst.MoveNext
| >>> | > | >>> | > iScrRst.MoveNext
| >>> | > | >>> | >
| >>> | > | >>> | > Loop
| >>> | > | >>> | > Loop
| >>> | > | >>> | > Loop
| >>> | > | >>> | > Response.Write "GrandTotal: " & GrandTotal
| >>> | > | >>> | >
| >>> | > | >>> | > --
| >>> | > | >>> | > HTH,
| >>> | > | >>> | >
| >>> | > | >>> | > Kevin Spencer
| >>> | > | >>> | > Microsoft MVP
| >>> | > | >>> | > .Net Developer
| >>> | > | >>> | > A watched clock never boils.
| >>> | > | >>> | >
| >>> | > | >>> | >
| >>> | > | >>> | > | >>> | > | >>> | >> Can anyone point me in the direction of some guidance
for
| >>> | > handling
| >>> | > | >>> | >> recordset values.
| >>> | > | >>> | >>
| >>> | > | >>> | >> I am trying to calculate a resultant value (total) of
| >>> adding 2
| >>> | > | >>> values and
| >>> | > | >>> | >> mulitplying by the third.
| >>> | > | >>> | >>
| >>> | > | >>> | >> Eventually I wanted to get total for the resultant
value
| >>> (all
| >>> | > the
| >>> | > | >>> totals
| >>> | > | >>> | >> added together) for the whole recordset!
| >>> | > | >>> | >>
| >>> | > | >>> | >> <%
| >>> | > | >>> | >> Dim Total
| >>> | > | >>> | >> Do While not aScrRst.EOF
| >>> | > | >>> | >> Do While not eScrRst.EOF
| >>> | > | >>> | >> Do While not iScrRst.EOF
| >>> | > | >>> | >> Total = iScrRst("Score") + eScrRst("Score") *
| >>> aScrRst("Score")
| >>> | > | >>> | >>
| >>> | > | >>> | >> Response.Write "Total"
| >>> | > | >>> | >>
| >>> | > | >>> | >> aScrRst.MoveNext
| >>> | > | >>> | >> eScrRst.MoveNext
| >>> | > | >>> | >> iScrRst.MoveNext
| >>> | > | >>> | >>
| >>> | > | >>> | >>
| >>> | > | >>> | >> Loop
| >>> | > | >>> | >> Loop
| >>> | > | >>> | >> Loop
| >>> | > | >>> | >> %>
| >>> | > | >>> | >>
| >>> | > | >>> | >
| >>> | > | >>> | >
| >>> | > | >>> |
| >>> | > | >>> |
| >>> | > | >>>
| >>> | > | >>>
| >>> | > | >>
| >>> | > | >>
| >>> | > | >
| >>> | > | >
| >>> | > |
| >>> | > |
| >>> | >
| >>> | >
| >>> |
| >>> |
| >>>
| >>>
| >>
| >>
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top