problem in mathematical operation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi..please help..i have a problem using command button in displaying answer
in basic math operation..i have the text1 and text2 and wishing to display
the answer in text3 by clicking a command button..i do coding in command
button like this(Me.Text3 = Me.Text1 + Me.Text2) and the result is still
combining the two numbers in textbox 1 and 2..please help..I use a Microsoft
access 2003 in my programming..please help, im new in programming
world..thank you very much,specially to sir Daniel P..
 
Renato Bacani said:
hi..please help..i have a problem using command button in displaying
answer
in basic math operation..i have the text1 and text2 and wishing to display
the answer in text3 by clicking a command button..i do coding in command
button like this(Me.Text3 = Me.Text1 + Me.Text2) and the result is still
combining the two numbers in textbox 1 and 2..please help..I use a
Microsoft
access 2003 in my programming..please help, im new in programming
world..thank you very much,specially to sir Daniel P..


Try Me.Text3 = Val(Me.Text1) + Val(Me.Text2)

See Val Function in the help files for more information.
 
Renato

Make sure your data types are numbers - in your question it would appear you
are adding text fields together rather than numbers. Check the Data Type in
your table or the format in your form.

Hope this helps.


Andy
 
Use the after update event of each of the first 2 textboxes, like:

Private Sub Text1_AfterUpdate()
If Len(Me.Text2 & vbNullString) > 0 Then
Me.Text3 = (Me.Text1 + Me.Text2)
Else
MsgBox "Please Enter a value in Text2", vbOKOnly
Me.Text2.SetFocus
End If
End Sub

Do the same thing for Text2, changing the values to Text1 in the Len
function and Message box.:

Private Sub Text2_AfterUpdate()
If Len(Me.Text1 & vbNullString) > 0 Then
Me.Text3 = (Me.Text1 + Me.Text2)
Else
MsgBox "Please Enter a value in Text1", vbOKOnly
Me.Text1.SetFocus
End If
End Sub
 
hi..please help..i have a problem using command button in displaying answer
in basic math operation..i have the text1 and text2 and wishing to display
the answer in text3 by clicking a command button..i do coding in command
button like this(Me.Text3 = Me.Text1 + Me.Text2) and the result is still
combining the two numbers in textbox 1 and 2..please help..I use a Microsoft
access 2003 in my programming..please help, im new in programming
world..thank you very much,specially to sir Daniel P..

Since your text boxes are named Text1 etc. I wonder if you have the
format of the text boxes set to text. If so, a math function will not
run correctly. To check this you need to open your Table in Design
View and make sure that the field's Data Type is set to Number. Then
make sure that Field Size is set to Long Integer.

After that, you need to open your form in Design View open the
properties sheet for each of your text boxes and set them to General
Number. See if that helps

Hunter57
http://churchmanagementsoftware.googlepages.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top