ACC: Sorting/Grouping a Query Using a Portion of Field's ValueID: Q88927
|
Novice: Requires knowledge of the user interface on single-user computers.
You can sort or group a query by using only a portion of a field's value.
This technique is useful if a field contains values with a set number of
leading or trailing characters that are insignificant to your sorting task.
An example of this might be a part number field that contained the following values:
A-453-34567
A-123-45675
B-234-75658
B-645-65759 and so forth
To demonstrate how to sort or group a query by using only a portion of a
field's value, this article uses the sample database Northwind.mdb to create
a query based on the Employees table. The query uses the Mid() function to sort
by six characters beginning with the fourth character in the LastName field. You
could also use the Left() and Right() functions to return characters from the left
or from the right side of a string argument.
NOTE: A demonstration of the technique used in this article can also be
seen in the sample file, Qrysmp97.exe. For information about how to obtain
this sample file, please see the following article in the Microsoft
Knowledge Base:
Q182568 ACC97: Microsoft Access 97 Sample Queries Available on
MSL
The following procedure explains how to use the Mid() function to sort
data by using only a portion of a field's value:
A-453-34567
A-123-45675
B-234-75658
B-645-65759 and so forth
Expr:MID([PartNo]),3,3)
For more information about string functions and related functions, search the Help Index for "String function," "Left function," "Right function," and "Len function."
Keywords : kbusage QryOthr
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 21, 1999