Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

MS Access parameter query


May 16, 2021 MS Access


Table of contents


The best part about a query is that you can save and run the same query over and over again, but when you run the same query again by changing only the conditions, you can consider the query accepting parameters.

  • If you often need to run variants of a particular query, consider using parameter queries

  • Parameter queries retrieve information interactively, prompting end users to provide standards before running the query.

  • You can also specify the type of data that the parameters should accept.

  • You can set data types for any parameter, but it is especially important to set data types for numbers, currencies, or date/time data.

  • When specifying the type of data that parameters should accept, users see more useful error messages if they enter the wrong type of data, such as text when currency is required.

  • If the parameter is set to accept text data, any input is interpreted as text and no error message is displayed.

Example

Now let's take a look at a simple example by creating a parameter query. L et's open the database and select the query design in the Create Table tab.

MS Access parameter query

Double-click tblProjects and close the Show dialog box.

MS Access parameter query

Select the field you want to view as the result of the query, as shown in the following screenshot.

MS Access parameter query

In the query design grid, in the conditional row of the ProjectStart column, type Enter Project Start Data. b21> , Enter Project Start Data , is your parameter prompt. ay. Enter item start data parameter prompt display.

MS Access parameter query

Now let's run the query, and you'll see the following tips.

MS Access parameter query

Now let's enter the following date.

MS Access parameter query

Click OK to confirm.

MS Access parameter query

Therefore, you will see details of the project starting on February 1, 2007. Let's go to the design view and run the query again.

MS Access parameter query

Enter the date in the screenshot above, and then click OK. You will now see details of the project starting from 5/1/2008.