Working with databases/Create a database/Records and tables

From WikiEducator
Jump to: navigation, search
OtagoPoly Logo S.png




Sort a table

We can sort a table - that is, we sort the records into numeric or alphabetical order.



OP icon activity.gif

Activity

Please note: the following tutorial will open in a new window/tab. When you have finished the tutorial, simply close the window/tab and you'll return to this page.

Before you go on, please work through the following tutorial:

  • Sorting Records





Access-sort1.png

In the heading row that contains the field names, locate the small black triangle. Click on this.

A menu will pop up. From the menu choose how you would like to sort your table: Sort A ⇒ Z or Z ⇒ A. This also works in fields that contain numerical data.

Although you will not be assessed on this, you can also use this menu to filter out and display only certain information. In our example we could choose to display only students from Glenfield.

The same principle applies to sorting a query (You will learn how to create a simple query later on) which is displayed on the screen like a table.

To clear and reset sorting, go to Home Tab ⇒Sort and Filter Group ⇒Clear All Sorts




OP icon activity.gif

Activity

  1. Open your bookshop database, and open the table that you have created
  2. Using what you have covered above, sort your table by book title, A ⇒ Z.

We are going to print your sorted table:

  • In Office 2007 open the Office Button, then click on Print.
  • In Office 2010 click on the File tab, then click on Print.

Tables that are very wide may be best printed in Landscape Format.

  1. Once you have printed your table, clear all sorting from your table.
  2. Now sort your table by year published, Z ⇒ A.
  3. Print your new sorted table.






OP icon exclamation.gif

Please note

Can we edit or change a table once it has data in it?

Yes you can, but with a few provisos:

  • You can safely add and edit a new field to an existing table.
  • You can delete a field, but you may break anything that relies on this field being there.
  • You can edit a field and change its properties or data-type, but you most likely will lose all information stored in that field across all records.





OP icon activity.gif

Activity

We are going to add a new field into our table called Book in Stock. This will be a Yes/No type field. Every time we sell a book we will untick this field. This way we can reorder new copies of popular books and indicate that we have them without having to delete and re-enter data all the time.

  1. Open your database.
  2. Open the table and change to Design View.
  3. Enter in the new field details at the end of the list of fields displayed. If you are unsure how to do this, you might want to review the section on Table design
  4. In the Field Properties pane, change the default value from 0 (zero) to 1 (one). This will make Access automatically tick the box for you when you enter in new books.

    Access-defaultvalue.png

  5. Check your database to make sure that Book in Stock is ticked for all books except for ones on order.
  6. Please add the following 3 new book titles to our database:

    Access-addmore.png

  7. Please check your database against your source information.