PC Review


Reply
Thread Tools Rate Thread

Calculating miles per gallon Access 2007

 
 
=?Utf-8?B?Rmx5IEJveSA1?=
Guest
Posts: n/a
 
      30th Sep 2007
I have two field as Long Integer. Gas purchased and miles driven.

It calculates ok but rounds 10.5 gallons to 11. How can I set it up so it
will calculate tenths of gallons and tenths of miles?

Thanks
 
Reply With Quote
 
 
 
 
Ken Snell \(MVP\)
Guest
Posts: n/a
 
      30th Sep 2007
Change the Field Size of the Gas purchased field to Currency or to Single or
to Double. You're trying to store a fractional number in an integer field;
won't work.

--

Ken Snell
<MS ACCESS MVP>


"Fly Boy 5" <(E-Mail Removed)> wrote in message
news:B0119C6A-7CDA-4124-9E25-(E-Mail Removed)...
>I have two field as Long Integer. Gas purchased and miles driven.
>
> It calculates ok but rounds 10.5 gallons to 11. How can I set it up so it
> will calculate tenths of gallons and tenths of miles?
>
> Thanks



 
Reply With Quote
 
=?Utf-8?B?Rmx5IEJveSA1?=
Guest
Posts: n/a
 
      30th Sep 2007
I should have said gallons purchased which would rule out the currency.

Thanks,

"Ken Snell (MVP)" wrote:

> Change the Field Size of the Gas purchased field to Currency or to Single or
> to Double. You're trying to store a fractional number in an integer field;
> won't work.
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
>
> "Fly Boy 5" <(E-Mail Removed)> wrote in message
> news:B0119C6A-7CDA-4124-9E25-(E-Mail Removed)...
> >I have two field as Long Integer. Gas purchased and miles driven.
> >
> > It calculates ok but rounds 10.5 gallons to 11. How can I set it up so it
> > will calculate tenths of gallons and tenths of miles?
> >
> > Thanks

>
>
>

 
Reply With Quote
 
=?Utf-8?B?Rmx5IEJveSA1?=
Guest
Posts: n/a
 
      30th Sep 2007
I changed the table fields to single and decimal to 1.
It still don't change until I change from 10 to 10.6 gallons which it will
indicate 27 from 30 mpg. Miles won't change until I go from 300.0 to 310.0.
which will indicate from 30 to 31mpg.
This is the formula I'm using in the query.
Expr1: +[Miles_Driven]\[Gallons_Purchased]

Any suggestions would be appreciated

"Ken Snell (MVP)" wrote:

> Change the Field Size of the Gas purchased field to Currency or to Single or
> to Double. You're trying to store a fractional number in an integer field;
> won't work.
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
>
> "Fly Boy 5" <(E-Mail Removed)> wrote in message
> news:B0119C6A-7CDA-4124-9E25-(E-Mail Removed)...
> >I have two field as Long Integer. Gas purchased and miles driven.
> >
> > It calculates ok but rounds 10.5 gallons to 11. How can I set it up so it
> > will calculate tenths of gallons and tenths of miles?
> >
> > Thanks

>
>
>

 
Reply With Quote
 
Ken Snell \(MVP\)
Guest
Posts: n/a
 
      30th Sep 2007
Currency is a data type that keeps accurate numbers to four decimal places.
It's not just for currency data -- it's used often for numbers that can have
up to four decimal places when you want exact numbers, not "floating point"
numbers. Makes your calculations more accurate too.
--

Ken Snell
<MS ACCESS MVP>





"Fly Boy 5" <(E-Mail Removed)> wrote in message
news:AAF80C64-8A27-4421-BEB9-(E-Mail Removed)...
>I should have said gallons purchased which would rule out the currency.
>
> Thanks,
>
> "Ken Snell (MVP)" wrote:
>
>> Change the Field Size of the Gas purchased field to Currency or to Single
>> or
>> to Double. You're trying to store a fractional number in an integer
>> field;
>> won't work.
>>
>> --
>>
>> Ken Snell
>> <MS ACCESS MVP>
>>
>>
>> "Fly Boy 5" <(E-Mail Removed)> wrote in message
>> news:B0119C6A-7CDA-4124-9E25-(E-Mail Removed)...
>> >I have two field as Long Integer. Gas purchased and miles driven.
>> >
>> > It calculates ok but rounds 10.5 gallons to 11. How can I set it up so
>> > it
>> > will calculate tenths of gallons and tenths of miles?
>> >
>> > Thanks

>>
>>
>>



 
Reply With Quote
 
Ken Snell \(MVP\)
Guest
Posts: n/a
 
      30th Sep 2007
You're using integer division when you use the \ operator. Try this:

Expr1: [Miles_Driven]/[Gallons_Purchased]

--

Ken Snell
<MS ACCESS MVP>



"Fly Boy 5" <(E-Mail Removed)> wrote in message
news:58A6702E-5E01-4694-91F0-(E-Mail Removed)...
>I changed the table fields to single and decimal to 1.
> It still don't change until I change from 10 to 10.6 gallons which it
> will
> indicate 27 from 30 mpg. Miles won't change until I go from 300.0 to
> 310.0.
> which will indicate from 30 to 31mpg.
> This is the formula I'm using in the query.
> Expr1: +[Miles_Driven]\[Gallons_Purchased]
>
> Any suggestions would be appreciated
>
> "Ken Snell (MVP)" wrote:
>
>> Change the Field Size of the Gas purchased field to Currency or to Single
>> or
>> to Double. You're trying to store a fractional number in an integer
>> field;
>> won't work.
>>
>> --
>>
>> Ken Snell
>> <MS ACCESS MVP>
>>
>>
>> "Fly Boy 5" <(E-Mail Removed)> wrote in message
>> news:B0119C6A-7CDA-4124-9E25-(E-Mail Removed)...
>> >I have two field as Long Integer. Gas purchased and miles driven.
>> >
>> > It calculates ok but rounds 10.5 gallons to 11. How can I set it up so
>> > it
>> > will calculate tenths of gallons and tenths of miles?
>> >
>> > Thanks

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?Rmx5IEJveSA1?=
Guest
Posts: n/a
 
      1st Oct 2007

Thank you very much. Its working fine with double.


"Ken Snell (MVP)" wrote:

> You're using integer division when you use the \ operator. Try this:
>
> Expr1: [Miles_Driven]/[Gallons_Purchased]
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
>
>
> "Fly Boy 5" <(E-Mail Removed)> wrote in message
> news:58A6702E-5E01-4694-91F0-(E-Mail Removed)...
> >I changed the table fields to single and decimal to 1.
> > It still don't change until I change from 10 to 10.6 gallons which it
> > will
> > indicate 27 from 30 mpg. Miles won't change until I go from 300.0 to
> > 310.0.
> > which will indicate from 30 to 31mpg.
> > This is the formula I'm using in the query.
> > Expr1: +[Miles_Driven]\[Gallons_Purchased]
> >
> > Any suggestions would be appreciated
> >
> > "Ken Snell (MVP)" wrote:
> >
> >> Change the Field Size of the Gas purchased field to Currency or to Single
> >> or
> >> to Double. You're trying to store a fractional number in an integer
> >> field;
> >> won't work.
> >>
> >> --
> >>
> >> Ken Snell
> >> <MS ACCESS MVP>
> >>
> >>
> >> "Fly Boy 5" <(E-Mail Removed)> wrote in message
> >> news:B0119C6A-7CDA-4124-9E25-(E-Mail Removed)...
> >> >I have two field as Long Integer. Gas purchased and miles driven.
> >> >
> >> > It calculates ok but rounds 10.5 gallons to 11. How can I set it up so
> >> > it
> >> > will calculate tenths of gallons and tenths of miles?
> >> >
> >> > Thanks
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Miles per gallon spreadsheet Greg Microsoft Excel Worksheet Functions 2 28th Mar 2009 07:04 PM
Averaging miles per gallon TckyTina Microsoft Excel Worksheet Functions 3 29th Apr 2008 09:17 PM
Miles per Gallon Report =?Utf-8?B?cGJpZWxhd3NraQ==?= Microsoft Access Reports 13 22nd Feb 2007 06:26 PM
Miles per Gallon Report =?Utf-8?B?cGJpZWxhd3NraQ==?= Microsoft Access Queries 3 16th Feb 2007 08:20 PM
excel to figure miles per gallon =?Utf-8?B?VGVycmk=?= Microsoft Excel New Users 5 9th Jan 2005 06:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:51 AM.