Results 1 to 5 of 5

Thread: Adding values

  1. #1
    Join Date
    Apr 2004
    Posts
    182

    Unanswered: Adding values

    I am tryin to add 3 values together
    Me.txtHours = ((Me.txtSetHr.value) + (Me.txtRunHr.value) + (Me.txtDownHr.value))
    but I am getting 123 instead of 6. it is concatenating them rather than adding them.

  2. #2
    Join Date
    Aug 2004
    Posts
    40
    Try using

    Me.txtHours = (CSng(Me.txtSetHr.value) + CSng(Me.txtRunHr.value) + CSng(Me.txtDownHr.value))

    Howard

  3. #3
    Join Date
    Apr 2004
    Posts
    182
    Lovely Howard
    What does the CSNG mean ?

  4. #4
    Join Date
    Aug 2004
    Posts
    40
    Access has a whole lot of conversion functions this being one of them

    CSng = Convert to single data type

    To see them all open the vb editor and it's help search for cval or csng

    Basically what was happening was the values were text so it was the same as entering

    Me.txtSetHr.value & Me.txtRunHr.value & Me.txtDownHr.value

    a string

    Converting them to numbers of some sort allowed VBA to evaluate them as numbers etc.

    HTH

    Howard

  5. #5
    Join Date
    Apr 2004
    Posts
    182
    Super thanks Howard.

Posting Permissions

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