ACC: How to Sort Form Records Using Field Names from Combo BoxID: Q153579
|
Moderate: Requires basic macro, coding, and interoperability skills.
This article describes how to sort the values on a form based on field
names that you select from a combo box.
To use this method, you create a form based on a table or query. You then
create a combo box whose row source is a value list containing the field
names to be used for sorting the records on the form. The record source for
the form is an SQL statement that sorts the data on the form based on the
values selected in the combo box. The AfterUpdate event of the combo box
contains a procedure that requeries the record source of the form each time
that you select a different field to sort by. This example uses the
Customers table from the Northwind sample database.
Select * From Customers Order By '["& Me!cboLookup &"]';
Sub cboLookup_AfterUpdate()
Me.RecordSource = "Select * From Customers ORDER By _
[" & Me!cboLookup & "];"
End Sub
For more information about the AfterUpdate event, search the Help Index for "AfterUpdate," or ask the Microsoft Access 97 Office Assistant.
Additional query words: Sort Field Names Combo Box howto
Keywords : FmsCmbo
Version : 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 23, 1999