MS Access 2003 Step By Step - Asim Abbasi

CH1: Overview | CH2:  MS Access Local & Linked Tables | CH3:  MS Access Queries | CH4: MS Access Reports & Forms | CH5: MS Access Modules & Macros | CH6: MS Access Data Import/Export Feature | CH7: MS Access Built-In Functions

Chapter 4: MS Access Reports & Forms

Page #: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17


Step 4: Add Sort Order If Required

1. The Report Wizard then asks for Sorting of the report and the columns that it would be using for sorting purpose. Select the field/column you want to select for sorting purpose. By default it would be descending but if you want the ascending order then click the <Ascending> button.

2. Finally click the <Next> button.

The wizard provides the option of sorting uptill 4 fields. In real world this is more than enough as we seldom go beyond two and very rarely beyond 3 column sorting. Its very easy to understand one column sorting but lets have a look on what really meant with two or more columns sorting. This can be better explined with the help of following example.

Let’s suppose we have a table having FIRST_NAME and LAST_NAME fields. If we sort this table based on FIRST_NAME the information will look like as shown below.

But if you sort first by FIRST_NAME and then by LAST_NAME then the information will look like as shown below. Have a focus on persons having first name as David in both the cases.

Here is the bottom line whenever you have multiple column in the ORDER BY clause of the query, the output data will first get sorted based on the first column and if there are similar records in the first column then MS Access looks for the second column in the ORDER BY list to decide which records should be at first place.

While designing query under every field that you will select, there is a Sort option available. You can either have sorting order as Ascending or Descending. The ‘SQL View’ of the query shown above will look like as follows.

SELECT [My Test Table].FIRST_NAME, [My Test Table].LAST_NAME
FROM [My Test Table]
ORDER BY [My Test Table].FIRST_NAME;

If you select both fields in the sorting then the Design and SQL View will look like as shown below respectively.

SELECT [My Test Table].FIRST_NAME, [My Test Table].LAST_NAME
FROM [My Test Table]
ORDER BY [My Test Table].FIRST_NAME, [My Test Table].LAST_NAME;

To switch between Design and SQL view of the query, the starting point is View command on the menu bar. The View menu gives the Design as well as SQL view options for a query.

 

Chapter 4: MS Access Reports & Forms

Page #: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17

CH1: Overview | CH2:  MS Access Local & Linked Tables | CH3:  MS Access Queries | CH4: MS Access Reports & Forms | CH5: MS Access Modules & Macros | CH6: MS Access Data Import/Export Feature | CH7: MS Access Built-In Functions

Share with others: