Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query shows a field decimals differently 2

Status
Not open for further replies.

knuckelhead

Technical User
Aug 8, 2002
228
US
Strange. I have a table with a field called RevHist$. It is a number field, single, 0 decimals. EG a record shows 4.95 revenue dollars.

I place the field into a query. I run the Qry and it displays 4.94999980926514

why is this? i want to avoid using round etc, if possible. so as not to slow things down. I even ensured that the table has 4.95 by retyping it in.

i also did a Compact.

any ideas?

 
In the query design grid, select the field and open the properties window. On the Format line, type Fixed or Currency and on the Decimal Places line type 2.

Or use CCur(RevHist$)
 
Since my initial request, i went to my table and made the RevHist$ with Format=fixed and Decimal Places=2. and no change. in the Qry, the field gives me a million decimals for some reason. the value 4.95 looks great in the table but not in the qry grid when i run the qry.

i had already tried one of the method's that you mentioned. that was, in the Qry, putting in Properties, Format=fixed and decimals=2. but that is more cosmetic. after running the Qry and click on the field, i see the many decimals again.

i am trying to avoid any kind of special code in my Qry field. only because i then would need to change the field name for the other fields in my Qry.

so i wonder why my table can show 4.95 but shows 4.94999980926514 in the Qry ??

thanks in advance for any more ideas.

 
Your issue is your field type and the value you are attempting to store. Consider reviewing this article
If you only want to store 2 decimal places, use a decimal type field rather than a single. What gets stored and what displays are generally two different attributes. I generally don't expose tables or queries to users.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Nice job dhookom. I got rid of my Number format in the table. As you suggested, i tried Currenty with fixed format and 2 decimals in my table. it works fine now in my Qry.

i never tried Currency, thinking that it would put dollar signs with my numbers. thereby making the reading more difficult (chance that i might read a dollar sign as say an 8).

thanks for your help fellows.
Knucklehead
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top