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

    Easier approach to gaining a sumation


    I have a report whose ControlSource includes two fields of special interest here, say MyField1 and MyField2. Those two fields have valid values of either 1,2,3 and 5. "Bottom line" here is that I want to include in the Report's Footer the total number of 2's observed, the number of 3's observed and the number of 5's observed within those two fields.

    While I could write several lines of Select Case code in a RecordSetClone loop in the Report's Footer section, I had the idea that there could be a simpler way. I tried to think of a way to create 3 pseudo variables in the RecordSource query and use a SUM function with those variables in the ReportFooter, but I wasn't sure that it was even a possibility.

    Any Suggestions?

    Thanks,
    Bill

  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,521
    How about

    =Sum(IIf(MyField1 = 2, 1, 0)) + Sum(IIf(MyField2 = 2, 1, 0))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    In the RecordSource Query or as the ControlSource of a text box in the Report Footer? I suspect you mean the latter?

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I meant the latter. You could probably also create a totals query and base a subreport on it. That would be more dynamic.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Paul,
    I knew it should be simple.
    Thanks,
    Bill

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem Bill!
    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. The Golden VB Script that will make your life much easier
    By pkstormy in forum Code Repository
    Replies: 55
    Last Post: 04-14-2015, 12:08 PM
  2. Easier way than adding 200 queries?
    By Kamal in forum Queries
    Replies: 2
    Last Post: 02-28-2013, 07:02 AM
  3. Replies: 1
    Last Post: 09-13-2012, 09:31 AM
  4. Replies: 3
    Last Post: 05-14-2012, 01:09 PM
  5. Replies: 8
    Last Post: 08-11-2010, 09:20 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