Article ID: 100132
Article Last Modified on 1/18/2007
Method 1: In the AfterUpdate property of the combo box, call a macro
using the FindRecord action.
Method 2: In the AfterUpdate property of the combo box, call a macro
using the ApplyFilter action.
Method 3: Use a Form/Subform, with the combo box in the main form and
the data in the subform, bound by the LinkMasterFields and
LinkChildFields properties.
Method 4: Base the form on a query that joins two tables and bind the
combo box to the field that controls the join, using the
AutoLookup technique.
Method Number: 1 2 3 4 --------------------------------------------- Requires no code/macros x x Saves on subforms x x x Can scroll to other records x x x Does not require a query x x x Can edit records x x x
Sub ComboNN_AfterUpdate()
'Find the record that matches the control.
Me.RecordsetClone.Findfirst "[ProductID] = " & Me![ComboNN]
Me.Bookmark = Me.RecordSetClone.Bookmark
End Sub
Text Box
------------------------
ControlName: ProductID
ControlSource: ProductID
Visible: Yes
Combo Box
------------------------------
ControlName: cboLookup
ControlSource: <leave blank>
RowSourceType: Table/Query
RowSource: Products
ColumnCount: 4
ColumnWidths: 0";2"
BoundColumn: 1
After Update: mcrLocateProduct
Macro Name Action
-----------------------------
mcrLocateProduct GoToControl
FindRecord
mcrLocateProduct Actions
---------------------------
GoToControl
ControlName: [ProductID]
FindRecord
Find What: =cboLookup
Find First: Yes
Combo Box
----------------------------------------------
ControlName: cboLookup
ControlSource: <leave blank>
RowSourceType: Table/Query
RowSource: Select [ProductName] from Products;
BoundColumn: 1
ColumnWidths: 1"
AfterUpdate: mcrLocateProduct
Macro Name Action
----------------------------
mcrLocateProduct SetValue
Requery
mcrLocateProduct Actions
--------------------------------------
SetValue
Item: Forms![frmComboTest].FilterOn
Expression: True
Macro Name Action
-------------------------------
mcrLocateProduct ApplyFilter
mcrLocateProduct Actions
-----------------------------------------------------
ApplyFilter
Where:[ProductID]=Forms![frmComboTest]![cboLookup]
Combo Box
----------------------------
ControlName: cboLookup
ControlSource: <leave blank>
RowSourceType: Table/Query
RowSource: Products
ColumnCount: 4
ColumnWidths: 0";2"
BoundColumn: 1
Text Box
------------------------
ControlName: ProductID
ControlSource: ProductID
Visible: Yes
Subform
----------------------------
LinkChildFields: [ProductID]
LinkMasterFields: cboLookup
Query: qryProductSelect
-----------------------------------------------
Field: ProductID
Table Name: tblProductSelect
Show: X (checked on)
Field: <any other fields you are interested in>
TableName: Products
Combo Box
--------------------------
ControlName: ProductID
ControlSource: ProductID
RowSourceType: Table/Query
RowSource: Products
ColumnCount: 1
ColumnWidths: 2"
BoundColumn: 1
Additional query words: Auto lookup forms text box move
Keywords: kbfaq kbhowto kbusage KB100132