Results 1 to 6 of 6
  1. #1
    huntersoasis is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    11

    Calculated Field - Rounding to .99

    So I have a Calculated Field


    If the price is .01 to .08 I want it to round up to .99 if it is 1.00 to round down to .99

    The current Calculated Field is this:

    Code:
    IIf([ORIG_LOCATION]="",0,IIf([ORIG_LOCATION]="DL",Round([SHIPPED_PRICE]*1.667,2),IIf([ORIG_LOCATION]="PJ",Round([SHIPPED_PRICE]*1.25,2),IIf([ORIG_LOCATION]="SB",Round([SHIPPED_PRICE]*1.667,2),IIf([ORIG_LOCATION]="WF",Round([SHIPPED_PRICE]*1.25,2),IIf([ORIG_LOCATION]="CNC",Round([SHIPPED_PRICE]*1.667,2),IIf([ORIG_LOCATION]="CNB",Round([SHIPPED_PRICE]*1.25,2),IIf([ORIG_LOCATION]="WFS",Round([SHIPPED_PRICE]*1.25,2),0))))))))

  2. #2
    huntersoasis is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    11
    The Next Calculated field needs the Same and it look like this..

    Code:
    IIf([ORIG_LOCATION]="",0,IIf([ORIG_LOCATION]="DL",Round([WHOLESALE_PRICE]*1.8,2),IIf([ORIG_LOCATION]="PJ",Round([WHOLESALE_PRICE]*1.3,2),IIf([ORIG_LOCATION]="SB",Round([WHOLESALE_PRICE]*1.8,2),IIf([ORIG_LOCATION]="WF",Round([WHOLESALE_PRICE]*1.35,2),IIf([ORIG_LOCATION]="CNc",Round([WHOLESALE_PRICE]*1.8,2),IIf([ORIG_LOCATION]="CNB",Round([WHOLESALE_PRICE]*1.3,2),IIf([ORIG_LOCATION]="WFS",Round([WHOLESALE_PRICE]*1.3,2),0))))))))

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Put this code in a module, then in your query,
    replace ROUND, with ROUND99

    Code:
    Public Function Round99(ByVal pvCalc)
    Dim cAmt As Currency
    Dim cCents As Currency
    Dim iDollar As Long
    
    
    cAmt = Round(pvCalc, 2)
    iDollar = CInt(cAmt)
    cCents = cAmt - iDollar
    
    
    Select Case cCents
       Case 0
          cAmt = cAmt - 0.01
       Case 0.01 To 0.08
          cAmt = iDollar + 0.99
       Case Else
          'if .09 to .98 ,do nothing
    End Select
    
    
    Round99 = cAmt
    End Function

  4. #4
    huntersoasis is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    11
    ranman256,

    I am unable to get this to work.

    When i change the Round( to Round99 in the calculated field I get a Error

    The expression
    The expression
    IIf([ORIG_LOCATION]="",0,IIf([ORIG_LOCATION]="DL",Round99([WHOLESALE_PRICE]*1.8,2),IIf([ORIG_LOCATION]="PJ",Round([WHOLESALE_PRICE]*1.3,2),IIf([ORIG_LOCATION]="SB",Round([WHOLESALE_PRICE]*1.8,2),IIf([ORIG_LOCATION]="WF",Round([WHOLESALE_PRICE]*1.35,2),IIf([ORIG_LOCATION]="CNc",Round([WHOLESALE_PRICE]*1.8,2),IIf([ORIG_LOCATION]="CNB",Round([WHOLESALE_PRICE]*1.3,2),IIf([ORIG_LOCATION]="WFS",Round([WHOLESALE_PRICE]*1.3,2),0))))))))
    cannot be used in a calculated column

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So I have a Calculated Field
    Does this mean you have a table that has a calculated field or that you are doing the calculation in a control or query?

    If you mean a field in a table, this is not (IMO) a good idea. I never use calculated fields in tables. If you can calculate it, then just calculate it when you need it.


    See http://allenbrowne.com/casu-14.html

  6. #6
    huntersoasis is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    11
    This is a field in a table doing the calculated field.

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

Similar Threads

  1. Replies: 2
    Last Post: 12-30-2014, 01:32 PM
  2. Rounding down in a report field
    By drnld in forum Access
    Replies: 4
    Last Post: 05-27-2014, 05:42 PM
  3. Replies: 2
    Last Post: 12-15-2013, 02:29 AM
  4. Rounding Down in a calculation field
    By FFLKing in forum Access
    Replies: 8
    Last Post: 06-05-2013, 02:22 PM
  5. Replies: 1
    Last Post: 04-21-2013, 03:20 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