Re: One more ! Calculating Recordset Values



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" <anon@xxxxxxxxxxx> wrote in message
news:T00cf.4397$8R6.1482@xxxxxxxxxxxxxxxxxxxxxxx
> 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" <sbr_enjoy@xxxxxxxxxxx> wrote in message
> news:usz56GF5FHA.2396@xxxxxxxxxxxxxxxxxxxxxxx
>> 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
>> _____________________________________________
>>
>>
>> "RobA" <anon@xxxxxxxxxxx> wrote in message
>> news:okZbf.15943$Gy5.15608@xxxxxxxxxxxxxxxxxxxxxxx
>> | Thanks but I am still getting a type mismatch error.
>> | "Kevin Spencer" <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> | news:OQe%23HzB5FHA.3876@xxxxxxxxxxxxxxxxxxxxxxx
>> | > <%
>> | > 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.
>> | >
>> | >
>> | > "RobA" <anon@xxxxxxxxxxx> wrote in message
>> | > news:v0Sbf.8228$lJ.3691@xxxxxxxxxxxxxxxxxxxxxxx
>> | >> 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
>> | >> %>
>> | >>
>> | >
>> | >
>> |
>> |
>>
>>
>
>


.



Relevant Pages

  • Re: DAO MUCH faster than ADO in this test
    ... DAO is well-known to be faster than ADO. ... Of course the DAO loop ran faster than the SQL loop; ... advantage of a table-type recordset, which only works on local tables. ... Dim starttime As Single, finishtime As Single ...
    (microsoft.public.access.modulesdaovba)
  • Re: One more ! Calculating Recordset Values
    ... | There are the same amount of records in each recordset. ... |>> Loop ...
    (microsoft.public.frontpage.programming)
  • Re: One more ! Calculating Recordset Values
    ... 'Transfer recordset values to equation values ... 'Total = The sum of all the SubTotals ... Loop ...
    (microsoft.public.frontpage.programming)
  • Re: Do While Loop nested in another While causes error
    ... still doesn't explain why a nested DO loop would cause problems. ... Until you sort out the contents of the recordset, ... idHolder = rsGuestbook ... display that new ID. ...
    (microsoft.public.inetserver.asp.db)
  • Re: One more ! Calculating Recordset Values
    ... Well I am almost there lol, got the recordset to work properly returning all ... the values in the one "loop" so to speak and I can see them being returned ... >> Dim aTot, eTot, iTot, pSubTot, aStrengthSubTot, PTotal, SubTotal, ... >>> totals ...
    (microsoft.public.frontpage.programming)