Add value to value list to Unbound combo box

  • Thread starter Thread starter aa
  • Start date Start date
A

aa

How to add value to value list of unbound combo box automatically when exit
from the unbound combo box
Thank you for your help and answer
 
How to add value to value list of unbound combo box automatically when exit
from the unbound combo box
Thank you for your help and answer

Use VBA code in the combo's NotInList event, such as:

Private Sub combobox_NotInList(NewData as String, Response as Integer)
Dim iAns As Integer
iAns = MsgBox(NewData & " is not in the list. Add it?", vbYesNo)
If iAns = vbYes Then
' Add the new value
Me!combobox.RowSource = Me!combobox.RowSource & ";" & NewData
Response = acDataErrAdded
Else
' undo the selection
Me!combobox.Undo
Response = acDataErrContinue
End If
End Sub
 
Back
Top