Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46

    report the # of times a name appears in a field

    I have a datatbase where I keep all my customer information. One field is for referrals (who referred that customer to me). I want to know how to have the report list the unique names in the referral field and then list the number of times each name appears. Is this possible?



    If I know the names I can do a text box with "=count(IIF([referral]="Joe",1))" but I don't always know all the names.

  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,530
    Sure; I'd use a subquery/subreport. It would be a totals query that grouped on the referral field and counted the same field (actually probably any field, or "*").
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    That sorta works. now I get

    Joe 5
    Joe 5
    Joe 5
    Joe 5
    Joe 5
    And in a seperate box (on a seperate page)
    Tim 3
    Tim 3
    Tim 3
    ETC......

    I would like it to all be on the same page and in the same box and only listed once.
    Joe 5
    Tim 3
    Larry 12
    etc......

  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,530
    Doesn't look like the SQL is correct for the totals query. What is it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    I did a subreport from the original query. Now I understand you are suggesting a subquery as well? How do I do that?

    Thanks

  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,530
    Not a subquery, but another query that the subreport is based on. It would be a totals query, like:

    SELECT referral, Count(*) As HowMany
    FROM TableName
    GROUP BY referral

    You may need a criteria to limit to the same set of records the report is based on.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    Ok that works now. However, now I get multiple pages displaying all the same information (page # varies as to the number of results the main query returns). i.e. if the main query returns 5 results, I get 5 pages....

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    not really, most of the info is private. I can post a screen shot of the query or the SQL......

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if your subreport is linked to your report do not have ANYTHING in the detail section of the subreport. Put your person name in the PERSONNAME FOOTER, and a formula in another field that is = count(Personname).

  11. #11
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    How do i get the multiple pages to go away?

  12. #12
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Have you tried shrinking your detail section of your report down to 0, or if it already is 0 playing with your margins, it's kind of impossible to tell what you mean by 'the multiple pages'

  13. #13
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    Even with the report blank, the report will show 1 page for every result in the query.

  14. #14
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    how can it be a blank report and have a record for every item, a blank report would have a null dataset

  15. #15
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    ok.... If I create a report from the query, then delete all the text boxes from the report. The report will print a number of blank pages. The number of pages = the number of results from the query.



    ETA: I just added a text box with "=count(IIF([pRace]="W",1))" and then used the Hide Duplicates property. Now it shows the text on the first page followed by 6 empty pages(there are 14 query results), instead of the same text on 14 pages.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Chart legend appears as date
    By Vronsky in forum Programming
    Replies: 0
    Last Post: 06-09-2011, 05:20 AM
  2. Function: add date when record appears on report
    By Theremin_Ohio in forum Reports
    Replies: 1
    Last Post: 05-17-2011, 08:03 AM
  3. Replies: 3
    Last Post: 08-24-2010, 07:40 PM
  4. Report duplicating itself many many times
    By TrudyD1474 in forum Reports
    Replies: 1
    Last Post: 06-24-2010, 11:59 AM
  5. Replies: 1
    Last Post: 08-27-2008, 12:39 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