Results 1 to 3 of 3
  1. #1
    kiranair is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2016
    Posts
    53

    conditions

    I want to round up a no based on few conditions

    1) if the values are in the range of 0.01 to 0.99 then it should be 1

    2) if the values are above 1 then a) Check the decimal if it is less than 0.2 i.e- 1.2 then round down to 1
    b) Check the decimal if it is more than 0.2 i.e- 1.21 then round up to 2


    Eg


    Question Answer
    0,22 1
    1,70 2
    19,95 20
    4,66 5
    6,40 7
    2,96 3
    0,37 1
    1,27 2
    11,12 11
    1,43 2
    1,30 2
    4,23 5
    1,66 2
    15,02 15
    1,70 2
    3,20 3
    4,30 5
    1,21 2
    12,37 13
    2,16 2
    1,11 1



    int(question)-(question-int(question)>0.2)

    This is working fine if the values in (question ) are greater than 0.2

    their is one condition in my calculation i.e if the values are in the range of 0.00- 1 then round it up to 1 and remaining is same

    if I use this int(question)-(question-int(question)>0.2) for values like 0.20- 0.01 its giving 0 but I need (1)


    can someone help me !!!!!






  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    usage: RountIt([field])


    Code:
    Public Function RountIt(ByVal pvNum) as long
    Dim vDec
    Dim lInt As Long
    
    on error resume next
    lInt = Int(pvNum)
    vDec = pvNum = lInt
    
    If pvNum < 1 Then
       RountIt = 1
    Else
       If vDec > 0.2 Then
          RountIt = lInt + 1
       Else
          RountIt = lInt
       End If
    End If
    End Function

  3. #3
    kiranair is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2016
    Posts
    53
    hello
    int(question)-(question-int(question)>0.2)

    this is absolutely working fine !!!!!!!only condition that is not working for my problem is if I get values less than 0.2 then its rounding to 0 but I want [1] remaining everything is 100% fine

    as I have not written any code only am using SQL to get the data from a main table

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

Similar Threads

  1. Top 5 per several conditions
    By tmcrouse in forum Queries
    Replies: 4
    Last Post: 03-11-2015, 07:52 AM
  2. iif for 16 conditions
    By harpreett.singhh@gmail.co in forum Access
    Replies: 3
    Last Post: 05-26-2014, 04:50 PM
  3. Select all only where conditions is met
    By webisti in forum Programming
    Replies: 1
    Last Post: 02-24-2014, 05:26 PM
  4. Help with Macro Conditions
    By sai_rlaf in forum Access
    Replies: 3
    Last Post: 01-19-2012, 04:25 PM
  5. if...then conditions ???
    By em07189 in forum Access
    Replies: 6
    Last Post: 03-05-2010, 10:29 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