97 Access multiple IIF query

Posted on 2011-10-06
Last Modified: 2012-08-14
I use access 97.

I have 2 tables linked together. Tblpatients and tblevent. I need a IF-then query.
Here is the situation. If you are a medicare part A patient after 10/1/2011 and you are treated with the codes 97150 or 92508 your minutes of treatment are divided by the number of people in the group.
Here is my statement without the “after 10/1/2011”
Mins: IIf([tblpatients]![PtInsur]="medicare Part a",IIf([tblEvent]![CPT Code]="97150" And "92508",[tblEvent]![U-value]/[tblEvent]![Group],[tblEvent]![U-value]),[tblEvent]![U-value])
This statement works, but I do not know how/where to add the [tblEvent]![DateofServ]>9/30/2011

Any help appreciated.

Question by:Tomcpt
    LVL 47

    Assisted Solution

    by:Dale Fye (Access MVP)
    Access 97 = Dark ages  ;-)

    How about:

    Mins: IIf([tblpatients]![PtInsur]="medicare Part a" AND [tblEvent]![CPT Code] IN ("97150", "92508") AND [tblEvent]![DateofServ]>#9/30/2011# ,[tblEvent]![U-value]/[tblEvent]![Group],[tblEvent]![U-value]),[tblEvent]![U-value])
    LVL 119

    Expert Comment

    by:Rey Obrero
    try this

    Mins: IIf([tblpatients]![PtInsur]="medicare Part a" AND [tblEvent]![CPT Code] IN ("97150", "92508") AND [tblEvent]![DateofServ]>#9/30/2011# ,[tblEvent]![U-value]/[tblEvent]![Group]),[tblEvent]![U-value])
    LVL 119

    Accepted Solution

    too many parentheses...

    try this

    Mins: IIf([tblpatients]![PtInsur]="medicare Part a" AND [tblEvent]![CPT Code] IN ("97150", "92508") AND [tblEvent]![DateofServ]>#9/30/2011# ,[tblEvent]![U-value]/[tblEvent]![Group],[tblEvent]![U-value])
    LVL 47

    Expert Comment

    by:Dale Fye (Access MVP)
    Good catch cappy.  I forgot to delete the last part of the original nested if.

    Author Closing Comment

    Fyed, thanks for the quick response. I know acc 97 old but it still works. I placed the # on both sides of my dates in my formula and it worked. When I used yours I received and error.

    Cappy I used your formula as it worked great and is best practice, therefore I awarded you the majority of the points.

    Thanks you both as this board is a life saver.


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now