ACC: How to Synchronize Two Combo Boxes on a FormID: Q97624
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article shows you how to synchronize two combo boxes so that
when you make a selection in the first combo box, the selection limits
the choices in the second combo box.
NOTE: This article explains a technique demonstrated in the sample
files, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0)
and FrmSmp97.exe (for Microsoft Access 97). For information about how
to obtain these sample files, please see the following articles in the
Microsoft Knowledge Base:
Q150895 ACC95: Microsoft Access Sample Forms Available on MSL
Q175066 ACC97: Microsoft Access 97 Sample Forms Available on MSL
The following example uses the sample database Northwind.mdb (NWIND.MDB in
earlier versions). The first combo box lists the available product
categories, and the second combo box lists the available products for the
category selected in the first combo box:
Query: Category Combo Query
---------------------------------------------------------
Table: Products
Type: Select Query
Field: ProductID (or Product ID in 1.x and 2.0)
Sort: Ascending
Show: Yes
Field: ProductName (or Product Name in 1.x and 2.0)
Table: Products
Show: Yes
Field: CategoryID (or Category ID in 1.x and 2.0)
Show: No
Criteria: Forms![Categories and Products]![Categories]
Combo Box 1
-------------------------------
Name: Categories
RowSourceType: Table/Query
RowSource: Categories
ColumnCount: 2
ColumnWidths: 0;1
BoundColumn: 1
AfterUpdate: Refresh Products
NOTE: The Name property is called the ControlName property in
Microsoft Access 1.x.
Combo Box 2
-----------------------------------
Name: Products
RowSourceType: Table/Query
RowSource: Category Combo Query
ColumnCount: 2
ColumnWidth: 0;1
BoundColumn: 1
Macro Name Actions
---------------------------
Refresh Products Requery
Action Arguments
----------------
Control Name: Products
Additional query words: listbox combobox link
Keywords : FmsCmbo
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: March 20, 1999