[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 510
  • Last Modified:

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
2 Solutions

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

DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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.

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now