Results 1 to 6 of 6
  1. #1
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481

    Iff Funtion!

    Hello, I am using the below Iff Function to compare results for alert msg.

    Code:
    =IIf(Nz([SValuePernt],0)=0 Or Nz([ActualPernt],0)=0,"N/A",IIf(Nz([ActualPernt],0)>=Nz([SValuePernt],0)*Nz([LCLAllowance],1) And Nz([ActualPernt],0)<=Nz([SvaluePernt],0)*Nz([UCLAllowance],1),"* The Actual Value is within Ctrl Range","* The Actual Value is out of Ctrl Range"))
    Requirement:
    Can we add field value in the alert message that how much it is variant either at UCL or LCL?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    If you're going to use that many IIf's, ...don't.
    Use either a custom function,
    or
    a query and a lookup table.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    There's only 2 IIf's but I suppose would get more complicated to present more info.

    Calculate the variances in other textboxes. Reference those textboxes in another expression. What if both are variant?

    Your original expression could be a little simpler.

    =IIf(IsNull([SValuePernt] - [ActualPernt]), "N/A", IIf(Nz([ActualPernt],0) BETWEEN Nz([SValuePernt],0)*Nz([LCLAllowance],1) AND Nz([SvaluePernt],0)*Nz([UCLAllowance],1), "* The Actual Value is within Ctrl Range", "* The Actual Value is out of Ctrl Range"))

    Are other fields able to have data if SValuePernt or ActualPernt are Null? If Not, then Nz() function should not be needed.
    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.

  4. #4
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Hi

    Thanks for your feedback.

    Yeah this could be one of alternative to show variances in other other expression but i was looking forward if could be shown in "The Actual Value is out of Ctrl Range" line.

    Woh, thats looks much simpler function. I apply this function. Most probally "SValuePernt or ActualPernt had rare chances to have zero values but may be UCL or LCL fields had zero values like "0.00" but cant be null.



  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Could include variance(s), probably with more IIf's, or build a custom function.

    Don't have to include all the calcs in one textbox. Some calcs might even be better done in query used as form or report RecordSource.
    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.

  6. #6
    cap.zadi is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2011
    Location
    KSA
    Posts
    481
    Yeah,

    U are right.

    The variances are done in other text fields.

    Thanks for shorter code.

    regards

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

Similar Threads

  1. How do I make a VBA funtion Global?
    By Zellax in forum Programming
    Replies: 2
    Last Post: 08-25-2017, 02:33 PM
  2. Replies: 5
    Last Post: 01-30-2015, 08:57 PM
  3. Replies: 7
    Last Post: 08-23-2014, 05:52 AM
  4. FileCopy Funtion
    By dccjr in forum Programming
    Replies: 2
    Last Post: 04-18-2013, 09:04 PM
  5. Random Rdn() Funtion Help Please
    By graviz in forum Access
    Replies: 1
    Last Post: 12-09-2009, 11:57 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