Microsoft Access 2010 Bible

(Rick Simeone) #1

Part II: Programming Microsoft Access


474


comply with ANSI SQL-92 (the generally accepted specification for SQL language implementa-
tions), Access SQL shares many similarities with all SQL implementations. Your Access SQL state-
ments run with very few changes in SQL Server or many other database systems.

Although forms and reports do have the ability to work with queries that are stored in an Access
database, many times you’ll find that creating a query on the fly in your code is quicker, easier, and
more flexible than working with Access queries. SQL is relatively easy to understand and work
with. This is a quick overview of SQL statements and how to create them in Access.

Viewing SQL statements in queries
To view the SQL statement that Access creates while building a query, choose View ➪ SQL View from
the tab on the Access ribbon. Figure 13.1 shows a typical SQL statement that returns the product
description, company name, and state for products purchased by contacts in Connecticut or New York.

Don’t be put off by the apparent complexity of the SQL statement in Figure 13.1. The same query
in Design view is shown in Figure 13.2. As you can see, the Access Query Designer hides much of
the complexity of the underlying SQL statement.

FIGURE 13.1

The SQL statement behind the qryProductsSold_NY_CT query in the SQL view window


FIGURE 13.2

The same query in Design view

Free download pdf