Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2003
    Location
    Spokane, WA
    Posts
    81

    Unanswered: Counting Text boxes

    How do I count two different text boxes?

    I've tried
    Code:
    =Count(IIf([customers_boxtype] Or [customers_boxtype2]="pb",0))
    and

    Code:
    =Count(IIf([customers_boxtype] + [customers_boxtype2]="pb",0))
    As well as

    Code:
    =Sum(IIf([customers_boxtype] And [customers_boxtype2]="pb",0))
    But neither is giving me the total of both boxes.

    Jacque

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    You have to test each object

    [customers_boxtype] = "pb" Or [customers_boxtype2] = "pb"
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Sep 2003
    Location
    Spokane, WA
    Posts
    81
    How will testing it give me a count?

  4. #4
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    What exactly do you want to count, and under what conditions to you want to count it? Are you doing this in a form, report, or query?

  5. #5
    Join Date
    Sep 2003
    Location
    Spokane, WA
    Posts
    81
    Oops, sorry about that. I should have been more clear.

    On a report, I would like a text box that will show the count of each time that "pb" occurs in the text boxes "customers_boxtype" and "customers_boxtype2".

    One text box that shows the total of both.

  6. #6
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    in the report footer

    count if both = pb
    sum(iif([customers_boxtype] = "pb" and [customers_boxtype2] = "pb",1,0))


    add one for each that = pb
    sum(iif([customers_boxtype] = "pb",1,0)+ iif([customers_boxtype2] = "pb",1,0))

  7. #7
    Join Date
    Sep 2003
    Location
    Spokane, WA
    Posts
    81
    What works is
    Code:
    =sum(iif([customers_boxtype] = "pb",1,0)+ iif([customers_boxtype2] = "pb",1,0))

  8. #8
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    You have to test each object for the value "pb."

    [customers_boxtype] = "pb"

    Or

    [customers_boxtype2] = "pb"

    You can't write

    [customers_boxtype] Or [customers_boxtype2]

    and then ask if they're = "pb"

    [customers_boxtype] Or [customers_boxtype2] = "pb"

    only tests to see if [customers_boxtype2] = "pb"
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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