Results 1 to 4 of 4
  1. #1
    pacer31 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    3

    stuck on expression for total query records

    Hi All,



    I'm very new to access and have been trying to teach myself as I go along, but am faced with an elementary task that I have been struggling with all day. My query below returns the correct counts by Payor for which I want to divide by the total number of records from table MHDCFY09A to get a percentage. As of now, the denominator, Expr1 returns the count of number of records in the table without the condition of hospid = 2118. Other than that Expr2 would seem to calculate the percent if I could fix Expr1..



    SELECT PAYOR.PAYOR_DESC, Count(MHDCFY09A.PAYOR) AS PayorN, DCount("Hospid","MHDCFY09A","2118") AS Expr1, [PayorN]/[Expr1] AS Expr2
    FROM MHDCFY09A INNER JOIN PAYOR ON MHDCFY09A.PAYOR = PAYOR.PAYOR
    GROUP BY PAYOR.PAYOR_DESC, MHDCFY09A.HOSPID
    HAVING (((MHDCFY09A.HOSPID)="2118"))
    ORDER BY Count(MHDCFY09A.PAYOR) DESC;

    Sorry if I described anything unclearly. Thanks for helping!!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The criteria argument is incorrect:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pacer31 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    3
    Thanks for the quick reply!
    I got it with DCount("RECID","MHDCFY09A","Hospid ='2118'")

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    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. Stuck on "Switch" expression.
    By andypandy in forum Programming
    Replies: 3
    Last Post: 07-04-2010, 05:12 PM
  2. Stuck on Query
    By wes028 in forum Access
    Replies: 9
    Last Post: 01-14-2010, 08:33 AM
  3. Stuck on Join Query
    By Pimped in forum Queries
    Replies: 1
    Last Post: 10-26-2009, 10:54 AM
  4. Replies: 2
    Last Post: 09-30-2009, 09:40 AM
  5. Total records printed
    By LesleyA in forum Queries
    Replies: 3
    Last Post: 08-04-2008, 03:53 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