• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 550
  • Last Modified:

Add Two Numbers

Hi,

I have three fields. when i enter value in first field and in the second field i should get a sum of those two numbers

when i tried i am not getting the same
Renewal.mdb
0
pg1533
Asked:
pg1533
  • 3
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
place this in the control source of the total control
=nz(int([text6]),0) + nz(int([text8]),0)
0
 
HainKurtSr. System AnalystCommented:
use this

Private Sub Text8_AfterUpdate()
    [total].Value = CInt(Nz([Text6].Value, "0")) + CInt(Nz([Text8].Value, "0"))
End Sub

Private Sub Text6_AfterUpdate()
    [total].Value = CInt(Nz([Text6].Value, "0")) + CInt(Nz([Text8].Value, "0"))
End Sub
0
 
JezWaltersCommented:
Bear in mind with HainKurt's solution that you'll get a 'Type mismtach' run-time error if either 'Number 1' or 'Number 2' are not numeric.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JezWaltersCommented:
And you'll get a 'Number 3' value of '#Error' if either 'Number 1' or 'Number 2' are not numeric with capricorn1's solution.
0
 
Rey Obrero (Capricorn1)Commented:
off course, you have to check for the entry in the textbox.. but that is another topic.



JezWalters,

did you see this
<i should get a sum of those two numbers>
0
 
JezWaltersCommented:
Both solutions also assume that your fields are integers too - is this actually the case?
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now