Unbound form/unbound control calculation

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

Guest

My form is unbound as are two controls. User inputs data into each control.

I wish to calculate the sum of the two and using VBA test for value, sucha as:

If (me.MyCntrl1 + me.MyCntrl2) > 2 then
perform task
End If

I created a third control with the source "=([MyCntrl1]+[MyCntrl2])". I did
this to check results and, frankly I don't understand. I got the following:

Desired: 1 + 3 = 4
Got: 1 + 3 = 13

Is there something I missed or a workaround?

In hopes of help...
 
My form is unbound as are two controls. User inputs data into each control.

I wish to calculate the sum of the two and using VBA test for value, sucha as:

If (me.MyCntrl1 + me.MyCntrl2) > 2 then
perform task
End If

I created a third control with the source "=([MyCntrl1]+[MyCntrl2])". I did
this to check results and, frankly I don't understand. I got the following:

Desired: 1 + 3 = 4
Got: 1 + 3 = 13

Is there something I missed or a workaround?

In hopes of help...

Access is concatenating the values as though they were text value,
instead of adding them together as number values.
You might try setting the each control's Format property to General
Number (or any other number format) to force it's being treated as
numeric. If all else fails, try
=Val(MyCntrl1) + Val(MyCntrl2)
 
Thanks fredg, the General Number format did the trick.
--
Thanks for your help,
Chris


fredg said:
My form is unbound as are two controls. User inputs data into each control.

I wish to calculate the sum of the two and using VBA test for value, sucha as:

If (me.MyCntrl1 + me.MyCntrl2) > 2 then
perform task
End If

I created a third control with the source "=([MyCntrl1]+[MyCntrl2])". I did
this to check results and, frankly I don't understand. I got the following:

Desired: 1 + 3 = 4
Got: 1 + 3 = 13

Is there something I missed or a workaround?

In hopes of help...

Access is concatenating the values as though they were text value,
instead of adding them together as number values.
You might try setting the each control's Format property to General
Number (or any other number format) to force it's being treated as
numeric. If all else fails, try
=Val(MyCntrl1) + Val(MyCntrl2)
 
Back
Top