Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2007
    Posts
    38

    Unanswered: Not on List event error

    Hi all

    I'll admit first up that I have just copied an example of the Not On List event as I don't know VB code at all and have made changes that I had hoped would work. I use a form which pulls inform from another table via a combo box. The table is named "Sire" and the column name of "Name".

    When I enter a new name that isn't on the list I am getting the error "The text you entered isn't an item on the list" "Select an item from the list, or enter text that matches one of the listed items"

    I summize that the code is correct up until the MsgBox part but as I said I really don't know the code language and need some help fixing it.

    Below is the code I have for the event.

    Private Sub Sire_NotInList(NewData As String, Response As Integer)

    Dim ctl As Control

    ' Return Control object that points to combo box.
    Set ctl = Me!Sire
    ' 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.RowSourceType = "Table/Query"
    ctl.RowSource = "Sire"
    Else
    ' If user chooses Cancel, suppress error message
    ' and undo changes.
    Response = acDataErrContinue
    ctl.Undo
    End If
    End Sub


    Thanks in advance. KIM

  2. #2
    Join Date
    Sep 2007
    Location
    Global Village
    Posts
    185
    Check out if your combo box property "Limit to List" is not set to "Yes", if it is then change it to "No"
    Cheers

  3. #3
    Join Date
    Aug 2007
    Posts
    38
    I did have it set to YES but on changing it to NO I don't get the MSGBox asking do I want to add the item. Also the item doesn't get added to the list.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •