Lesson 18 of 50 – Sorting Records in MS Access
36%

Sorting Records in MS Access

Sorting records means arranging data in a particular order. In Microsoft Access, you can sort records alphabetically, numerically, or by date. Sorting makes it easier to find and understand information stored in a table or query.

1. What Is Sorting?

Sorting is the process of arranging records according to the values in one or more fields.

For example, a Students table may contain these records:

StudentID StudentName Course Fees
103 Rahul ADCA 10000
101 Amit Tally Prime 4000
102 Priya Web Development 12000

If you sort the StudentName field in ascending order, the records will appear as Amit, Priya, and Rahul.

2. Types of Sorting

Ascending Order

Ascending order arranges values from smallest to largest or alphabetically from A to Z.

  • Numbers: 10, 20, 30, 40
  • Names: Amit, Priya, Rahul
  • Dates: Oldest to newest
Descending Order

Descending order arranges values from largest to smallest or alphabetically from Z to A.

  • Numbers: 40, 30, 20, 10
  • Names: Rahul, Priya, Amit
  • Dates: Newest to oldest
Sorting Type Meaning Example
Ascending Smallest to largest / A to Z 100, 200, 300
Descending Largest to smallest / Z to A 300, 200, 100

3. How to Sort Records in Datasheet View

Follow these steps to sort records in a table:

  1. Open your MS Access database.
  2. Open the table in Datasheet View.
  3. Click any cell in the field you want to sort.
  4. Open the Home tab on the ribbon.
  5. In the Sort & Filter group, select Ascending or Descending.
  6. Access rearranges the records according to the selected field.
Example: Click a cell in the StudentName column and choose Ascending to arrange student names from A to Z.

4. Sorting Numbers and Dates

Sorting Numbers

If you sort a numeric field such as Fees in ascending order, the lowest fee appears first.

StudentName Fees
Amit 4000
Rahul 10000
Priya 12000
Sorting Dates

Sorting a Date/Time field in ascending order displays earlier dates first. Descending order displays later dates first.

Make sure the field uses the appropriate Number, Currency, or Date/Time data type so Access sorts the values correctly.

5. Sorting by Multiple Fields

Sometimes, sorting by one field is not enough. You may want to sort students first by Course and then by StudentName.

Example

Suppose you want students grouped by course and names arranged alphabetically within each course.

  1. Open the table or query in Design View, or create a query.
  2. Add the Course and StudentName fields to the query grid.
  3. Set the Sort row for Course to Ascending.
  4. Set the Sort row for StudentName to Ascending.
  5. Run the query to see the sorted results.
Remember: In a query, the order of the fields and their sort settings determines how the results are sorted. A secondary sort is applied within groups formed by the primary sort.

6. How to Remove a Sort

You can remove the current sort when you want to return to the table's normal record order.

  1. Open the table or query in Datasheet View.
  2. Go to the Home tab.
  3. Find the Sort & Filter group.
  4. Click Clear All Sorts, or use the available clear-sort command in your Access version.

Clearing a sort removes the active sorting arrangement. It does not delete the records or change their field values.

7. Practical Assignment

Create a Students table containing these fields:

  • StudentID — AutoNumber
  • StudentName — Short Text
  • Course — Short Text
  • Fees — Currency
  • AdmissionDate — Date/Time
Tasks
  1. Enter at least five student records.
  2. Sort StudentName in ascending order.
  3. Sort StudentName in descending order.
  4. Sort Fees from lowest to highest.
  5. Sort AdmissionDate from oldest to newest.
  6. Create a query that sorts students by Course and then by StudentName.
  7. Clear the current sort.

Goal: Practice sorting text, numeric, and date values.

8. Revision Questions

  1. What is sorting in MS Access?
  2. What is ascending order?
  3. What is descending order?
  4. Which ribbon tab contains sorting commands in Datasheet View?
  5. How can you sort fees from highest to lowest?
  6. Why might you sort records using multiple fields?
  7. Does clearing a sort delete records?

🧠 Quick Quiz

1. What does ascending order mean for names?




2. Which command sorts numeric fees from highest to lowest?




3. What happens when you clear a sort?