4. MICROSOFT ACCESS QUERIES
4.1: Simple Query
The simplest query is one that displays a complete table – all rows and columns. Suppose we want to list all books in the library. The process of creating the query is as follows:
-
-
- Click on the Create tab if necessary and then click on the Query Design icon; then:
- drag the Book table from the Tables panel into the Relationships area, or,
- right-click in the Relationships area and choose the Show Table. Double-click Book.
-
MS Access displays the Book table and its fields in the Relationships area. The first in this list is an * which stands for all attributes – double-click the *. Note the contents of the Grid area:
You can run a query when using Query Design view. If the Run button is not visible, click the “Design” tab. Now, to run the query, click the “Run” button in the “Results” button group:
There are other views of a query. If you click the drop-down just below View:
You can see all the ways of viewing a query, including:
-
-
- Datasheet View
- Design View
- SQL View.
-
You can run a query by choosing Datasheet View. When developing a query, one often alternates between Datasheet View and Design View to get the query working as required. When you run a query, MS Access will retrieve the information requested. Our results of running the query are:
You can save the query: right-click the name and then give the query a new name:
Now, provided you have selected ‘All Access Objects’ you will see the query as a database object. See figure 4.8b.
The query can be run any time by an end user. The results of the query are not stored or saved – only the definition of the query. Whenever a user runs the query the current contents of the Book table are accessed.