Create a parameter query that gets criteria from a custom dialog box
You can use a custom dialog box to enter criteria for the query underlying a form, report, or Web page. For example, a custom dialog box can determine what records a printed report includes.
- Create or open the query that will collect its criteria values from the dialog box.
- Make sure that the query includes the tables you want to use.
- Add to the query design grid the fields associated with each of the dialog box controls where you'll enter criteria values. For each of these fields, enter an expression in the Criteria cell that tells Microsoft Access to refer to the control on the dialog box for the criteria values. If you need help creating the expression, use the Expression Builder. For more information, click .
- Add to the query design grid the fields whose values you want returned.
For example, you could create a dialog box form named Customer Info with a control for the CustomerID field. By entering a customer ID in the dialog box, you could have the query return the correct customer's company name, address, and city. To create this query, you'd do the following:
- Add the CustomerID field to the query design grid. In its Criteria cell, enter the expression that tells Microsoft Access to refer to the Customer ID control in the dialog box for the criteria values the query uses. In this case, you'd enter the expression Forms![Customer Info]![CustomerID].
- Add to the query design grid the fields whose values you want returned based on the CustomerID value: CompanyName, Address, and City fields.
To read more about using forms to collect and display information, see "Using Forms to Collect, Filter, and Display Information" in Building Applications with Forms and Reports.