A Query or a SQL Statement as a Record Source


A Query as a Record Source

When creating a form or a report that would be used to present data to the user, we selected a table as the source of data. In the same way, if you have created a query that holds some records, you can use it as the base of data for a form or report.

If you delete the form or report, the query would still exist because it is a separate object, but it would lose its data holder.


Using a SQL Statement as a Record Source

Instead of first formally creating a query before using it for a form or report, you can select the data from a table or a query and use it on the form or report. Behind the scenes, Microsoft Access would create the SQL expression that is directly applied to the form or report. Such a query is not saved as an object. This technique is used when you do not need a formal query as the base of data for a form or report.

There are various techniques you can use to create a query specifically made for a form or a report. You can start the Form Wizard or the Report Wizard. Then, in the first page of the wizard, select the Tables/Queries that holds the data, and complete the wizard. When you finish with the wizard, a SQL statement would be created for the form or report.

Alternatively, you can start by displaying a form or report in Design View. Then, in the Properties window, click Record Source and click its ellipsis button Ellipsis. In the Show Table dialog box, you can select a table or query, click Add and click Close. In the list of the Employees window, you can select the desired fields:

Then close the window. You would be asked to save, which you should do.

After creating the form or report, if you delete it (the form or the report), the expression would be lost also.


Home Copyright © 2008-2016, FunctionX, Inc.