ACC2000: Four Ways to Move to a Record from a Combo Box SelectionID: Q209537
|
This article shows you four methods of moving to a specific record
based on a combo box selection. The methods are as follows:
Microsoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.aspCAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.
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
NOTE: These methods can also apply to text boxes.
Sub ComboNN_AfterUpdate()
'Find the record that matches the control.
Me.RecordsetClone.Findfirst "[ProductID] = " & Me![ComboNN]
Me.Bookmark = Me.RecordSetClone.Bookmark
End Sub
[ProductName] = Forms![frmComboTest]![cboLookup]
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
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
NOTE: Include at least the ProductID field on the new form. However, additional fields may help to illustrate that you have changed records based on the value selected in the combo box.
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
For more information about AutoLookup queries, click Microsoft Access Help on the
Help menu, type "AutoLookup" in the Office Assistant or the Answer Wizard,
and then click Search to view the topic.
For more information about referencing controls, click Microsoft Access Help on the
Help menu, type "referencing controls" in the Office Assistant or the Answer Wizard,
and then click Search to view the topic.
For more information about using the control wizard to find a record, click Microsoft Access Help on the
Help menu, type "Find a record by selecting a value from a list" in the Office Assistant or the Answer Wizard,
and then click Search to view the topic.
For more information about how to use the Filter By Form technique, click Microsoft Access Help on the
Help menu, type "Filter By Form" in the Office Assistant or the Answer Wizard,
and then click Search to view the topic.
Additional query words: Auto lookup forms text box move
Keywords : kbusage kbdta FmsCmbo
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 13, 1999