Results 1 to 6 of 6
  1. #1
    The X-Man is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    8

    Having trouble with a building expression

    Hello all

    I have a question I hope someone can answer. I have the below expression that works:
    CURRENT PAYMENTS: IIf([RMOD]='TC',[HMO/POS TDI FEES EFF10/1/19],[HMO/POS TDI FEES EFF 10/1/19]*1)

    I just used this one to make sure I was writing the expression correctly and it gave me the correct results. But when I tried to add to it I keep getting an error. This is what I used:

    CURRENT PAYMENTS: IIf([RMOD]='TC',[HMO/POS TDI FEES EFF10/1/19],[HMO/POS TDI FEES EFF 10/1/19]*1, IIf([POS]='NF',[RATE B HMO NONFACILITY FEES]*1, IIF([POS] ='F', [RATE B HMO FACILITY FEES]*1))

    Why isn't this working, can anyone help?

    Thanks

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    To nest them you must add to the "false" part of an iff expression, in the first one you have both a true and a false and in the last two only the true parts.... Comma's matter....
    Cheers,

  3. #3
    The X-Man is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    8
    I see that I left out the false parts and added them. Still get an error. Now I am using:

    CURRENT PAYMENTS: IIf([RMOD]='TC',[HMO/POS TDI FEES EFF 10/1/19],[HMO/POS TDI FEES EFF 10/1/19]*1, IIF([POS]='NF', [RATE B HMO NON FACILITY FEES], [RATE B HMO NON FACILITY FEES]*1, IIF([POS]= 'F', [RATE B HMO FACILITY FEES], [RATE B HMO FACILITY FEES]*1))

    now I am getting an error saying that the expression has a function containing the wrong number of arguments.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    CURRENT PAYMENTS: IIf([RMOD]='TC',[HMO/POS TDI FEES EFF 10/1/19],[HMO/POS TDI FEES EFF 10/1/19]*1, IIF([POS]='NF', [RATE B HMO NON FACILITY FEES], [RATE B HMO NON FACILITY FEES]*1, IIF([POS]= 'F',[RATE B HMO FACILITY FEES], [RATE B HMO FACILITY FEES]*1))

    IIf(Expression,True,False)

    Nested IIF: IIF(Expression1,True,IIF(Expression2,True,IIF(Expression........
    Hopefully you can see the pattern here, each subsequent nested iif is in the False position of the previous one, so you cannot have a true, false and another iif, only true,false(=iif)True,False(=iif.........

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Join Date
    Apr 2017
    Posts
    1,679
    Field names like [HMO/POS TDI FEES EFF10/1/19] indicate table structure where same type of info (pos tdi fees eff) is in several (daily or monthly) columns. As follows, you have (every day or month) add new columns to table, and edit your formulas, forms, reports etsc. With right table structure, you do all design once, and after that you have to add new data, and you get results for new day/month from forms, queries, or reports without any additional work.

  6. #6
    The X-Man is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    8
    Thanks all. I actually was able to figure it out last night and you are right Gicu The problem was I didn't need the additional false expression. In addition, I didn't even need the *1 at the end either. Thanks again, you made me look deeper from you first response and it was extremely helpful.

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

Similar Threads

  1. Building an iif() expression
    By Sephaerius in forum Queries
    Replies: 11
    Last Post: 10-05-2017, 10:34 AM
  2. Trouble with building query in VBA...
    By sstiebinger in forum Programming
    Replies: 4
    Last Post: 08-21-2015, 09:13 AM
  3. Replies: 1
    Last Post: 08-29-2013, 06:14 AM
  4. Building An Expression Help
    By Lisa Perry in forum Access
    Replies: 12
    Last Post: 06-19-2013, 10:44 AM
  5. Report Expression Building
    By KMac in forum Reports
    Replies: 7
    Last Post: 12-07-2012, 11:29 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