Use query Design view to generate an SQL statement to paste elsewhere
You can use SQL statements and clauses in many expressions, as arguments of procedures, and as property settings. For example, you can use an SQL statement to set the RowSource property of a list box in a form or report to generate a list of items.
- In query Design view, create the query from which you want to generate the SQL statement.
- Click the arrow next to the View button on the toolbar, and then click SQL View.
- Select all or part of the SQL statement, and then press CTRL+C to copy the selected text onto the Clipboard.
- Place the insertion point where you want to paste the SQL statement, such as in a property box or in the Code window of the Visual Basic Editor.
- Press CTRL+V.
Notes
- You can create or edit a query in SQL view instead of Design view. To do so, switch to SQL view and type or modify the SQL statement for your query. If you then switch back to Design view, the SQL statement will be represented in the design grid.
- Most query properties in the property sheet in query Design view have equivalent clauses and options available in SQL view.
- If you use a wizard to create a form, report, or data access page based on more than one table or to create a list box or combo box, Microsoft Access automatically creates an SQL statement to use as the record source for the form, report, or page or the row source for the list box or combo box. Without using a wizard, you can generate an SQL statement for the RecordSource or RowSource properties by clicking the Build button next to either of these properties, and then creating a query in query Design view.
- You can't use the design grid to create SQL-specific queries. For these types of queries, you must use SQL view. For more information, click .