Rounding numbers for calculated feild

A

Alvin

I am using access 2000 & Windows XP
I have an Hours Subform to calculate wages. Rate Times hours worked.
ST times 1.5 Times Rate Rate is set to currency and ST is long integer
If I have 36.10 as Rate and ST hours as 8 it should be $288.8 but it rounds
to $289
I have tried everything I know and I know I am missing something but don't
know what. Thanks for any help. Oh, The Wages are calculated through a query.
Here is the formula.
<<<< CLng(([Rate]*[ST])+([Rate]*1.5*[OT])+([Rate]*2*[DT])) >>>>
 
6

'69 Camaro

Hi, Alvin.
If I have 36.10 as Rate and ST hours as 8 it should be $288.8 but it rounds
to $289

Converting the result to a Long data type will round off the cents to a
whole number. Convert to the Currency data type instead. In your query, try
(watch out for word wrap -- this is all one line):

Wages: CCur((NZ([Rate], 0)*NZ([ST], 0))+(NZ([Rate], 0)*1.5*NZ([OT],
0))+([Rate]*2*NZ([DT], 0)))

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.


Alvin said:
I am using access 2000 & Windows XP
I have an Hours Subform to calculate wages. Rate Times hours worked.
ST times 1.5 Times Rate Rate is set to currency and ST is long integer
If I have 36.10 as Rate and ST hours as 8 it should be $288.8 but it rounds
to $289
I have tried everything I know and I know I am missing something but don't
know what. Thanks for any help. Oh, The Wages are calculated through a query.
Here is the formula.
<<<< CLng(([Rate]*[ST])+([Rate]*1.5*[OT])+([Rate]*2*[DT])) >>>>
 
O

Ofer

The clng will round the noumber, try and convert it to dbl, and then use the
format

Format(CDbl(([Rate]*[ST])+([Rate]*1.5*[OT])+([Rate]*2*[DT])) ,"#.00")
 
A

Alvin

That works great. Thank you. Now which one of the Replies is the best or is
it just personal pref ?

'69 Camaro said:
Hi, Alvin.
If I have 36.10 as Rate and ST hours as 8 it should be $288.8 but it rounds
to $289

Converting the result to a Long data type will round off the cents to a
whole number. Convert to the Currency data type instead. In your query, try
(watch out for word wrap -- this is all one line):

Wages: CCur((NZ([Rate], 0)*NZ([ST], 0))+(NZ([Rate], 0)*1.5*NZ([OT],
0))+([Rate]*2*NZ([DT], 0)))

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.


Alvin said:
I am using access 2000 & Windows XP
I have an Hours Subform to calculate wages. Rate Times hours worked.
ST times 1.5 Times Rate Rate is set to currency and ST is long integer
If I have 36.10 as Rate and ST hours as 8 it should be $288.8 but it rounds
to $289
I have tried everything I know and I know I am missing something but don't
know what. Thanks for any help. Oh, The Wages are calculated through a query.
Here is the formula.
<<<< CLng(([Rate]*[ST])+([Rate]*1.5*[OT])+([Rate]*2*[DT])) >>>>
 
6

'69 Camaro

You're welcome. Glad to help.
Now which one of the Replies is the best or is
it just personal pref ?

If you are referring to which reply to mark as an answer, you may mark more
than one post. Every reply that helped answer your question (sometimes it's
a series of steps that require multiple posts as more information is
revealed or discovered) should be marked in order to help researchers
quickly find the information they need when they have the same (or similar)
question as yours.

Each community member whose post is marked will receive credit for one
question answered, regardless of how many posts you marked as "the answer."
Your participation in this process is greatly appreciated, since two of the
participants in this thread are about to earn a bronze badge for their
contribution level in this newsgroup. Of the many hundreds of contributors
to this newsgroup, there's only one Access expert who has ever reached that
level: Tom Wickerath.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.


Alvin said:
That works great. Thank you. Now which one of the Replies is the best or
is
it just personal pref ?

'69 Camaro said:
Hi, Alvin.
If I have 36.10 as Rate and ST hours as 8 it should be $288.8 but it
rounds
to $289

Converting the result to a Long data type will round off the cents to a
whole number. Convert to the Currency data type instead. In your query,
try
(watch out for word wrap -- this is all one line):

Wages: CCur((NZ([Rate], 0)*NZ([ST], 0))+(NZ([Rate], 0)*1.5*NZ([OT],
0))+([Rate]*2*NZ([DT], 0)))

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message
will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the
question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember
that
questions answered the quickest are often from those who have a history
of
rewarding the contributors who have taken the time to answer questions
correctly.


Alvin said:
I am using access 2000 & Windows XP
I have an Hours Subform to calculate wages. Rate Times hours worked.
ST times 1.5 Times Rate Rate is set to currency and ST is long integer
If I have 36.10 as Rate and ST hours as 8 it should be $288.8 but it
rounds
to $289
I have tried everything I know and I know I am missing something but
don't
know what. Thanks for any help. Oh, The Wages are calculated through a
query.
Here is the formula.
<<<< CLng(([Rate]*[ST])+([Rate]*1.5*[OT])+([Rate]*2*[DT])) >>>>
 

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