List Box Formatting

R

Ray S.

I have a form with a list box. The list box is populated by a query. The
query is:

SELECT CheckFinalPercentages.AllocType, CheckFinalPercentages.[Master-Sub],
CheckFinalPercentages.SumOfPERCOUT AS Pct
FROM CheckFinalPercentages
ORDER BY CheckFinalPercentages.AllocType DESC ,
CheckFinalPercentages.[Master-Sub];

Now, when I run the query that feeds the list, I get the SumOfPERCOUT As Pct
looking fine, with the Pct column displaying in percent format, but in the
list it is showing up as a number (for example, instead of 100%, I get 1). I
know that at one point the form used to display the percentage format, but
somehow I've lost that. Can anyone give me a tip as to how I can get it to
display in percent format again?
 
R

Ray S.

OK, it's me again...I just noticed that two more list boxes in the form are
also not showing the formatting from the source query. The query is set up to
display numbers in standard format (with comma separating thousands), and the
query displays fine if you just run the query, but in the list box the
numbers are displaying without the commas. I figure this has to have
something to do with the form itself...HELP!
 
D

Douglas J. Steele

Wrap the Format function around the fields in question:

SELECT CheckFinalPercentages.AllocType, CheckFinalPercentages.[Master-Sub],
Format(CheckFinalPercentages.SumOfPERCOUT, "Percent") AS Pct
FROM CheckFinalPercentages
ORDER BY CheckFinalPercentages.AllocType DESC ,
CheckFinalPercentages.[Master-Sub];

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Ray S. said:
OK, it's me again...I just noticed that two more list boxes in the form
are
also not showing the formatting from the source query. The query is set up
to
display numbers in standard format (with comma separating thousands), and
the
query displays fine if you just run the query, but in the list box the
numbers are displaying without the commas. I figure this has to have
something to do with the form itself...HELP!

Ray S. said:
I have a form with a list box. The list box is populated by a query. The
query is:

SELECT CheckFinalPercentages.AllocType,
CheckFinalPercentages.[Master-Sub],
CheckFinalPercentages.SumOfPERCOUT AS Pct
FROM CheckFinalPercentages
ORDER BY CheckFinalPercentages.AllocType DESC ,
CheckFinalPercentages.[Master-Sub];

Now, when I run the query that feeds the list, I get the SumOfPERCOUT As
Pct
looking fine, with the Pct column displaying in percent format, but in
the
list it is showing up as a number (for example, instead of 100%, I get
1). I
know that at one point the form used to display the percentage format,
but
somehow I've lost that. Can anyone give me a tip as to how I can get it
to
display in percent format again?
 
K

Ken Sheridan

Change the RowSource property of the list box to:

SELECT AllocType, [Master-Sub],
FORMAT(SumOfPERCOUT, "PerCent")
FROM CheckFinalPercentages
ORDER BY AllocType DESC, [Master-Sub];

Do the same for the other list boxes' RowSource properties, changing the
references in the SELECT clauses to the relevant columns like this:

FORMAT([YourNumberColumn],"#,##0.00")

Unless you are showing column headings in the list box you don't need to
give the formatted columns aliases.

Ken Sheridan
Stafford, England

Ray S. said:
OK, it's me again...I just noticed that two more list boxes in the form are
also not showing the formatting from the source query. The query is set up to
display numbers in standard format (with comma separating thousands), and the
query displays fine if you just run the query, but in the list box the
numbers are displaying without the commas. I figure this has to have
something to do with the form itself...HELP!

Ray S. said:
I have a form with a list box. The list box is populated by a query. The
query is:

SELECT CheckFinalPercentages.AllocType, CheckFinalPercentages.[Master-Sub],
CheckFinalPercentages.SumOfPERCOUT AS Pct
FROM CheckFinalPercentages
ORDER BY CheckFinalPercentages.AllocType DESC ,
CheckFinalPercentages.[Master-Sub];

Now, when I run the query that feeds the list, I get the SumOfPERCOUT As Pct
looking fine, with the Pct column displaying in percent format, but in the
list it is showing up as a number (for example, instead of 100%, I get 1). I
know that at one point the form used to display the percentage format, but
somehow I've lost that. Can anyone give me a tip as to how I can get it to
display in percent format again?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top