Results 1 to 3 of 3
  1. #1
    nsteenhaut is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    6

    DCount

    Hi,



    I have two tables. One table called "Lawyers" and one table called "Law Firm Offices". Each Lawyer belongs to a Law Firm Office via the primary key "Law_Office_ID". I am trying to set up a query that returns the number of lawyers for each Law_Office_ID, so my query (called "No_Of_Attys_By_Office") has just 2 columns - Law_Office_ID and the field I built with the expression builder using DCount. The expression I buildt below, however, returns the total number of attorneys in the database and the number is the same for each Law_Office_ID. What am I doing wrong? Here's my expression:

    Number_Of_Attorneys: DCount("[Lawyers]![Lawyer_ID]","Lawyers",[Lawyers]![Law_Office_ID]=[No_Of_Attys_By_Office]![Law_Office_ID])

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    There is no grouping with DCount. To get the count per law office you query:
    Code:
    SELECT [Law_Office_ID], Count([Law_Office_ID]) AS CountOfLawyers
    FROM [Lawyers]
    GROUP BY [Law_Office_ID]

  3. #3
    nsteenhaut is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    6
    THANKS!!! This worked like a charm!

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

Similar Threads

  1. DCount and If
    By Madmax in forum Access
    Replies: 3
    Last Post: 07-28-2011, 06:53 AM
  2. dcount and isnull
    By Madmax in forum Access
    Replies: 7
    Last Post: 06-22-2011, 09:31 AM
  3. DCount and SQL
    By DSTR3 in forum Queries
    Replies: 3
    Last Post: 12-06-2010, 03:07 PM
  4. Help with Dcount
    By tozey in forum Programming
    Replies: 1
    Last Post: 08-10-2010, 10:53 AM
  5. Dcount on report
    By mattbrem in forum Reports
    Replies: 2
    Last Post: 06-06-2009, 01:33 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