Results 1 to 2 of 2
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    Addition statement behaves like a string concatenation - important text box lesson of the day

    Two screenshots below, the first shows the intended addition which resulted in "2 + 3 = 23" while the second shows "32 + 48 = 80", yet other than the data-types the syntax is identical. At entry to sub "UpTheGrands, text boxes: tbNewAdj = 2; tbReNewAdj = 3; tbNewAdjAmt = 32; tbReNewAdjAmt = 48.



    Click image for larger version. 

Name:	000.jpg 
Views:	9 
Size:	82.0 KB 
ID:	24700

    Click image for larger version. 

Name:	001.jpg 
Views:	9 
Size:	83.0 KB 
ID:	24701

    It turns out that unless, in this case, the text box format property is explicitly set to General Number that the data type is treated like "String" and the effects of using the "+" is like having used "&" to concatenate the strings.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I know you've sorted it, but another alternative is using a conversion function, like:

    Me.Textbox1 = CCur(Me.Textbox2) + intAdj

    You may also need the Nz() function, as the conversion functions will barf on a Null.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 05-29-2015, 10:21 AM
  2. Replies: 7
    Last Post: 03-16-2014, 08:35 PM
  3. Replies: 7
    Last Post: 11-15-2013, 10:28 AM
  4. Text Color for Urgent or Important Items
    By John B in forum Access
    Replies: 1
    Last Post: 07-02-2012, 03:10 PM
  5. Concatenation of Text and Number
    By diane802 in forum Reports
    Replies: 67
    Last Post: 01-26-2010, 03:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums