Solved

How format numbers differently in a listbox

Posted on 2014-04-26
4
468 Views
Last Modified: 2014-04-27
I have this SQL code in a query which drops the decimals from the number which is exactly what I want to do:

SELECT tblEstParts.EstPartID, tblEstParts.PartDesc, tblPaper.Description, tblEstParts.InkColors, Format([tblEstParts].[Qty1],"0") AS [Qty 1], Format([tblEstParts].[Qty2],"0") AS [Qty 2], Format([tblEstParts].[Qty3],"0") AS [Qty 3], Format([tblEstParts].[Qty4],"0") AS [Qty 4], Format([tblEstParts].[Qty5],"0") AS [Qty 5]
FROM tblEstParts LEFT JOIN tblPaper ON tblEstParts.PaperID = tblPaper.PaperID
ORDER BY tblEstParts.PartDesc;

But I also want the numbers to have a comma if for example the number is 2500 I want the listbox field to display 2,500

How can this be done?

--Steve
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 250 total points
ID: 40024620
try something like this

Format([tblEstParts].[Qty3],"#,###")
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 250 total points
ID: 40024735
Actually, all values in a listbox are formatted like text, so if you want the numbers to align to the right side of a column, you will have to set the font to a non-proportional font (I like Consolas, but Courier New works too), and will then need to pad the string to however many characters you want.  So try something like:

Right(Space(8) & Format([tblEstParts].Qty3, "#,###"), 8)

HTH

Dale
0
 
LVL 19

Expert Comment

by:Richard Daneke
ID: 40024932
Change your format.  Format([tblEstParts].[Qty1],"#,##0")

The "0" in use means that at least one numerical character will be displayed with no decimal place.

The "#,##0" means that additional places can be displayed add the thousands separator (",") and still no decimal places.

Since you are  using this on a numeric field, I don't think the text comment applies.  The field should stay numeric.  Please correct me if I am wrong.  The listbox that this populates is written in with what language?   Some languages have separate listbox properties for alignment.
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 40025580
List- and comboboxes always display text, thus numbers will be left aligned.
Further, the output from Format is text, so even if numbers were right aligned it wouldn't make a difference.

/gustav
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

627 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