ACC2: NotInList Event Is Not Triggered

ID: Q123867


The information in this article applies to:


SYMPTOMS

Advanced: Requires expert coding, interoperability, and multiuser skills.

The Access Basic code or macro specified in a combo box's OnNotInList property setting is not triggered when you enter a value in the combo box that is not in the combo box's list.


CAUSE

The NotInList event is triggered only if the value entered in the combo box cannot be uniquely associated with any item in the combo box's list, and if the combo box's LimitToList property is set to Yes.


RESOLUTION

Make sure the combo box's LimitToList property is set to Yes.

Also, check to see if the value you entered in the combo box can be uniquely associated with an item in the combo box's list. For example, assume a combo box with the following list:


   Beverages
   Condiments
   Confections
   Dairy Products 

If you type the letter "D" in the combo box, the "Dairy Products" item will be selected in the combo box and the NotInList event will not be triggered. If you type the letter "C" in the combo box, the NotInList event will be triggered, because "C" is not uniquely associated with an item in the list. If you type "COND" in the combo box, the "Condiments" item will be selected and the NotInList event will not be triggered.


STATUS

This behavior no longer occurs in Microsoft Access version 7.0.


MORE INFORMATION

Steps to Reproduce Behavior


  1. Open the sample database NWIND.MDB.


  2. Create a blank, new form. Add a combo box with the following properties to the form:
    
          RowSourceType: Table/Query
          RowSource: Categories
          ColumnCount: 2
          ColumnWidths: 0;1
          BoundColumn : 2
          LimitToList: Yes
          AutoExpand: No 


  3. Set the combo box's OnNotInList property to the following event procedure:
    
          Sub Field0_NotInList (NewData As String, Response As Integer)
             MsgBox "This item is not in the combo box."
          End Sub 


  4. View the form in Form view. Type CON in the combo box and then press the TAB key. The "This item is not in the combo box" message box appears as you expect.


  5. Type COND in the combo box and then press TAB. Note that "Condiments" is automatically selected in the combo box and that the NotInList event is not triggered.



REFERENCES

For more information about the OnNotInList property, search for "OnNotInList" then "OnNotInList Property" using the Microsoft Access Help menu.


Keywords          : kbusage FmsCmbo 
Version           : 2.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: April 8, 1999