Results 1 to 3 of 3
  1. #1
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62

    how to use multiple IIF code in a query?

    I WANT TO USE THIS CODE DEPENDING THE TYPE OF THE ACCOUNT, THERE ARE 2 TYPES OF ACCOUNT RESIDENTIAL AND COMMERCIAL ACCOUNT.




    IF "RESIDENTIAL ACCOUNT" OR (R) ACCOUNT IS TRUE:

    THIS CODE WILL RUN
    IIf([m3]>=36,((((([m3]-15)-10)-10)*21.56)+472.5),IIf([m3]>=26,(((([m3]-15)-10)*17.25)+300),IIf([m3]>=16,((([m3]-15)*15)+150),IIf([m3]>=15,(150),IIf([m3]>=10,(150),IIf([m3]<=9,[m3]*15,"0"))))))

    IF "COMMERCIAL ACCOUNT" OR (C)
    IIf([m3]>=36,((((([m3]-15)-10)-10)*43.13)+945),IIf([m3]>=26,(((([m3]-15)-10)*34.5)+600),IIf([m3]>=16,((([m3]-15)*30)+300),IIf([m3]>=15,(300),IIf([m3]>=10,(300),IIf([m3]<=9,[m3]*30,"0"))))))

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Those are very long expressions. Probably should build a VBA custom function. However, try:

    IIf([Account] = "RESIDENTIAL ACCOUNT",

    Switch([m3]>=36, (((([m3]-15)-10)-10)*21.56)+472.5, [m3]>=26, ((([m3]-15)-10)*17.25)+300, [m3]>=16, (([m3]-15)*15)+150, [m3]>=10, 150, [m3]<=9, [m3]*15),

    Switch([m3]>=36, (((([m3]-15)-10)-10)*43.13)+945, [m3]>=26, ((([m3]-15)-10)*34.5)+600, [m3]>=16, (([m3]-15)*30)+300, [m3]>=10, 300, [m3]<=9, [m3]*30))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    markpastoril is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2018
    Posts
    62
    really works thanks sir?or maam?

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

Similar Threads

  1. Replies: 12
    Last Post: 08-23-2016, 09:22 AM
  2. Replies: 9
    Last Post: 10-15-2014, 12:09 PM
  3. Replies: 1
    Last Post: 05-04-2013, 12:19 PM
  4. VBA code to get sum from multiple entries
    By budchevy in forum Programming
    Replies: 2
    Last Post: 04-04-2012, 03:21 PM
  5. Multiple tasks in vb code
    By JFo in forum Programming
    Replies: 8
    Last Post: 10-03-2011, 07:58 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