Results 1 to 11 of 11
  1. #1
    mpaulbattle is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Location
    Houston
    Posts
    50

    When running query, if value is 0 record is missing

    I have two tables, MPL and Providers. The MPL houses all the information about the Provider's practices. On the MPL we keep track of how many Providers are associated with each practice. [NumofProv] I have been asked get it to calculate the numbers automatically so the team does not have to go and add the numbers manually. I created a query via query design to count the providers who are active and grouped it by Practice Mnemonic. This works perfectly. However, when the count is zero because we moved the doctor to Inactive, the record is missing.



    Is there away to get the field CountofMnemonic, to show 0 and not have the record go missing?

    I have looked at the Iif IsNull and Nz functions but don't quite understand them. I have also found another thread on here but it did not seem to be resolved.

    I am new to Access, please be patient with me.

    Thanks in advance

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    If the provider is inactive then count WOULD be zero.
    why do want it otherwise?

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You need to make the query a LEFT JOIN or OUTER JOIN query. In query design view, right-click the join line between the two tables, then click "Join Properties".

    In the dialog box that follows, Option 1 in the bottom part will be selected by default. Change it to Option 2 or 3, whichever one says "Include ALL records from MPL ...."

    The count should then show all records, with the zeros.

  4. #4
    mpaulbattle is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Location
    Houston
    Posts
    50
    Ranman, I asked the same question. We (management) would still need be able to view their information.

  5. #5
    mpaulbattle is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Location
    Houston
    Posts
    50
    John...I tried both options under there and still not showing. Maybe my join is incorrect. Both tables have a mnemonic field which is how i linked them. I also created a practiceID field on the providers to match that of the MPL. Should I link those two?

  6. #6
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Can you post the SQL of the query?

    Have you any criteria on fields from MPL which might keep those records from showing?

  7. #7
    mpaulbattle is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Aug 2013
    Location
    Houston
    Posts
    50
    [SELECT Providers.[eCW Contract Name], MPL.DBA, Providers.Mnemonic, Count(Providers.Mnemonic) AS CountOfMnemonic, Providers.[Active / Inactive], MPL.[SCP Campus Strategy], MPL.[SCP or PCP], MPL.[MHMD Dept], MPL.[ACO Member], MPL.Address, MPL.Phone, MPL.Fax, MPL.Specialty, MPL.[Practice Email], MPL.[Primary Contact], MPL.[Primary Contact Num], MPL.[Alternate Contact], MPL.[Back line], MPL.[Num Locations], MPL.[Practice Status], MPL.EMR, MPL.[EMR Go-Live Date], MPL.PM, MPL.[PM Go-Live Date], MPL.IA, MPL.Sales, MPL.[eCW PM], MPL.[MHMD POD], MPL.[Clearing-house], MPL.Billing, MPL.Biller, MPL.[PM Interface], MPL.[Data Migrtn], MPL.[Legacy System], MPL.[Trainer(s)], MPL.[Ending Training Date], MPL.[Elect Elig], MPL.[Elect Stmts], MPL.[MAQ UN/PW], MPL.[REC Practice], MPL.[Code Correct], MPL.[Call Reminder System], MPL.eMobile, MPL.[eMobile Go Live Date], MPL.[eMOBILE code], MPL.eHX, MPL.[eHX Go-Live Date], MPL.P2P, MPL.[eP2P Go-Live Date], MPL.[IMO Yes or No], MPL.[IMO Go-Live Date], MPL.[IMO Org ID], MPL.[IMO MH Enterprise OrgID], MPL.[Need ImmTrac Upgrade?], MPL.[ImmTrac Yes or No], MPL.[ImmTrac Go-Live Date], MPL.[MU Status 9/29/14], MPL.PP, MPL.[Pt Portal Go-Live Date], MPL.[Pt Portal URL], MPL.[Pt Portal Opt-Out Training], MPL.[Pt Portal Model], MPL.[Pt Portal Admin Dash URL], MPL.[Pt Portal Admin Dash UN], MPL.eBO, MPL.[eBO Go-Live Date], MPL.[eBO URL], MPL.[CCR V3], MPL.[CCR V3 Go Live Date], MPL.eMessenger, MPL.[eMessenger Go-Live Date], MPL.[PCMH Structured Data Built], MPL.[PCMH Go-Live date], MPL.eClinicalTouch, MPL.[eClinicalTouch Go-Live Date], MPL.[Num of eClinicalTouch Providers], MPL.Scribe, MPL.[Scribe Go-Live Date], MPL.Kiosk, MPL.[Kiosk Go-Live Date], MPL.[Kiosk Providers Activated], MPL.SmartRegistry, MPL.[SmartRegistry Go-Live Date], MPL.[SmartRegistry Trainer], MPL.HCC, MPL.[HCC Go-Live Date], MPL.[Lab interfaces other than MHDL], MPL.[dHX (Imaging Results)], MPL.[Device Interface], MPL.[Medic Scanner], MPL.ISP, MPL.[IT Partner], MPL.[eCW Portal Username], MPL.[Streamline/SN User], MPL.Facility, MPL.Notes, MPL.[Fax Server Login], MPL.[KVM Switch (Yes/No)], MPL.[Medical Home Initiative Go Live Date], MPL.[Memorial Hermann Community]
    FROM Providers
    LEFT JOIN MPL ON Providers.Mnemonic = MPL.Mnemonic
    GROUP BY Providers.[eCW Contract Name], MPL.DBA, Providers.Mnemonic, Providers.[Active / Inactive], MPL.[SCP Campus Strategy], MPL.[SCP or PCP], MPL.[MHMD Dept], MPL.[ACO Member], MPL.Address, MPL.Phone, MPL.Fax, MPL.Specialty, MPL.[Practice Email], MPL.[Primary Contact], MPL.[Primary Contact Num], MPL.[Alternate Contact], MPL.[Back line], MPL.[Num Locations], MPL.[Practice Status], MPL.EMR, MPL.[EMR Go-Live Date], MPL.PM, MPL.[PM Go-Live Date], MPL.IA, MPL.Sales, MPL.[eCW PM], MPL.[MHMD POD], MPL.[Clearing-house], MPL.Billing, MPL.Biller, MPL.[PM Interface], MPL.[Data Migrtn], MPL.[Legacy System], MPL.[Trainer(s)], MPL.[Ending Training Date], MPL.[Elect Elig], MPL.[Elect Stmts], MPL.[MAQ UN/PW], MPL.[REC Practice], MPL.[Code Correct], MPL.[Call Reminder System], MPL.eMobile, MPL.[eMobile Go Live Date], MPL.[eMOBILE code], MPL.eHX, MPL.[eHX Go-Live Date], MPL.P2P, MPL.[eP2P Go-Live Date], MPL.[IMO Yes or No], MPL.[IMO Go-Live Date], MPL.[IMO Org ID], MPL.[IMO MH Enterprise OrgID], MPL.[Need ImmTrac Upgrade?], MPL.[ImmTrac Yes or No], MPL.[ImmTrac Go-Live Date], MPL.[MU Status 9/29/14], MPL.PP, MPL.[Pt Portal Go-Live Date], MPL.[Pt Portal URL], MPL.[Pt Portal Opt-Out Training], MPL.[Pt Portal Model], MPL.[Pt Portal Admin Dash URL], MPL.[Pt Portal Admin Dash UN], MPL.eBO, MPL.[eBO Go-Live Date], MPL.[eBO URL], MPL.[CCR V3], MPL.[CCR V3 Go Live Date], MPL.eMessenger, MPL.[eMessenger Go-Live Date], MPL.[PCMH Structured Data Built], MPL.[PCMH Go-Live date], MPL.eClinicalTouch, MPL.[eClinicalTouch Go-Live Date], MPL.[Num of eClinicalTouch Providers], MPL.Scribe, MPL.[Scribe Go-Live Date], MPL.Kiosk, MPL.[Kiosk Go-Live Date], MPL.[Kiosk Providers Activated], MPL.SmartRegistry, MPL.[SmartRegistry Go-Live Date], MPL.[SmartRegistry Trainer], MPL.HCC, MPL.[HCC Go-Live Date], MPL.[Lab interfaces other than MHDL], MPL.[dHX (Imaging Results)], MPL.[Device Interface], MPL.[Medic Scanner], MPL.ISP, MPL.[IT Partner], MPL.[eCW Portal Username], MPL.[Streamline/SN User], MPL.Facility, MPL.Notes, MPL.[Fax Server Login], MPL.[KVM Switch (Yes/No)], MPL.[Medical Home Initiative Go Live Date], MPL.[Memorial Hermann Community]
    HAVING (((Providers.[Active / Inactive])="Active"))
    ORDER BY Providers.Mnemonic;


    ][/CODE]

  8. #8
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Assuming this is a one-to-many relationship, which is the "one" and which is the "many"? Normally, the 'Count' is applied to the "many" side, but in this case I can't see that count making any sense, unless [eCW Contract Name] and mnemonic are duplicated within Providers.

    Also, if the "many" side is Providers, then the ORDER BY should be on a field in the MPL table.

  9. #9
    mpaulbattle is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Aug 2013
    Location
    Houston
    Posts
    50
    [eCW Contract Name] and [Mnemonic] are on both tables. I know that is probably not the right thing to do, to have duplicate information, but initially they just asked me to transfer the excel sheets to Access. After reading more about building a DB, I am in the process of trying to create a Database Model to eliminate the duplicated information. I would think the Providers is the many side since Practices could have multiple Providers, unless i am not understanding relationships. The query is working all except where the count would be =0, it hides the record.

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Do you really need all of the fields to get a count??

    Maybe start with something simple and add fields as needed, checking to ensure the count doesn't change.
    Code:
    SELECT MPL.DBA, MPL.Mnemonic, Count(Providers.Mnemonic) AS CountOfMnemonic1
    FROM Providers RIGHT JOIN MPL ON Providers.Mnemonic = MPL.Mnemonic
    GROUP BY MPL.DBA, MPL.Mnemonic, Providers.[Active / Inactive]
    HAVING (((Providers.[Active / Inactive])="Active"))
    ORDER BY Count(Providers.Mnemonic);


    <snip>but initially they just asked me to transfer the excel sheets to Access.<snip>
    Have to say, the MPL table does look like it came from an Excel spreadsheet.
    It looks to me that the MPL table could be broken into at least 12 more tables.
    Having linking fields that are text is not the most efficient method for linking tables. Should be Long Integers.....


    Also.....
    Object names should only be letters and numbers - NO spaces, punctuation or special characters (exception is the underscore).
    You have spaces,
    special characters ([Active / Inactive], [IMO Go-Live Date], [KVM Switch (Yes/No)]) and
    punctuation ([Need ImmTrac Upgrade?]) in your field names.


    My $0.02............

  11. #11
    mpaulbattle is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Aug 2013
    Location
    Houston
    Posts
    50
    SSnafu...We are currently working on breaking up the MPL. We're just working on how we want to do it. Right now we have Practices, Providers, Locations (Addresses), and making a decision to break up the modules so it would be eClinicalTouch, eMobile, CCR, etc. I just used all the fields currently in the MPL to create a new MPL form whose data source is from the query. The count is correct, just got to find a way to get the 0 to stay in the [num prov] field without hiding the record. Will try to do just the count and go from there.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-02-2015, 03:06 PM
  2. Query to Find a Missing Record
    By KCC47 in forum Queries
    Replies: 8
    Last Post: 05-06-2014, 01:25 PM
  3. Running Sum Property Missing
    By Cheryl R in forum Forms
    Replies: 3
    Last Post: 05-31-2013, 08:33 PM
  4. Replies: 1
    Last Post: 07-13-2011, 11:30 AM
  5. Missing references and running code at startup
    By springrider in forum Programming
    Replies: 1
    Last Post: 01-09-2011, 09:47 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