PARAMETERS Declaration (SQL Only)
See Also Example
For queries that you run regularly, you can use a PARAMETERS declaration to create a parameter query A parameter query can help automate the process of changing query criteria. With a parameter query, you can set new values for the parameters each time the query is run.
In the Professional Edition only, you can set QueryDef parameters with the following syntax:
querydef ! parametername = parametertext
The PARAMETERS declaration is optional but when included precedes any other statement, including SELECT.
You use the following syntax to declare a parameter:
PARAMETERS parametertext datatype
The argument parametertext is the name of the parameter you use in the SQL statement Use brackets to enclose text that contains spaces or punctuation. For example, [Low price] and [Begin report with which month?] are valid entries for parametertext.
The argument datatype is the parameter's field data type
If the declaration includes more than one parametertext-datatype pair, separate them with commas. The following example includes two parameters:
PARAMETERS [Low price] Currency,
[Beginning date] DateTime
You can use parametertext but not datatype in places such as a WHERE or HAVING clause. The following example requires that your program supply two parameters and then applies the criteria to records in the Orders table:
PARAMETERS [Low price] Currency, [Beginning date] DateTime;
SELECT [Order ID], [Order Amount]
FROM Orders
WHERE [Order Amount] > [Low price]
AND [Order Date] >= [Beginning date]