"The text you entered isn't an item in the list" error when you add a new record to a table
Office 365 ProPlus is being renamed to Microsoft 365 Apps for enterprise. For more information about this change, read this blog post.
Original KB number: 824176
This article applies only to a Microsoft Access database (.mdb). Requires basic macro, coding, and interoperability skills.
When you try to programmatically add a new record to a table by using the NotInList event of the combo box on a form, you might receive the following error message:
The text you entered isn't an item in the list.
Select an item from the list, or type the text that matches one of the listed items.
However, the new record is successfully added to the table. As a result, the new item that you entered is added to the list of items in the combo box.
This problem occurs when the combo box is bound to a Number data type column and the format property for the column is set to Currency or to Euro.
To work around this problem, type the value in the combo box that matches the format of the column that the combo box is bound to. For example, if the format of the column is Currency, type $20 instead of 20.
However, if the format of the column is set to Euro, you might not be able to enter a number that matches the format of the column.
If you reset the Format property of the column, the problem does not occur.
You might also receive the error message when you type a number that corresponds to an item in the combo box that already exists. This problem might occur if the number that you type does not match the formatted entries of the underlying recordset that already exists.
Steps to reproduce the behavior in Microsoft Office Access 2003
Start Microsoft Access.
Create a new Db1.mdb database.
To create the required sample table, follow these steps:
- In the Database window, click Tables under Objects.
- In the right pane, double-click Create table in Design view.
- In the first row of the Field Name column, typeID, and then set the corresponding Data Type to AutoNumber.
- In the second row of the Field Name column, typeRates, and then set the corresponding Data Type to Number.
- In the Field Properties pane, click the General tab.
- Set the Format property to Currency.
- On the File menu, click Save.
- In the Save As dialog box, type Rates, and then click OK.
- On the File menu, click Close.
In the Database window, click Forms under Objects.
In the right pane, double-click Create form in Design view.
Add a ComboTest combo box to the form, and then set the properties as follows:
Property Value Name: ComboTest Bound Column: 1 RowSourceType: Table/Query Row Source: SELECT Rates.ID, Rates.Rates FROM Rates; Auto Expand: Yes Limit to List: Yes Column Count: 2 Column Widths: 0";1"
On the View menu, click Code to open the Microsoft Visual Basic Editor.
Paste the following code in the NotInList event of the ComboTest combo box.
The sample code in this article uses Microsoft Data Access Objects. For this code to run correctly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.
Dim Db As DAO.Database Dim Rs As DAO.Recordset Dim Msg As String Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr Msg = Msg & "Do you want to add it?" If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then Response = acDataErrContinue MsgBox "Try again." Else Set Db = CurrentDb Set Rs = Db.OpenRecordset("Rates", dbOpenDynaset) Rs.AddNew Rs![Rates] = NewData Rs.Update Response = acDataErrAdded End If
On the File menu, click Save.
In the Save As dialog box, type FormTest, and then click OK.
On the File menu, click Close.
In the right pane of the Database window, double-click FormTest.
Type a number in the combo box, and then press the ENTER key.
The NotInList event is triggered. You receive the error message that is mentioned in the "Symptoms" section of this article.
For more information about the NotInList event, click Microsoft Access Help on the Help menu, type NotInList Event in the Office Assistant or the Answer Wizard, and then click Search to view the topic.