MS Access combo box Not On List


I have a form with a combo box with a list of names.  I want users to be able to type the start of names in so they go to the relevant item in the list (which they can).  However if the item is not on the list they get the 'item not on list' message and they are then forced to choose an existing item.

How do I use the 'Not On List' event to display a message saying 'Not on List' and then remove what they have entered  to allow them to continue without the the Access 'Not on list' message being displayed.

At present it is not a requirement for users to be given the option of adding what they have typed to the list.

Many thanks
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


you will find an example if you search for "NotInList" in the Access help. This event handles this error and you can use it to define an own action. Here's the code example from the help file.


Private Sub Colors_NotInList(NewData As String, _
        Response As Integer)
    Dim ctl As Control
    ' Return Control object that points to combo box.
    Set ctl = Me!Colors
    ' Prompt user to verify they wish to add new value.
    If MsgBox("Value is not in list. Add it?", _
         vbOKCancel) = vbOK Then
        ' Set Response argument to indicate that data
        ' is being added.
        Response = acDataErrAdded
        ' Add string in NewData argument to row source.
        ctl.RowSource = ctl.RowSource & ";" & NewData
    ' If user chooses Cancel, suppress error message
    ' and undo changes.
        Response = acDataErrContinue
    End If
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Armen Stein - Microsoft Access MVP since 2006PresidentCommented:
You've already gotten some helpful links above.

However, I'm questioning your design.  When a user types something into a combobox that isn't in the list, the typical behavior is to allow them to correct it slightly to find the desired value.  Your approach would clear out what they've typed (which might be many characters) and force them to start over from the beginning.  Is this departure from standard behavior really what you want?
kenabbottAuthor Commented:
I take your point but in this instance this is not a problem due to the nature of this particular dropdown
Patrick MatthewsCommented:
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.