Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Posts
    2

    Unanswered: Table Totals based on Criteria for report

    I'm very new to Access\VBA so hopefully somebody can understand my question.

    I have a table I would like to extract totals from and insert into a report. I would like to know basically ie

    total Count as integer
    while (!end of table){

    if table1.field1 = "EA" or if table1.field = "MA"
    Count = Count +1
    }
    and go through the entire table and totaling the value.

    I'd like to then insert this total into a report. I'm just verify unfamiliar with how to go about getting these totals. Should I even use VBA or is there a simpler method.

    I appreciate any help. Thankyou!

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Try:
    a) in VBA:
    Code:
    Total = DCOUNT("*", "table1", "field1 = 'EA' OR field = 'MA'")
    b) in SQL:
    Code:
    SELECT COUNT (*) AS Total
    FROM table1
    WHERE ((table1.field1 = 'EA') OR (table1.field = 'MA'));
    Have a nice day!

  3. #3
    Join Date
    Apr 2011
    Posts
    2
    Worked great. Thanks Sinnho.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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