views:

872

answers:

3

Code in Form onLoad:

  country_combo.RowSourceType = "Value List"

Code in a reset function:

  Dim lListIndex As Long

  With Me.country_combo
    For lListIndex = .ListCount - 1 To 0 Step -1
      .RemoveItem (lListIndex)
    Next lListIndex<br/>
  End With

Code to populate country combo:

  *For n = 1 To numCountries*
    *countryCombo.AddItem (countryRS.Fields("countryName"))*
    *countryRS.MoveNext*
  *Next n*

I'm having a problem that occurs AFTER the code to populate the country combobox runs. The values are there as I can run Debug.Print(countryCombo.Value) and it prints out the name of the selected country, but I can't see the values in the combobox at all. They're invisible, and as far as I know there is no visiblity property for specific items, unless I'm completely mistaken.

comboBoxError.png

A: 

I think you should probably use Access's GUI tools to do what you're looking for. In design mode, click on the field you are trying to populate, then click the "lookup" tab. You can then specify a table to populate the field with and your forms should automaticly update as well.

NickSentowski
A: 

I've also seen what you describe here - as far as I can tell, it's a bug within Access (I was using 2007) that only occurs when you programatically mess with the contents of a combo box. It does not happen every time. The issue corrects itself if you highlight the text that is in the combo box.

YogoZuno
A: 

I am experiencing a similar issue with Access 2003. Based on the selection of one combo box, the row source of a listbox is set to an SQL string Basically a SELECT DISTINCT [MyField_Selected] FROM MyTable. For some fields the values are visible in the list box and others it is not. The values are there however as I can access them via code. To make it more interesting it works fine in Access 2007. Just found the resolution on another forum. Check the format property of the field(s) in question on the table. In my case, when Access 2007 created the table, it put an @ format in there. I removed that and all works great!

Bob