Add value to value list to Unbound combo box

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
 
J

John Vinson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top