Results 1 to 2 of 2
  1. #1
    GaryReno is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2015
    Posts
    1

    IIF statement in Expression on Form


    I am building a database that is for a writers payroll. I'm stuck.

    I have a form from a table that has article information and word counts. I need a form to do some functions.

    LongWordCount and ShortWordCounts is where the TotalPay gets its information.

    So i need an IIF statement to say If LongWordCount has a value and ShortWordCount is Null do this math =0.02*([LongWordCount]-1500)+65

    If LongWordCount IsNull look in ShortWordCount for a value and then do this math =IF([ShortWordCount]<800,35,0.02*([ShortWordCount]-800)+35)

    So a writer writes a long word count article and gets paid 2 cents for everything over 1500 words plus $65.00

    If they write a short word count and its less than 800 words they get a flat $35.00 if its over 800 words they get $35.00 plus 2 cents a word.

    HELP PLEASE

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    LongWordCount and ShortWordCount are number fields?

    Do calculations in query:

    LWC: 65 + 0.02 * ([LongWordCount] - IIf([LongWordCount] > 1500, 1500, 0))

    SWC: 35 + 0.02 * ([ShortWordCount] - IIf([ShortWordCount] > 800, 800, 0))

    If field is Null the result will be Null.

    Now use those calculated fields in another expression.

    In a textbox on form: Nz(LWC, SWC)

    Or one expression:

    IIf([LongWordCount] Is Null, 35, 65) + 0.02 * (Nz([LongWordCount], [ShortWordCount]) - IIf(Nz([LongWordCount, ShortWordCount) > IIf([LongWordCount] Is Null, 1500, 800), IIf([LongWordCount] Is Null, 1500, 800), 0))

    Regarding use of Is Null, IsNull, Nz in query - review http://allenbrowne.com/QueryPerfIssue.html


    Otherwise, build a custom VBA function to do calcs and return appropriate value.
    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.

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

Similar Threads

  1. Replies: 6
    Last Post: 09-20-2014, 10:48 AM
  2. Replies: 2
    Last Post: 09-16-2014, 09:00 AM
  3. Append SQL Statement expression
    By Jgk in forum Queries
    Replies: 5
    Last Post: 05-16-2014, 05:56 PM
  4. Replies: 5
    Last Post: 04-25-2014, 11:10 AM
  5. Replies: 2
    Last Post: 11-20-2012, 03:21 AM

Tags for this Thread

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