Connecting Tech Pros Worldwide Help | Site Map

Sum of 2 texboxes = ?

  #1  
Old July 12th, 2007, 06:35 PM
2D Rick
Guest
 
Posts: n/a
Access2003 on XP2
On an un-bound "Single Form" containing 3 un-bound textboxes, I want
to add the value in box 1 and box 2 and show the sum in box 3.

Mutiply works: Me.Text4 = [Text1].[Value] * [Text2].[Value]

Divide works: Me.Text4 = [Text1].[Value] / [Text2].[Value]

Add does not work: Me.Text4 = [Text1].[Value] + [Text2].[Value]

Sum does not work: Me.Text4 = Sum([Text1].[Value] + [Text2].[Value])

Why is something this simple whipping me?

Rick

  #2  
Old July 12th, 2007, 07:05 PM
fredg
Guest
 
Posts: n/a

re: Sum of 2 texboxes = ?


On Thu, 12 Jul 2007 10:29:28 -0700, 2D Rick wrote:
Quote:
Access2003 on XP2
On an un-bound "Single Form" containing 3 un-bound textboxes, I want
to add the value in box 1 and box 2 and show the sum in box 3.
>
Mutiply works: Me.Text4 = [Text1].[Value] * [Text2].[Value]
>
Divide works: Me.Text4 = [Text1].[Value] / [Text2].[Value]
>
Add does not work: Me.Text4 = [Text1].[Value] + [Text2].[Value]
>
Sum does not work: Me.Text4 = Sum([Text1].[Value] + [Text2].[Value])
>
Why is something this simple whipping me?
>
Rick
Word's like "doesn't work" do not tell us much.
You get nothing shown in the text box?
You get #Error or #Name in the text box?
You get an incorrect result?
You get a concatenated result?
What?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old July 12th, 2007, 07:05 PM
Max Vit
Guest
 
Posts: n/a

re: Sum of 2 texboxes = ?


It should work but I must confess that I am not a fan of the Me
syntax.

Have you tried to perform this using:

Forms![Form Name]!Text4 = Forms![Form Name]!Text1 + Forms![Form Name]!
Text2

Another possibility is that when you perform the Multiply and Divide
operations you are triggering a refresh function for Text4 but then
you may have forgotten to do the same when you are testing the Add or
Sum operations - hence not showing the result in Text4

HTH - Max


  #4  
Old July 12th, 2007, 07:15 PM
2D Rick
Guest
 
Posts: n/a

re: Sum of 2 texboxes = ?


On Jul 12, 11:00 am, fredg <fgutk...@example.invalidwrote:
Quote:
On Thu, 12 Jul 2007 10:29:28 -0700, 2D Rick wrote:
Quote:
Access2003 on XP2
On an un-bound "Single Form" containing 3 un-bound textboxes, I want
to add the value in box 1 and box 2 and show the sum in box 3.
>
Quote:
Mutiply works: Me.Text4 = [Text1].[Value] * [Text2].[Value]
>
Quote:
Divide works: Me.Text4 = [Text1].[Value] / [Text2].[Value]
>
Quote:
Add does not work: Me.Text4 = [Text1].[Value] + [Text2].[Value]
>
Quote:
Sum does not work: Me.Text4 = Sum([Text1].[Value] + [Text2].[Value])
>
Quote:
Why is something this simple whipping me?
>
Quote:
Rick
>
Word's like "doesn't work" do not tell us much.
You get nothing shown in the text box?
You get #Error or #Name in the text box?
You get an incorrect result?
You get a concatenated result?
What?
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail- Hide quoted text -
>
- Show quoted text -
Sorry Fredg, I was getting the #Error in the textbox but after pokin
at it some more I got it to work.

I wrapped it with the VAL function.
Me.Text4 = Val([Text1].[Value]) + Val([Text2].[Value])

Not sure if this is the right cure but it works.

Also, thanks again for all the great solutions you have given me in
the past.
Your always dead on.

Rick


  #5  
Old July 12th, 2007, 08:35 PM
fredg
Guest
 
Posts: n/a

re: Sum of 2 texboxes = ?


On Thu, 12 Jul 2007 11:13:30 -0700, 2D Rick wrote:
Quote:
On Jul 12, 11:00 am, fredg <fgutk...@example.invalidwrote:
Quote:
>On Thu, 12 Jul 2007 10:29:28 -0700, 2D Rick wrote:
Quote:
>>Access2003 on XP2
>>On an un-bound "Single Form" containing 3 un-bound textboxes, I want
>>to add the value in box 1 and box 2 and show the sum in box 3.
>>
Quote:
>>Mutiply works: Me.Text4 = [Text1].[Value] * [Text2].[Value]
>>
Quote:
>>Divide works: Me.Text4 = [Text1].[Value] / [Text2].[Value]
>>
Quote:
>>Add does not work: Me.Text4 = [Text1].[Value] + [Text2].[Value]
>>
Quote:
>>Sum does not work: Me.Text4 = Sum([Text1].[Value] + [Text2].[Value])
>>
Quote:
>>Why is something this simple whipping me?
>>
Quote:
>>Rick
>>
>Word's like "doesn't work" do not tell us much.
>You get nothing shown in the text box?
>You get #Error or #Name in the text box?
>You get an incorrect result?
>You get a concatenated result?
>What?
>--
>Fred
>Please respond only to this newsgroup.
>I do not reply to personal e-mail- Hide quoted text -
>>
>- Show quoted text -
>
Sorry Fredg, I was getting the #Error in the textbox but after pokin
at it some more I got it to work.
>
I wrapped it with the VAL function.
Me.Text4 = Val([Text1].[Value]) + Val([Text2].[Value])
>
Not sure if this is the right cure but it works.
>
Also, thanks again for all the great solutions you have given me in
the past.
Your always dead on.
>
Rick
If you are doing this directly in the control source of an unbound
control, you cannot use the Me keyword. Me is a VBA word and therefore
unrecognized by Access.
Either
=[Text1 + [Text2]
or better ....
=Nz([Text1],0) + Nz([Text2],0)

Look up the Nz function in VBA help.

Note also that since Value is the default property yo do not need to
explicitly write it.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #6  
Old July 12th, 2007, 09:15 PM
Bob Quintal
Guest
 
Posts: n/a

re: Sum of 2 texboxes = ?


Max Vit <mvit@safe-mail.netwrote in
news:1184263490.778802.145600@m3g2000hsh.googlegro ups.com:
Quote:
It should work but I must confess that I am not a fan of the
Me syntax.
>
Have you tried to perform this using:
>
Forms![Form Name]!Text4 = Forms![Form Name]!Text1 +
Forms![Form Name]! Text2
>
Another possibility is that when you perform the Multiply and
Divide operations you are triggering a refresh function for
Text4 but then you may have forgotten to do the same when you
are testing the Add or Sum operations - hence not showing the
result in Text4
>
HTH - Max
>
The problem is the overloading of the addition symbol as a
concatenation operator. Access is confused by which to use, so it
will concatenate unless explicitly forced to perform the
mathermatical operation

Sum() unfortunately is a SQL function, not VB. that's why it
doesn't work.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating textboxes dynamically ashwinigopi answers 4 July 30th, 2008 10:18 PM
How to write the simplest Windows program? Knut Olsen-Solberg answers 6 February 20th, 2007 11:25 AM