Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2006
    Posts
    33
    Provided Answers: 1

    Red face Unanswered: Error when using unbound textbox to show sum of other unbound textboxes

    hi fellows

    i have a problem when adding two textbox values to show on a form within an unbound textbox
    instead of the sum i get the concatenated value this happens in a query too!
    eg text1=2
    text2 = 12
    controlsource of text3 is "=[text1]+[text2]"

    now the answer should be 2+12 or 14
    i get 212

    &@#@@@$%@#$@!!

    im going nuts!


    help

  2. #2
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    try something like:
    =cdbl([text1])+cdbl([text2])

    use cint() if you are using integers.
    hth
    chris

  3. #3
    Join Date
    Mar 2006
    Posts
    33
    Provided Answers: 1
    tanks a ton
    its aslo working if i change the formats in the textboxes!
    ill use the cint in the queries
    thanks alot again

  4. #4
    Join Date
    Mar 2006
    Posts
    33
    Provided Answers: 1
    another thing had to use the nz function to weed out the nulls!
    =CInt(nz([PBSN1],0))+CInt(nz([PBSN2],0))+CInt(nz([PBSN3],0))+CInt(nz([PBSN4],0))+CInt(nz([PBSN5],0))+CInt(nz([PBSN6],0))
    thats the one i have working PBSN(5) these are the textboxes
    bye

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    If the fields in question can ALWAYS be converted to numeric data types (PBSNS & PBSN6), then why aren't you storing them as numeric data types to begin with?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    ...can of worms Teddy!
    how about
    nz(CInt(nz([PBSN3],0)),0) +

    or
    iif(isnumeric(nz(PBSN3,0)), cint(nz(PBSN3,0), 0)) +

    izy
    currently using SS 2008R2

  7. #7
    Join Date
    Mar 2006
    Posts
    33
    Provided Answers: 1
    izyrider!
    you are rt i need to check for the null twice, but i think ill use the input mask or the data validation to restrict only numericals
    problem earlier was if all values were integers even then the result was concatenated.
    cint has solved that, additionally is it ok if i put a default as 0, so its never null???

    yeah teddy i am collecting the data on a form to be used in a query to manipulate the value i need for the actual field which will be a bound control on the form but hidden.

    this is my second day here on this forum why havent i been here earlier!!!!? to imagine the hours i spent figuring out problems and reading the exhaustive help, thanks all you guys.......Many Many Thanks.
    Last edited by abhichoudhary; 03-13-06 at 15:13.

  8. #8
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    default = 0 does not prevent the user from deleting the zero
    play safe(safe())

    izy


    LATER: but your input mask idea should fix it (don't use them myself, so not 100% certain)
    Last edited by izyrider; 03-13-06 at 15:20.
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •