ACC: How to Include a Null Selection in a Combo Box ListID: Q139039
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article demonstrates how you can include a blank row at the top
of a combo box list. This enables you to set the combo box's LimitToList
property to Yes, and still be able to delete the contents of the combo box
without triggering the NotInList event.
This feature is created by basing the contents of the combo box on
a union query that adds a null row to the top of the query.
To include a blank row at the top of a combo box, follow these steps.
CAUTION: Following the steps in this example will modify the sample
database Northwind.mdb (or Nwind.mdb in version 2.0 or earlier). You may
want to back up the Northwind.mdb (or Nwind.mdb) file and perform these
steps on a copy of the database.
Query: qryCustList
-------------------
Type: Select Query
Field: CustomerID
Table: Customers
Field: CompanyName
Table: Customers
Sort: Ascending
SELECT DISTINCTROW Customers.[CustomerID], Customers.[CompanyName]
FROM Customers
UNION SELECT Null, Null FROM Customers
ORDER BY Customers.[CompanyName];
NOTE: In Microsoft Access 2.0, type a space in the Customer ID and
the Company Name field names.
Form: Test1
------------------------------
Caption: TestForm
Combo box:
Name: cmbTest
RowSourceType: Table/Query
RowSource: qryCustList
LimitToList: Yes
Text Box:
Name: Field1
The text you entered isn't an item in the list.
The text you enter must match an entry in the list.
For more information about union queries, type "Union Query," in the Office Assistant, click Search, and then click to view the appropriate topic.
Additional query words: kbhowto delete combo box notinlist
Keywords : kberrmsg FmsCmbo
Version : 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 23, 1999