Solved

Adjusting decimal places in unbound list box

Posted on 2012-03-23
7
793 Views
Last Modified: 2012-03-31
I have a unbound list box on a form in Access database.  I want some values to be 3 decimal places and some to be 4, but all are rounding to two.  Some are pulling values from table and some from queries.  How can I control the # of decimal places shown on form?
0
Comment
Question by:Caidley2k
  • 3
  • 2
  • 2
7 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37757227
You did not post many details on the listbox, other than to say it is unbound...

I don't think that you can specify that some values in a column to be 3 decimal places and others to be 4.

Or ...are you saying this this is needed for different "Columns".

If so, then set the number of decimal places in the "table" that provides these values.

JeffCoachman
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37757229
You must define that number in the query that is the rowsource for your listbox

Start out by using the Round([fieldname], decimal places ) function to get the right number of decimals.

Keep in mind, that all entries in a listbox are treated as text and will be left aligned.  Another option would be to create a continuous form, which would give you the ability to align these numeric values to the right of a textbox.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37757265
...For example, in the table, set the field property: Format to "Fixed"
Then set the decimal places property as needed. (2 or 3 ,...or whatever...)
Then when you load these values into the listbox, they will have the desired decimal places.

;-)

JeffCoachman
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 37757294
The reason I recommended the Round( ) function was that the OP indicated some needed 3 decimals, some need 4.  Unfortunately, Access doesn't have a decimal align feature like Word and Powerpoint do.  Now, that would be a useful addition.
0
 

Accepted Solution

by:
Caidley2k earned 0 total points
ID: 37767430
I was able to resolve this in the table I had created.  The Data Type is currency, but changed the format to general number and set the decimal places at what I wanted it to be.  This way allows my unbound text box to show the decimal placed I want.  
Thanks to all for your suggestions.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37768174
OK by me.

Just a note.
With a currency datatype you can set the number of decimals places as well (so there may be no need to change the datatype.

If you change the datatype from Currency you loose the default currency format (Dollar sign, thousandth separator), and you may end up having to "format" the final result as currency anyway...

JeffCoachman
0
 

Author Closing Comment

by:Caidley2k
ID: 37790349
My own comment was the easiest way for me to reach a conclusion.  Not saying any of the others wouldn't work, but based on my skill-set this was best approach for me.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
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…

920 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

15 Experts available now in Live!

Get 1:1 Help Now