Can't see items in combo

A

Andy

Hi guys

I am trying to dynamically add items to a combo box on a form and
display the results to the user. (Access 2003, XP)

I have the combo type set to 'Value List'.

When I add the value to the rowsource and requery, the combo on the
form remains blank and does not display the entries.

I am appending an ";" to the list to create a delimited string.

Here is the code I am using. This code is part of a loop to
dynamically build a list of items in the combo.

varListDetail = RSt!Country & " (" & RSt!CountryCode & ")
Me!cmbResult.RowSource = Me!cmbResult.RowSource & ";" & varListDetail
Me!cmbResult.Requery

Any thoughts mush appreciated.

Thanks...Andrew
Bendigo, Australia
 
K

Ken Snell \(MVP\)

Try delimiting the value with " characters:

varListDetail = Chr(34) & RSt!Country & " (" & RSt!CountryCode & ")" &
Chr(34)
Me!cmbResult.RowSource = Me!cmbResult.RowSource & ";" & varListDetail
Me!cmbResult.Requery
 
A

Andy

Thanks for your prompt reply Ken

I have done what you suggested so my Me!cmbResult.RowSource value now
looks like:

"AUSTRALIA (AU)";"GERMANY (DE)";"FRANCE (FR)";

This would appear to be the correct format to build the list however I
still cannot get the values to display in the combo.

I was thinking the .Requery should force a display on the combo but no
go.

Should I use a text box for display purposes. What I want to achieve
is a list such as:

AUSTRALIA (AU)
GERMANY (DE)
FRANCE (FR)
etc

Thanks again for your help....Andrew
 
A

Andy

It is solved....

I changed the object to a list box and it worked.

Thanks Ken - wouldn't have worked without your (Chr34) hint.

Regards....Andrew
 
K

Ken Snell \(MVP\)

Requery will not automatically "assign" a value to a combo box; it just
requires the RowSource of the combo box. You'd need to add one more step of
code to assign, for example, the first value in the list to the combo box so
that it is displayed in the combo box when the list is not dropped down:

Me.ComboBoxName.Value = Me.ComboBoxName.ItemData(0)
 
Top