Results 1 to 5 of 5
  1. #1
    KevinMCB is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    29

    Multiple IIF statements

    Just a note, I did search for any recent threads on this subject and none of them related to my problem in a way I could use.

    I am trying to calculate monthly interest in a querry for a report on pieces of collateral on a line of credit. I have no problem doing this if the unit has been on the loan for more than a month, in which case I just use

    Monthlyinterest: [CurPrin]*[Rate]/12

    However, for the units that are added to the loan, say on the 15th of the month, I need to caclulate the interest by day. So far I have come up with the following equation:

    Monthlyinterest: IIf(Year(Date())) = Year(Efdate), IIf(Month(Date())) = Month(Efdate), ([OrigPrin]*[Rate])/12, ((Date()-Efdate)*[Rate]*[CurPrin])/365

    Where Efdate = date the unit was added to the loan.

    Right now I am getting a "wrong number of arguments" error.

    I am relatively new to access. If there is a way to accomplish this with having so many imbedded "if" statements that would be great. Otherwise I need to figure out more of the logic on this equation. Thanks!

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    I don't know your rule to calculate the interest, but IIF syntax is like this:

    IIF( condition1, IIF(condition2, bothTrue, condition2false), condition1false)

  3. #3
    KevinMCB is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    29
    Thanks for the tip. Being so new to this I am still learning the language that access accepts.

  4. #4
    KevinMCB is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2010
    Posts
    29
    Ok, I had a co-worker help me out this one, our resident access authority, lol. We finally got it working. Note CurPrin from earlier = OrigPrin Anyway here is the equation:

    Monthlyinterest: IIf(Month([Enter date of report])=Month([Efdate]),IIf(Year([Enter date of report])=Year([Efdate]),[OrgPrin]*[Rate]/365*(DateValue([Enter date of report])-[Efdate]+1),[OrgPrin]*[Rate]/365*Day([Enter date of report])), [OrgPrin]*[Rate]/365*Day([Enter date of report]))

    This allows it to calculate interest on a monthly basis, but take into account how many days the item has been on the loan. So it can calculate interest per day as well, for a monthly total.

    My next project is a running total of the interest. Should be fun!

  5. #5
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you can use one IIF to simplify you expression as:
    Monthlyinterest: IIf(Month([Enter date of report])=Month([Efdate]) and Year([Enter date of report])=Year([Efdate]),[OrgPrin]*[Rate]/365*(DateValue([Enter date of report])-[Efdate]+1),[OrgPrin]*[Rate]/365*Day([Enter date of report]))

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

Similar Threads

  1. Replies: 3
    Last Post: 10-13-2010, 03:35 PM
  2. IIF statements?
    By staceyo in forum Queries
    Replies: 15
    Last Post: 09-28-2010, 08:45 AM
  3. SQL statements from VBA
    By John Southern in forum Programming
    Replies: 12
    Last Post: 05-16-2010, 01:07 PM
  4. IIF Statements
    By JDA2005 in forum Queries
    Replies: 8
    Last Post: 07-07-2009, 04:24 PM
  5. If statements
    By Ezeecopy in forum Access
    Replies: 0
    Last Post: 03-24-2009, 04:54 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