• Remove the NotInList Warning (Access 2K)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Remove the NotInList Warning (Access 2K)

    Author
    Topic
    #366272

    There is a combo box on a Registration form. If the Student is listed in the combo box, they can be registered. If they are not listed in the combo box, I open a second form where that student can be added to the Student table. I am using the following code to do this, attached to the NotInList event.

    Private Sub StudentNumber_NotInList
    'Open Student Form for unlisted Students
    
    Dim strMessage As String
    Dim stDocName As String
    Dim stLinkCriteria As String
    
    strMessage = "This is not a listed Student" & (Chr(13) & Chr(10))
    strMessage = strMessage & "Do you want to add this Student?" & (Chr(13) & Chr(10))
    strMessage = strMessage & "Click Yes to add or No to re type the name"
    If MsgBox(strMessage, vbQuestion + vbYesNo, "Add New Student?") = vbNo Then
            Me![StudentNumber] = Null
       Else
        Me![StudentNumber] = Null
        DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
        stDocName = "frmStudent"
        DoCmd.OpenForm stDocName, , , , acFormAdd
    End If
    
    End Sub

    My problem is that when the Student form opens, so that a Student can be added, a window displaying the message “Text you entered is not an item in the list.” appears. This is annoying, since the only time I am opening this form is when the Student is not in the list and needs to be added. How can I inhibit the display of this message? Nothing I try seems to accomplish this simple task.

    Viewing 1 reply thread
    Author
    Replies
    • #567497

      If you look closely at the NotInLIst event, you will see it actually looks like this:

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

      You need to add a line of code like this:
      Response = acDateErrAdded

      See Help under NotInList – Event Procedures for more detail.

    • #567500

      Check out this recent thread – I think it will answer your question about how to eliminate the problem of the message popping up. In a nutshell you want to requery the combo box after you have added the student, typically done when the add form is closed. Hope this helps.

      • #567646

        Thanks Mark and Wendell for taking the time to help me understand this a bit better. I still need to work on it, but a combination of both suggestions removed the error that appeared when the add form was opened.

    Viewing 1 reply thread
    Reply To: Remove the NotInList Warning (Access 2K)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: