1
votes

I have a situation where combobox's last value stays in the screen even if it has been removed via VBA.

I was using the method

cboBox.Removeitem "Drafter"

but here's what I would see

i've try cboBox.Requery afterwards, but no luck.

any help would be appreciated. thanks.

UPDATE:

I tried changing the combo box's source type from Value list to Table/Query, and just .requery after the values are updated. The same problem presists. Access has seemed to set "Drafter" as the default value now.

1
In MS Access, the usual way to populate a combo or list box is with an SQL statement.Fionnuala
well, i can populate it no problem, but im trying to keep it an unbound control.thanksEddy
Using SQL to populate a control does not bind it, it just makes life easier.Fionnuala
i was using a recordset to add into the combo box. as in do while not Recordset.EOF... cboBox.addItem(Recordset.value) .MoveNext Loop . etc.Eddy
Me.SomeControl.RowSouce="SELECT ID, SomeDate FROM SomeTable WHERE This = 'That'"Fionnuala

1 Answers

1
votes

The Combo Box retains its .Value even after the underlying Item has been removed from the list. That's why it still shows up in the (top) text box portion of the control even after it has been removed from the drop-down list portion. You could try this:

Dim itemToRemove As String
itemToRemove = "Drafter"
Me.cboBox.RemoveItem itemToRemove
If Me.cboBox.Value = itemToRemove Then
    Me.cboBox.Value = Null
End If