Unbound form/unbound control calculation

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...
 
F

fredg

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)
 
G

Guest

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)
 

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

Top