About working with SQL in queries, forms, reports, macros, and modules

About working with SQL in queries, forms, reports, macros, and modules

You can use SQL, or Structured Query Language, to query, update, and manage relational databases such as Microsoft Access. When you create a query in query Design view, behind the scenes Microsoft Access constructs the equivalent SQL statements. You can view or edit the SQL statement in SQL view. After you make changes to a query in SQL view, the query might not be displayed the way it was previously in query Design view.

Some queries can't be created in the design grid. For pass-through, data-definition, and union queries, you must create SQL statements directly in SQL view.

You can also use SQL statements in many places in Microsoft Access where you can enter the name of a table, query, or field. In some cases, Microsoft Access fills in the SQL statement for you. For example, when you use a wizard to create a form or report that gets data from more than one table, Microsoft Access automatically creates an SQL statement that it uses as the setting for the RecordSource property of the form or report. When you create a list box or combo box with a wizard, Microsoft Access creates the SQL statement and uses it as the setting for the RowSource property of the list box or combo box. You can also use SQL statements in subqueries in the query design grid, in the SQL Statement argument of the RunSQL macro action, and in code.

Return to Work with SQL in queries, forms, reports, macros, and modules