Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remove the NotInList Warning (Access 2K)

    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.

    <pre>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</pre>



    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.

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Remove the NotInList Warning (Access 2K)

    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.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Remove the NotInList Warning (Access 2K)

    Check out this <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=acc&Number=111939&page=2&vi ew=collapsed&sb=5&o=0&fpart=2&vc=1>recent thread</A> - 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.
    Wendell

  4. #4
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Remove the NotInList Warning (Access 2K)

    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.

Posting Permissions

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