473,387 Members | 1,303 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

calculation

77
i have to fields in a form which are both currency field types..

what i need is the sum of both fields to be displayed automatically in a third field..

can anyone help
Mar 21 '07 #1
4 1110
ADezii
8,834 Expert 8TB
i have to fields in a form which are both currency field types..

what i need is the sum of both fields to be displayed automatically in a third field..

can anyone help
Assumptions:
__1. Field #1: txtCurrency1
__2. Field #2: txtCurrency2
__3. Field #3: txtCurrency3
In the AfterUpdate() Event of both txtCurrency1 and txtCurrency2, place the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtCurrency1_AfterUpdate()
  2. If Not IsNull(Me![txtCurrency1]) And Not IsNull(Me![txtCurrency2]) Then
  3.   Me![txtCurrency3] = Format$(Me![txtCurrency1] + Me![txtCurrency2], "Currency")
  4. Else
  5.   'Remove any results from a previous calculation if either Field is blank
  6.   Me![txtCurrency3] = Null
  7. End If
  8. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtCurrency2_AfterUpdate()
  2. If Not IsNull(Me![txtCurrency1]) And Not IsNull(Me![txtCurrency2]) Then
  3.   Me![txtCurrency3] = Format$(Me![txtCurrency1] + Me![txtCurrency2], "Currency")
  4. Else
  5.   'Remove any results from a previous calculation if either Field is blank
  6.   Me![txtCurrency3] = Null
  7. End If
  8. End Sub
Mar 21 '07 #2
Mubs
77
Assumptions:
__1. Field #1: txtCurrency1
__2. Field #2: txtCurrency2
__3. Field #3: txtCurrency3
In the AfterUpdate() Event of both txtCurrency1 and txtCurrency2, place the following code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtCurrency1_AfterUpdate()
  2. If Not IsNull(Me![txtCurrency1]) And Not IsNull(Me![txtCurrency2]) Then
  3.   Me![txtCurrency3] = Format$(Me![txtCurrency1] + Me![txtCurrency2], "Currency")
  4. Else
  5.   'Remove any results from a previous calculation if either Field is blank
  6.   Me![txtCurrency3] = Null
  7. End If
  8. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtCurrency2_AfterUpdate()
  2. If Not IsNull(Me![txtCurrency1]) And Not IsNull(Me![txtCurrency2]) Then
  3.   Me![txtCurrency3] = Format$(Me![txtCurrency1] + Me![txtCurrency2], "Currency")
  4. Else
  5.   'Remove any results from a previous calculation if either Field is blank
  6.   Me![txtCurrency3] = Null
  7. End If
  8. End Sub
i get the error msg sayin you cant assign a value to this object....
Mar 21 '07 #3
missinglinq
3,532 Expert 2GB
Why not simply:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtCurrency1_BeforeUpdate(Cancel As Integer)
  2.    Me![txtCurrency3] = Format$(Nz(Me![txtCurrency1]) + Nz(Me![txtCurrency2]), "Currency")
  3.  End Sub
  4.  
  5.  Private Sub txtCurrency2_BeforeUpdate(Cancel As Integer)
  6.    Me![txtCurrency3] = Format$(Nz(Me![txtCurrency1]) + Nz(Me![txtCurrency2]), "Currency")
  7.  End Sub
  8.  
Mar 21 '07 #4
Mubs
77
Why not simply:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtCurrency1_BeforeUpdate(Cancel As Integer)
  2.    Me![txtCurrency3] = Format$(Nz(Me![txtCurrency1]) + Nz(Me![txtCurrency2]), "Currency")
  3.  End Sub
  4.  
  5.  Private Sub txtCurrency2_BeforeUpdate(Cancel As Integer)
  6.    Me![txtCurrency3] = Format$(Nz(Me![txtCurrency1]) + Nz(Me![txtCurrency2]), "Currency")
  7.  End Sub
  8.  

i get the following msg "the value u entered isnt valid for this field".. on the following line of code...


Private Sub Combo86_AfterUpdate()
Me![totalcost] = Format$(Nz(Me![Combo86]) + Nz(Me![Combo84]), "Currency")
End Sub
Mar 22 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
1
by: cdelaney | last post by:
I have a form that I created a calculation on using 2003. The calculation works exactly like I want it to but ONLY on the first and last record. The calculation does not work/exist on records in...
0
by: gavo | last post by:
Hi. using A2K; i have a form containing a continous subform. The question is, how can i call a calculation for one of the fields in the continous subform from the main form. At the moment i...
4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
3
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
5
by: =?Utf-8?B?amVsbGU3OQ==?= | last post by:
Hi, I want to use a difficult Excelsheet as source for my calculation in a ASP.NET (C#) page. I have 5 input fields on my ASP.NET page and when I press the submit button I want to put these...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.