I Hate Math - An Expression

G

Guest

This is the best one yet. I have a Fee for services on my report. It works
perfectly from my point of view. It rounds the calculated fee from $545.52 to
$546.

My boss says he wants it to round up to the nearest "even" dollar amount,
since they bill in two equal installments. I suggested charging 50 cents, but
they want to keep it to dollars.

Here is the formula now: =Sum([Proj_save])*([Mgmt_fee])

Can someone help me with how to make it round up to 0,2,4,6,8?
 
A

Al Campagna

Novice2000,
I'm assuming you want your initial calculation to round up for > .5 and round down
for < .5

Lets call your calculation = Sum([Proj_save])*([Mgmt_fee])
"NetPrice" for example...


And we'll call this calculation FinalPrice
FinalPrice = IIf(Val(Format([NetPrice],"#")) Mod 2 <> 0, Val(Format([NetPrice],"#")) + 1,
Val(Format([NetPrice],"#")))

would display NetPrice as an Even number.

Proj_Save Mgmt_Fee NetPrice FinalPrice
92 1.05 96.60 98
89 1.05 93.45 94
 
A

Al Campagna

Van,
That is really "slick"...
So, putting a - just before the INT acts just like multiplying the whole calculation
by -1 ?
= (Int(-YourSum/2) * 2) * -1
Live and learn...
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Van T. Dinh said:
RoundedUpEven = -Int(-YourSum/2) * 2

should do.

--
HTH
Van T. Dinh
MVP (Access)



Novice2000 said:
This is the best one yet. I have a Fee for services on my report. It works
perfectly from my point of view. It rounds the calculated fee from $545.52 to
$546.

My boss says he wants it to round up to the nearest "even" dollar amount,
since they bill in two equal installments. I suggested charging 50 cents, but
they want to keep it to dollars.

Here is the formula now: =Sum([Proj_save])*([Mgmt_fee])

Can someone help me with how to make it round up to 0,2,4,6,8?
 
D

Douglas J. Steele

Al Campagna said:
So, putting a - just before the INT acts just like multiplying the whole
calculation by -1 ?

Yup. Technically, you're using - as a unary operator.
 
G

Guest

Thanks this worked like a charm.

Van T. Dinh said:
RoundedUpEven = -Int(-YourSum/2) * 2

should do.

--
HTH
Van T. Dinh
MVP (Access)



Novice2000 said:
This is the best one yet. I have a Fee for services on my report. It works
perfectly from my point of view. It rounds the calculated fee from $545.52
to
$546.

My boss says he wants it to round up to the nearest "even" dollar amount,
since they bill in two equal installments. I suggested charging 50 cents,
but
they want to keep it to dollars.

Here is the formula now: =Sum([Proj_save])*([Mgmt_fee])

Can someone help me with how to make it round up to 0,2,4,6,8?
 
A

Al Campagna

Douglas,
At first I saw it as
-INT
which I thought was really odd, but now I see how it's not associated with the INT at
all...

Minus a Minus amount = Positive amount?

Can't get my head around why it works that way. Multiplication or Division of 2
negative numbers yields a positive, but I don't see how just assigning a "-" to a negative
value
causes a result that is equivalent to multiplying by that value -1.
Seems like two different birds... very interesting...

I think the last time I had a "unary" problem like this, I had just returned from R&R
in Hong Kong! :-D

Thanks Douglas,
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
V

Van T. Dinh

Mathematically, applying the unary operator "-" is exactly the same as
multiplying by -1.

Is that correct, Maths Professor Doug?
 
V

Van T. Dinh

Just in case you think I am *that* smart to find this solution, I read it
first-posted in one of these newsgroups few years back.

(I am not smart. However, I tend to work very diligently on what I like to
do and Access development / programming is one.)
 
A

Al Campagna

Me too... Van.
I find database application development fascinating.
I go back to the days of Jim Button's PC-File for Dos 3.2.
Still love it after all these years...
Thanks,
Al Campagna
 
V

Van T. Dinh

I used PC-file (version 5??? - DOS-based) for a short while too before
moving to Omnis-5 (Omnis has Mac heritage and the first PC-compatible
Windows version is Omnis-5) and then Omnis-7.

Omnis-7 came out about 1991 and was actually quite good (comparable with
Access 1 and came out about a year earlier) and even now there are some
supports for Omnis-7 (version 8???) - "7" was the version number but then
Blythe Software came out with Omnis-7 version 2 and then version 3 , etc
.... - sounding like Pentium I, II, III & V.

Pity that Omnis never had the marketing powers to pull it through ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top