Results 1 to 5 of 5
  1. #1
    Roncc is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    85

    Question Using addition in a control source

    I have a set of text boxes on a form whose contents can either be null or "adult". These textboxes are [Text167], [Test169], [Text170], etc. (for a total of 10 TextBoxes).

    I have a second set of Textboxes whose control source formulas are

    =IIf(([text167])="adult",1,"0"), =IIf(([text169])="adult",1,"0"), =IIf(([text170])="adult",1,"0"), etc. for a total of 10 textboxes.


    The Textboxes in this second set have the control identifiers [Text262] [Text264] [Text266], etc. for a total of 10 textboxes. The last of these textboxes is [Text282].

    I have a final text box that I want to use to add up all the numbers in the second set of text boxes (Text262,], [text264], [Text66], etc.) using the control source formula

    =[Text262]+[Text264]+[Text266]+[Text270]+[Text272]+[Text274]+[Text276]+[Text278]+[Text280]+[Text282]

    This works fine if at least one of the second set of Textboxes , the ones containing the formula =IIf(([text###])="adult",1,"0"), has a 1 in it but, if all these textboxes have a 0 in them the final text box will read 0000000000, not just 0.

    It is almost like the final textbox is concatenating all the zero's instead of adding them.

    Any ideas? Thanks in advance.

    Roncc

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    "0" is text. 0 is a number. Remove the quotes.
    What you're doing seems kind of convoluted but if you're happy with it and have a good reason then ignore that.
    EDIT: so yes, you are concatenating.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Roncc is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Dec 2017
    Posts
    85
    Thank you so much. That did the trick. When you're in the thick of things you sometimes can't see the forest for the trees.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Glad I could help.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,938
    Quote Originally Posted by Roncc View Post
    Thank you so much. That did the trick. When you're in the thick of things you sometimes can't see the forest for the trees.
    Having everything called Textnnn cannot possibly help either?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 4
    Last Post: 04-26-2020, 02:33 AM
  2. Replies: 19
    Last Post: 06-26-2018, 07:13 AM
  3. Replies: 3
    Last Post: 04-27-2016, 01:25 PM
  4. Replies: 4
    Last Post: 02-18-2016, 12:06 PM
  5. Replies: 5
    Last Post: 09-18-2013, 09:15 PM

Tags for this Thread

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