23

Creating Select Queries

Select queries are the most common type of query used in an Access database. A Select query simply gathers a group of records but does not modify them in any way. Select queries are often used as the record source for forms, reports, and other queries, and in addition, many built-in VBA functions and macros can use Select queries as their record source. Select queries are an everyday part of life in an Access database application.

Single-table queries are the simplest of Select queries. Adding tables to the query, using joins to link one table to another, creates more complex queries by using the power of a relational database. Adding criteria, or parameters, to a query limits the records returned. Queries can also have parameters to serve several purposes: to return single records only, to return a range of records, and to exclude records that meet specific criteria. Access's built-in functions, as well as user-defined functions, can be added to queries by creating a Calculated field.

Writing SQL statements without the assistance of a wizard or the graphical user interface is also permitted in Access using SQL View mode. Writing SQL code directly allows for the greatest amount of control on how the query is formed. In fact, using the SQL View mode is the only way Union queries can be written. Regardless of the method you use to build your Select queries, Access 2010 makes it very simple.

LESSON SETUP

For this lesson you need Access 2010 and the Lesson ...

Get Microsoft® Access® 2010 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.