Results 1 to 4 of 4
  1. #1
    Bobwords is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Minneapolis, MN
    Posts
    28

    Performing a count of specific text in report


    I'm trying to create a report of devices that are being shipped, giving a total number of devices sent. I want to create a footer on the report that shows how many of each device type is being mailed monthly, but I'm not sure how I'm supposed to go about writing the syntax for it.

    On any given month we'll ship 5 different items, each contained as text in the Device_Type field.

    Click image for larger version. 

Name:	report.PNG 
Views:	12 
Size:	57.6 KB 
ID:	16904

    At the very bottom of the report, I'd like to get an output that shows how many of each device type way shipped. Is there a way to do something like =Count("6921", [Device_Type])? I know that isn't the right way to do it, as I've tried. Any help would be greatly appreciated!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did you consider using report Sorting & Grouping features with aggregate calc in group footer?

    How many device types are there? In report footer section:

    =Count(IIf([Device_Type]="6921",1,Null))

    or

    =Sum(IIf([Device_Type]="6921",1,0))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Bobwords is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Minneapolis, MN
    Posts
    28
    Quote Originally Posted by June7 View Post
    Did you consider using report Sorting & Grouping features with aggregate calc in group footer?

    How many device types are there? In report footer section:

    =Count(IIf([Device_Type]="6921",1,Null))

    or

    =Sum(IIf([Device_Type]="6921",1,0))

    =Count(IIf([Device_Type]="6921",1,Null)) was exactly what I needed! Thank you so much.

    If I could ask, can you help break down what each thing is doing? Just so I understand it better?

    I get how count works, but why are there two IIs? Is that a different command? For the 1,Null, what exactly does that do? Assign the appearance of a 6921 a value of 1 to be counted? What does the null statement at the end do?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The IIf() is an intrinsic function. It means "In-line If". The logic is: If condition is true, then do this, else do this. Access Help has more info on use of IIf() function.

    Aggregate functions ignore Null so it does not count that record.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Specific Record Count
    By FormerJarHead in forum Queries
    Replies: 3
    Last Post: 08-23-2013, 11:02 AM
  2. Replies: 1
    Last Post: 04-04-2013, 11:59 AM
  3. Parameter Query/Report Question to Count Text
    By Lettyg82 in forum Reports
    Replies: 6
    Last Post: 08-13-2012, 03:47 PM
  4. Replies: 1
    Last Post: 06-04-2012, 04:31 PM
  5. Performing count in VBA
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 08-21-2010, 07:41 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