calculated value

  • Thread starter Thread starter Bob Brannon
  • Start date Start date
B

Bob Brannon

Hello,

I am using Access 2000 SP3 on XP Home SP2.

Can anyone tell me if there is a way, in a form used to enter data for a
table, to have a field sum the values I enter in it? For example, say my
form has a field named TOTAL, which is also in my table. When entering data
for a new record in the form I want to type 1+2+3 and have that field on
that form sum the total as 6.

Is this possible without a lot of difficulty?
 
Can anyone tell me if there is a way, in a form used to enter data for a
table, to have a field sum the values I enter in it? For example, say my
form has a field named TOTAL, which is also in my table. When entering data
for a new record in the form I want to type 1+2+3 and have that field on
that form sum the total as 6.

Not easily. You'll need to use an unbound control and some VBA code to
do the calculation. For instance, you might have two textboxes on the
form - one bound to the field in which you want to store the sum (I'll
call it txtVal), and the other unbound (blank Control Source), let's
say txtExpr.

In the AfterUpdate event of txtExpr put code like:

Private Sub txtExpr_AfterUpdate()
Me!txtVal = Eval(Me![txtExpr])
End Sub

If the user enters something which cannot be evaluated as a normal
expression ( e.g. "Almost 45") this will give an error message and (I
believe) a NULL result.


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Good evening

If you wish I can send you a copy of popup calculator that will allow you to do
what you're asking.

Simply send me an email to confirm

Best regards

Maurice St-Cyr
 
In the last textbox you enter a value , go to the
properties of that textbox and in the codebuilder of the
after_update event type

Total (fieldname for your total) = [field1]+[field2]+
[field3] etc
-----Original Message-----
Can anyone tell me if there is a way, in a form used to enter data for a
table, to have a field sum the values I enter in it? For example, say my
form has a field named TOTAL, which is also in my table. When entering data
for a new record in the form I want to type 1+2+3 and have that field on
that form sum the total as 6.

Not easily. You'll need to use an unbound control and some VBA code to
do the calculation. For instance, you might have two textboxes on the
form - one bound to the field in which you want to store the sum (I'll
call it txtVal), and the other unbound (blank Control Source), let's
say txtExpr.

In the AfterUpdate event of txtExpr put code like:

Private Sub txtExpr_AfterUpdate()
Me!txtVal = Eval(Me![txtExpr])
End Sub

If the user enters something which cannot be evaluated as a normal
expression ( e.g. "Almost 45") this will give an error message and (I
believe) a NULL result.


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
.
 
Hello,

Forgive me but I do not know how to use this calculator. I can use it in
the sample database but how do I get it into some of the databases in which
I need to use it?

--
Regards,
Bob Brannon


Good evening

If you wish I can send you a copy of popup calculator that will allow you to
do
what you're asking.

Simply send me an email to confirm

Best regards

Maurice St-Cyr
 
Hello again Maurice,

I was wondering if there might be a way to get a memory + and memory recall
button in that calculator?


--
Regards,
Bob Brannon


Good evening

If you wish I can send you a copy of popup calculator that will allow you to
do
what you're asking.

Simply send me an email to confirm

Best regards

Maurice St-Cyr
 
I was just trying to do a calculator project for class ~ trying to write a
calculator in VB in Access and i'm so locked in confusion. Perhaps is there
anyone with an idea to help?
 
Back
Top