Retail roundin

geno

Registered User.
Local time
Today, 08:30
Joined
Jun 19, 2000
Messages
243
Hi,
I need to round a retail price to the nearest 8. Lets say after a discount is applied then a margin is applied the retail comes out to $4.75, is there a way to round this up to $4.78? Another scenerio is if the retail is $4.79 round down to $4.78.
Thanks
 
Try This!

FOR ACCESS 2000 TRY THIS.........

DIM MYNUM AS LONG
DIM GOUP AS LONG
DIM GODOWN AS LONG

IF RIGHT(FORMS![name of your form]![name of your field],1) = "8" THEN
EXIT FUNCTION
END IF

MYNUM = FORMS![name of your form]![name of your field]
GOUP = 0
GODOWN = 0

DO WHILE RIGHT(MYNUM,1) <> "8"
MYNUM = MYNUM + 0.01
GOUP = GOUP + 0.01
LOOP

MYNUM = FORMS![name of your form]![name of your field]

DO WHILE RIGHT(MYNUM,1) <> "8"
MYNUM = MYNUM - 0.01
GODOWN = GODOWN + 0.01
LOOP

IF (GOUP = GODOWN) OR (GOUP > GODOWN) THEN
FORMS![name of your form]![name of your field] = FORMS![name of your form]![name of your field] + GOUP
EXIT FUNCTION
END IF

FORMS![name of your form]![name of your field] = FORMS![name of your form]![name of your field] - GODOWN

LET ME KNOW HOW YOU GO!

REGARDS,

NEIL ADCOCK
 
Correction!!!

Sorry, the 8's should not be in quote marks!! ie <> 8 not <> "8"

Neil
 
I need to round a retail price to the nearest 8

So, I assume that if your number ends in 0,1, or 2 then round 'down' to the previous 0.8.


Try the following:

int(YourNumber*10-0.3) / 10 + 0.08
 
Last edited:
However, if you simply want the last number to become an 8, do this:

int(Your Number * 10) / 10 + 0.08
 
Hi Neil,
Does your code go into a module? If so how do I call the function on the exit of the retail price field. I've also tried kkilfoil's suggestion of int([FINAL RETAIL] * 10) / 10 + 0.08 but I get an error: Compile error: Expected Identifier:
Thanks
 
geno said:
Hi Neil,
Does your code go into a module? If so how do I call the function on the exit of the retail price field. I've also tried kkilfoil's suggestion of int([FINAL RETAIL] * 10) / 10 + 0.08 but I get an error: Compile error: Expected Identifier:
Thanks

I assumed that you would be creating a calculated field in a query, which is less complicated than code.
 
Hi,
You assume correct, I do have quite a bit of calculations happening in this query. I did add your suggestion: int([FINAL RETAIL] * 10) / 10 + 0.08 to the query and it works AOK. Thanks for pointing me in the right direction.
Geno
 

Users who are viewing this thread

Back
Top Bottom