Results 1 to 4 of 4
  1. #1
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40

    Lightbulb Need To Edit This Formula

    Hi Dears!
    I am using the (IIf(([Studies1]>0) And ([Studies2]=0) And ([Studies3]=0),[Studies1],IIf(([Studies1]>=0) And ([Studies2]>0) And ([Studies3]=0),[Studies2],IIf(([Studies1]>=0) And ([Studies2]>=0) And ([Studies3]>0),[Studies3],0))))
    to show the value of studies1 when other fields are zero and this field has a number greater than 0 and show the studies2 value when the studies1 is equal or greater than 0 and so on the value of studies2.
    The Problem is here i want to use this formula work with empty strings (" ") instead of 0 for this i used the (IIf(([Studies1]<>"") And ([Studies2]="") And ([Studies3]=""),[Studies1],IIf(([Studies1]>=0) And ([Studies2]<>"") And ([Studies3]=""),[Studies2],IIf(([Studies1]>=0) And ([Studies2]>=0) And ([Studies3]<>""),[Studies3],0)))) Formula for my purpose but its not working.
    Please Help Me To Solve This Problem.
    Read For More Information:
    Main Purpose of using formula is this that I want to do the following work with the function.
    When I type a number greater than or equal to 0 in the Studies1 field and keep the two other (Studies1 and Studies2) fields empty the result must be the value of Studies1 field.
    When I type a number greater than or equal to 0 in the Studies1 field and also type a number greater than or equal to 0 in the Studies2 field and keep the one other (Studies3) field empty the result must be the value of Studies2 field.
    When I type a number greater than or equal to 0 in the studies1 field, type a number greater than or equal to 0 in the studies2 field and also type a number greater than or equal to 0 in Studies3 the result must be the value of Studies3 field.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Assuming the Studs are fields.

    Code:
    Function CalcFlds(Stud1, Stud2, Stud3)
    Dim vVal
    Select Case True
        Case Stud1 >= 0 And IsNull(Stud2) And IsNull(Stud3)
           vVal = Stud1
        
        Case Stud1 >= 0 And (Stud2)>= 0 And IsNull(Stud3)
           vVal = Stud2
        Case Stud1 >= 0 And Stud2 >= 0 And Stud3 >= 0
           vVal = Stud3
    End Select
    CalcFlds =vVal
    End Function
    Last edited by ranman256; 11-06-2014 at 10:07 AM.

  3. #3
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40
    Thanks Dear RanMan My Problem Is Solved

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    good, but I had an error on the 2nd Case. (corrected above)

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

Similar Threads

  1. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  2. Replies: 1
    Last Post: 05-31-2013, 08:53 AM
  3. need a formula please
    By jimbob90 in forum Queries
    Replies: 1
    Last Post: 08-01-2012, 06:56 PM
  4. SQL Formula to Sum Itself
    By Scorpio11 in forum Access
    Replies: 1
    Last Post: 02-19-2011, 11:22 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