List Box help please

  • Thread starter Thread starter Stacey Howard
  • Start date Start date
S

Stacey Howard

I have a collection of currency values in vba, that I would like to display
in a list box control on a form. When I attempt to use the additem method of
the list box control to add the values for display. Any numbers with three
digits or more are truncated in the list box as such:

truncated
$1
000.000

Instead of
$1000.000

If I then try to add a string literal of $1000.000 the control functions
fine. Any ideas on how I can resolve this issue. Using Access xp.
 
Stacey,

A quick look at VBA Help on the AddItem method indicates that a String
expression is required for the Item argument. If your application needs to
do some math with the Selected Item or a comparison to another currency
value, you can convert the String back to Currency upon selection.

hth,
 
It looks as if your problem stems from the commas that
normally appear in Currency values. When adding these in
as string items using the AddItem method, the commas in
resulting RowSource property are subsequently being
translated as 'end of row'.
There are two solutions depending upon your requirements.
If you do not need to have the commas present, then use the
format function to generate the appropriate string from the
currency value e.g ListBox.AddItem Format(curValue , "$#0.00")
If you do need to have the commas present, then populate a
table with the list values, change the Row Source Type
property to "Table/Query" and the Row Source property to
this table.
 
Back
Top