Re: adding values from option groups

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"Al Campagna" <newsgroups@xxxxxxxxxxx> wrote in
news:uSBSwMdJJHA.1304@xxxxxxxxxxxxxxxxxxxx:


"Bob Quintal" <rquintal@xxxxxxxxxxxxx> wrote in message
news:Xns9B2CCAFF6B654BQuintal@xxxxxxxxxxxxxxx
"Al Campagna" <newsgroups@xxxxxxxxxxx> wrote in
news:eei4lwYJJHA.1308@xxxxxxxxxxxxxxxxxxxx:

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)


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






--
Bob Quintal

PA is y I've altered my email address.
** Posted from http://www.teranews.com **
.



Relevant Pages

  • Re: adding values from option groups
    ... If Access misinterprets a number as a string, ... + concatenates the strings if neither is null. ... Also, I tested two option groups on a sample form, and ... Microsoft Access MVP ...
    (microsoft.public.access.forms)
  • Re: adding values from option groups
    ... I see now that you want the sum. ... If Access misinterprets a number as a string, it will concatenate, ... Also, I tested two option groups on a sample form, and ...
    (microsoft.public.access.forms)
  • Re: Modify records
    ... Dim strValue as String ... >,with a combobox, which ... > with the option related on the selected patient. ... does this works also with option groups or only ...
    (microsoft.public.access.forms)
  • Re: query between two dates and times
    ... the & it concatenates the two together and makes them a string. ... can be forced back to a dateTime by using the CDate function, ...
    (microsoft.public.access.queries)
  • Re: Problem with MS Access + Operator in Query
    ... E.g 4 fields in the query, values 2,4,6,8. ... , then it concatenates. ... If the string can be converted to a number, ... This email account is my spam trap so I ...
    (microsoft.public.access.queries)