Results 1 to 11 of 11
  1. #1
    gacapp is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    16

    help with totals for count text boxes

    I am a novice, so I'm sure (hoping) someone can help.



    I have 5 text boxes that have count totals and I used the code below:

    =DCount("*", "TableName", "[Gender]='male' AND ([Age] >= 21 OR [Age] <= 30)")

    This code works fine.

    What I need is a text box that will come up with the sum of all five boxes. So for example, I have 5 count text boxes that have the numbers (2,4,3,5,4) in them. I need one text box that will sum the total of all 5 count text boxes (20).

    Can someone show me the code for doing that??

    Any help would be appreciated.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    ControlSource of:
    =Me.txt1 + Me.txt2 + Me.txt3 + Me.txt4 + Me.txt5
    ...using your ControlNames of course.

  3. #3
    gacapp is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    16
    Maybe I did something wrong.

    My text boxes are named text19, text20, text21, text22 and text23.

    I put in the Control Source for data:
    =Me.text19+Me.text21+Me.text22+Me.text23+Me.text24

    and it gives me the #Name? response.

    Can you elaborate a little more??

    thanks

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you intend to miss text20 and add text24?

  5. #5
    gacapp is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    16
    Yes, the text boxes that I listed are correct.

    any Ideas??

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by gacapp View Post
    Maybe I did something wrong.

    My text boxes are named text19, text20, text21, text22 and text23.

    I put in the Control Source for data:
    =Me.text19+Me.text21+Me.text22+Me.text23+Me.text24

    and it gives me the #Name? response.

    Can you elaborate a little more??

    thanks
    You have an inconsistancy in the names of your TextBoxes and your formula. Start with =Me.text19
    If that works then add =Me.text19+Me.text20
    ...etc...

  7. #7
    gacapp is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    16
    I tired =Me.Text19 and it gives me the same error.

    The controlsource for the Text19 box is:

    =DCount("*","Age Group: New-Child <1")

    which grabs the amount of kids that are under 1 year old. That works correctly.

    So any other suggestions??

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I take it "Age Group: New-Child <1" is the name of one of your queries.
    Try =Text19 as a ControlSource
    ...what is the name of the control where you are trying to sum everything?

  9. #9
    gacapp is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    16
    your suggestion worked - thank you very much

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So the solution is to drop the Me. from the reference right?
    =txt1 + txt2 + txt3 + txt4 + txt5
    Is this thread ready for the Solved thread tool?

  11. #11
    gacapp is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    16
    Yes the solution was to drop the "Me".

    This is a solved thread

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

Similar Threads

  1. Creating Report using Text boxes & db fields
    By Nancy J. in forum Reports
    Replies: 13
    Last Post: 07-20-2009, 07:09 AM
  2. Expense Totals
    By Nosaj08 in forum Database Design
    Replies: 10
    Last Post: 05-06-2009, 11:35 AM
  3. How to count charcter or text in field
    By nshaikh in forum Queries
    Replies: 3
    Last Post: 09-12-2008, 10:27 AM
  4. joining text in text boxes
    By jjwilliams73 in forum Forms
    Replies: 1
    Last Post: 08-26-2008, 02:30 PM
  5. bounding text boxes
    By nosirrah69 in forum Database Design
    Replies: 2
    Last Post: 02-23-2006, 08:35 AM

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