473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to ensure accurate mileage expense calculations??

Hello,

I have read about currency calculations, etc. in this newsgroup, and I
understand that currency math will be sufficiently accurate for what I
need to do for a mileage/expense report.

Where I'm stuck is what data type etc. I should use for the mileage
distance number -- single?? decimal?? for the amount of mileage
distance traveled, to two decimal places maximum, but allowing for no
decimals or one decimal place or two decimal places.

Then in a query or even form field which calculates the mileage
reimbursement money amount, I need to multiply the mileage amount times
$.31 to get the money amount, and have the query result be an accurate
currency value displayed to 2 decimal places, therefore I need to have
an accurate data entry for the mileage distance amount (e.g. 10.0 miles
or more).

Basically the expense report should work more or less like this
unfinished HTML example page:

http://www.visualwave.com/expense.

This simple page auto-calculates expenses or mileages in each row and
adds them up in each column, and generates a grand total, but contains
various rather unwieldy JavaScript, etc. It's been tested for the
calculations, but the form data entry validations are not so hot (for
proper decimal places). The first row works best. Perhaps I should
stick with this, and backend a database to this form...

My other option is to use Visual Web Developer and ASP.NET 2.0 against
an Access database, but that also requires validation, queries, etc.
that Access can easily do for me, even if I do have to give 150 people
an MDE file, sigh.

Thank you for reading this,
Tom

Jan 29 '06 #1
4 3118
I think you want your "mileage" field to contain the number of miles
travelled (not the odometer reading of the vehicle)? If so, your table will
have fields like this:
MileageID AutoNumber primary key
MileageDate Date/Time When this expense occurred.
MileageDescrip Text (255)
Miles Number (Long, or Double if you need fractions)
Rate Currency $/mile

You will then create a query to calculate the expense for the row. Type this
into a fresh column in the Field row:
Expense: [Miles] * [Rate]

If you used a Double as the size for the Miles field, then round to the
nearest cent like this:
Expense: Round([Miles] * [Rate])

To enure that is interpreted correctly, use:
Expense: CCurNz(Round([Miles] * [Rate]),0))

You can now create a report based on that query that sums the total.

If the idea of doing calculated fields in a query (instead of storing in a
table) is new, see:
Calculated fields
at:
http://allenbrowne.com/casu-14.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"tlyczko" <tl*****@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...

I have read about currency calculations, etc. in this newsgroup, and I
understand that currency math will be sufficiently accurate for what I
need to do for a mileage/expense report.

Where I'm stuck is what data type etc. I should use for the mileage
distance number -- single?? decimal?? for the amount of mileage
distance traveled, to two decimal places maximum, but allowing for no
decimals or one decimal place or two decimal places.

Then in a query or even form field which calculates the mileage
reimbursement money amount, I need to multiply the mileage amount times
$.31 to get the money amount, and have the query result be an accurate
currency value displayed to 2 decimal places, therefore I need to have
an accurate data entry for the mileage distance amount (e.g. 10.0 miles
or more).

Basically the expense report should work more or less like this
unfinished HTML example page:

http://www.visualwave.com/expense.

This simple page auto-calculates expenses or mileages in each row and
adds them up in each column, and generates a grand total, but contains
various rather unwieldy JavaScript, etc. It's been tested for the
calculations, but the form data entry validations are not so hot (for
proper decimal places). The first row works best. Perhaps I should
stick with this, and backend a database to this form...

My other option is to use Visual Web Developer and ASP.NET 2.0 against
an Access database, but that also requires validation, queries, etc.
that Access can easily do for me, even if I do have to give 150 people
an MDE file, sigh.

Thank you for reading this,
Tom

Jan 30 '06 #2
Hello Allen,

Thank you for responding, this is what I'm doing, I appreciate your
adding the comments about rounding, since there are so many comments
about this topic, I wasn't sure if setting the number of decimal places
etc. was the way to round a Double.

I'll also read the newsgroup about Round().

However, if I want the Miles number to be a decimal (e.g. 29.6 or 84.33
miles) you suggested I use Double.

Will this be sufficiently accurate that when I round it, multiply it by
the Rate, then cast it to Currency, that I will get an accurate dollar
amount??

I'll do my own testing, but after having read some of the impassioned
posts about rounding, currency, etc. I just wanted to be sure.

Thank you, Tom

Jan 30 '06 #3
You can use the Currency data type to store things other than money. You
might like to use a Currency field, and set the Format to Fixed and the
Decimal Places to 2.

Than use Round() when you make the calculations in the query, and the result
will be accurate. Again, you may wish to set the Format of the field in the
query (or the text box on the form/report) so it is Fixed, 2-decimal place.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"tlyczko" <tl*****@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
Hello Allen,

Thank you for responding, this is what I'm doing, I appreciate your
adding the comments about rounding, since there are so many comments
about this topic, I wasn't sure if setting the number of decimal places
etc. was the way to round a Double.

I'll also read the newsgroup about Round().

However, if I want the Miles number to be a decimal (e.g. 29.6 or 84.33
miles) you suggested I use Double.

Will this be sufficiently accurate that when I round it, multiply it by
the Rate, then cast it to Currency, that I will get an accurate dollar
amount??

I'll do my own testing, but after having read some of the impassioned
posts about rounding, currency, etc. I just wanted to be sure.

Thank you, Tom

Jan 30 '06 #4
Hello Allen,

Thank you for the advice about the currency datatype.

I can see I'll have to run examples etc., since I hope to eventually
use an ASP.NET 2.0 form and HTML table output for this after getting
the Access query set up right.

Thank you, Tom

Jan 30 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: slylos | last post by:
I've got a section of code in my app that keeps track of how much time an employee has accrued, which equals out to 1.33 days of PTO per month. I'm trying to store the time accrued so far in an...
6
by: jimfortune | last post by:
In: http://groups.google.com/group/comp.databases.ms-access/msg/60d7faa790c65db1 james.ea...@gmail.com said: :Ok, I've answered the first half of my own question. From a MSDN :article, I...
3
by: t | last post by:
Does anyone know of a software that calculates mileage chart(not msmappoint or what ever they call it please)? If not, how do you write the software? I just can not figure it out. Has anyone tried...
9
by: lialie | last post by:
Hi, all Suppose have two threads, one thread(A) does heavy calculations, the other one(B) must get a accurate time.Thread B can't cost too much cpu's resource, but it must trigger an event at...
5
Deathwing
by: Deathwing | last post by:
Hi everyone one I'm playing around with trying to make an expense calculator. I would like it so that the user can keep enter expenses until they have no more expenses. Then I would like for the...
9
Deathwing
by: Deathwing | last post by:
Hey everyone, I have written a code that figures out a users total montly expenses. I have it working except for the fact that it does not add up their cumulative entries. For example, the code ask...
0
by: Shawn Yates | last post by:
I have a few applications that calculate the mileage from one city or zipcode to another using the best routes. The main problem I have with those programs is that I can only enter one city at a...
4
by: Timothy Grant | last post by:
On Fri, Aug 29, 2008 at 6:51 AM, Heston James <heston_james@live.co.ukwrote: Why not look at the process list, and if you find two entries kill the one that is just starting? -- Stand Fast,...
7
by: MNNovice | last post by:
Please forgive me for this is a long request. I am designing a DB to capture expenses related to Federal Grants and to generate appropriate reports. Each grant starts with a Notice of Grant Award...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.