Solved

Currency decimal places

Posted on 1998-11-24
4
1,245 Views
Last Modified: 2012-06-27
I have a VB6 front end and Access 97 backend project where the customer insists on searching for a dollar amount and applying a percentage increase or decrease.  If we start out with $20.00 and apply 10% increases all is well but as I test the app and apply numbers like 11.11% to $20.00, Access stores 3 ad 4 significant figures to the right of the decimal point in the table.  Then, when the User searched for an amount like $34.47 and the value stored is $34.467, it is never found.  How can I ensure that only two decimal values get stored.  I am using currency with 2 decimal places.
0
Comment
Question by:SiscoKid
  • 2
4 Comments
 
LVL 5

Expert Comment

by:chewhoung
ID: 1969259
How do you search for an amount? By query? If so, in your query you have to format the amount field to 2 decimal to accomplish this.

Post your query so we can have better understanding.
0
 
LVL 1

Accepted Solution

by:
ssam earned 50 total points
ID: 1969260
In your datatable, make sure the field type is
currency (i'm sure it probably already is), and try changing
the decimal places from auto to 2 in the field properties.
also, as chewhoung notes, you may have to change properties
in querries, reports, etc.
 
An alternative might be to add a
rounding statement in the VB code before stuffing the field.
0
 
LVL 1

Expert Comment

by:ssam
ID: 1969261
addendum from ssam:  also, set the format in your table to
'fixed.'
0
 

Author Comment

by:SiscoKid
ID: 1969262
I changed the query to include a Format statement "#.00" so only two decimal places gets stored.  The number of decimal places in the field definition within the table affects the display of the data not the way the data is stored.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now