Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - adding up fields in asp
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

adding up fields in asp

 Post Reply Post Reply
Author
t4p67b96 View Drop Down
Newbie
Newbie


Joined: 10 May 2005
Location: United States
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote t4p67b96 Quote  Post ReplyReply Direct Link To This Post Topic: adding up fields in asp
    Posted: 10 May 2005 at 12:22pm
I have a 4th asp page that is suppose to add specified fields from 3 other forms. When I test the page it just adds them like a string and not totaling them.  Below is how I have it now. I open all 3 connections (rst, rst2, rst3) Fields are named the same in each database table.
 
accidents = rst("Accidents") + rst2("Accidents") + rst3("Accidents")
ogpriorityoh = rst("OG Priority OH") + rst2("OG Priority OH") + rst3("OG Priority OH")
 
Then somewhere in the table I call for the total using for example
<%=ogpriorityoh%>.  So in the other 3 forms if I enter 3, 4, 5, I get 345 not 12.
 
thanks
 
t4p67b96
Confused


Edited by t4p67b96 - 10 May 2005 at 12:22pm
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2005 at 12:51pm
Try
accidents = (Cint(rst("Accidents")) + Cint(rst2("Accidents")) + Cint(rst3("Accidents")))

Lead me not into temptation... I know the short cut, follow me.
Back to Top
t4p67b96 View Drop Down
Newbie
Newbie


Joined: 10 May 2005
Location: United States
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote t4p67b96 Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2005 at 2:03pm
Thank you.  That worked
 
 
 
Smile
t4p67b96
 
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 10 May 2005 at 3:07pm
Not that the Convert to Integer Number instruction (Cint) only works with numbers up to 32K.
If you expect higher numbers, use the Convert to Long Number instruction (Clng). Uses more resources to run than Cint.

Lead me not into temptation... I know the short cut, follow me.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.