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.