Forums

This topic is locked

Fields addition

Posted 22 Apr 2003 18:49:49
1
has voted
22 Apr 2003 18:49:49 Alfa Siete posted:
i am trying to add four values in four fields then dividing the results beetwen 4, so i declared a local variable

<%=averrev%>
then in the total fiels of the repeated region i tried:

<% averrev = (Recordset1.Fields.Item("1RA".Value) + (Recordset1.Fields.Item("2DA".Value) + (Recordset1.Fields.Item("3RA".Value) + (Recordset1.Fields.Item("4TA".Value)/4%>

the field values in the first record are: 10, 0, 0 and 0

when viewing the page i see blank total, but in the next record i see 1000

so is not adding but reading the text and puting togheter the fields numbers.
i need to add the numbers then divide by 4, the correct total result should be (10+0+0+0)/4= 2.5

what am I doing wrong

Everybody should belive in something... I belive i'm having another beer

Replies

Replied 23 Apr 2003 01:20:42
23 Apr 2003 01:20:42 kunta Chaman replied:
You are reading what you wrote in your DB, double check that fiels in your DB are numeric, that should do it
Replied 23 Apr 2003 02:02:38
23 Apr 2003 02:02:38 Alfa Siete replied:
¡¡It works!!
field were text, once i changed to numeric everithing showed as it was suposed to

Thanks Chaman
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
You are reading what you wrote in your DB, double check that fiels in your DB are numeric, that should do it
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Everybody should belive in something... I belive i'm having another beer

Reply to this topic