adding values from option groups

S

Steve

when i try to add option group values together it will produce a number of
the 2 values put side by side. for example, if i had 2 option groups, and
option group 1's value = 3 and option group 2's value = 1 the outcome would
show as 31, and not 4. i can get the value to subtract, divide and multiply
but not plus.

Any help?

thank you!
 
A

Al Campagna

Steve,
I may have misunderstood your question. I thought you wanted to
concatenate the two values. I see now that you want the sum.
(use your own names)
= Opt1 + Opt2 ... should do it.
Describe your names and table definitions for these option boxes.
I'm assuming the two options are "option groups" with multiple possible
values in each group, and that you have numeric values assigned to each
option within the group.

I find that the fact that you say you can subtract, multiply, and
divide, but not add the 2 values, very strange...
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
B

Bob Quintal

Steve,
I may have misunderstood your question. I thought you wanted
to
concatenate the two values. I see now that you want the sum.
(use your own names)
= Opt1 + Opt2 ... should do it.
Describe your names and table definitions for these option
boxes. I'm assuming the two options are "option groups" with
multiple possible
values in each group, and that you have numeric values assigned to
each option within the group.

I find that the fact that you say you can subtract, multiply,
and
divide, but not add the 2 values, very strange...

Al and steve,

What you are seeing here is because the + operator in access has two
roles, one that adds numbers, the other that concatenates strings.

If Access misinterprets a number as a string, it will concatenate,
not add. The -, / and * operators are not dual purpose so do not
suffer the same confusion.

steve,
somewhere one of your opt values is being interpreted as a string.
Force the conversion to numbers using the val() or cint() functions,
like this: = cint(Opt1) + cint(Opt2)
 
A

Al Campagna

Bob Quintal said:
Al and steve,

What you are seeing here is because the + operator in access has two
roles, one that adds numbers, the other that concatenates strings.

If Access misinterprets a number as a string, it will concatenate,
not add. The -, / and * operators are not dual purpose so do not
suffer the same confusion.

steve,
somewhere one of your opt values is being interpreted as a string.
Force the conversion to numbers using the val() or cint() functions,
like this: = cint(Opt1) + cint(Opt2)


Thanks Bob. Odd that I've never had to use that function.
But... I may not have ever had cause to add option group values.

Also, I tested two option groups on a sample form, and
= [Opt1] + [Opt2]
gave me the correct sum. Hmmm...

Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
B

Bob Quintal

Thanks Bob. Odd that I've never had to use that function.

with a string, + concatenates the strings if neither is null. The
other concatenation operator, &, concatenates an empty string if one
of the values is null.
But... I may not have ever had cause to add option group values.

Also, I tested two option groups on a sample form, and
= [Opt1] + [Opt2]
gave me the correct sum. Hmmm...
The original poster, steve, has bound an option group to a string
field, defined one of the option values as "3" instead of 3, or has
passed the option groups' value to a string variable.
 
A

Al Campagna

Bob Quintal said:
Thanks Bob. Odd that I've never had to use that function.

with a string, + concatenates the strings if neither is null. The
other concatenation operator, &, concatenates an empty string if one
of the values is null.
But... I may not have ever had cause to add option group values.

Also, I tested two option groups on a sample form, and
= [Opt1] + [Opt2]
gave me the correct sum. Hmmm...
The original poster, steve, has bound an option group to a string
field, defined one of the option values as "3" instead of 3, or has
passed the option groups' value to a string variable.


Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in
your life."

That's what I figured... and asked him for the details on the option fields
in his table.
Going by the first post, he referred to...Good deal Bob... Thanks

Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 

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