• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 23. Working with Structured Quer... > Using SQL Statements in Forms, Repor...

Using SQL Statements in Forms, Reports, and Macros

If you create many forms and reports based on queries or that use queries, or if you use macros to run Select and Action queries, the query list in your Database window can become cluttered. You can use SQL queries you write or copy from the SQL dialog in place of the names of query objects and then delete the query from your database. You can use SQL statements for the following purposes:

  • Record Source property of forms and reports. Substitute the SQL query text for the name of the query in the Record Source text box.

  • Row Source property in lists and drop-down combo lists on a form. Using an SQL statement rather than a query object gives you greater control over the sequence of the columns in your list.

  • Value of the SQL property of a QueryDef object or the strSource argument of the OpenRecordset method in Access VBA code. You use SQL statements extensively as property and argument values when programming applications with Access VBA, especially for SQL pass-through queries.

  • Source property of an ADODB.Recordset object specified as the Record Source property of a form or report. The capability to bind Access form and report objects to ADO Recordsets is a very important new feature of Access 2000.

  • Argument of the RunSQL() macro action. Only SQL statements that create action queries can be used with the RunSQL() macro action. Using macros is strongly discouraged in Access 2000.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint