Table of contents
TOC
折叠目录
展开目录

Report.InputParameters 属性 (访问)Report.InputParameters Property (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

您可以使用输入参数属性可以指定或确定传递给窗体或报表或存储的过程时使用 Microsoft Access 中的记录源的记录源属性中的 SQL 语句的输入的参数项目 (.adp)。读/写,字符串You can use the InputParameters property to specify or determine the input parameters that are passed to a SQL statement in the RecordSource property of a form or report or a stored procedure when used as the record source within a Microsoft Access project (.adp). Read/write String.

语法Syntax

表达式输入参数expression. InputParameters

表达式_一个表示报表对象的变量。_expression A variable that represents a Report object.

注解Remarks

如果使用记录源属性:When used with a RecordSource property:

使用的记录源属性中的 SQL 语句的示例输入参数属性字符串将使用以下语法。An example InputParameters property string used with a SQL statement in the RecordSource property would use the following syntax.

state char=[Forms]![formname]![StateList], salesyear smallint=[Forms]![formname]![Enter year of interest]state char=[Forms]![formname]![StateList], salesyear smallint=[Forms]![formname]![Enter year of interest]

该语法会将状态参数设为“状态列表”控件的当前值,并提示用户输入 salesyear 参数。如果有不在该列表中的其他参数,将为这些参数指定默认值。This would result in the state parameter being set to the current value of the StateList control, and the user getting prompted for the salesyear parameter. If there were any other parameters that were not in this list, they would get default values assigned.

应使用一个执行查询?在输入参数列表中的每个非默认参数的标记。The query should be executed with one ? marker for each non-default parameter in the InputParameters list.

刷新或重新查询命令 (通过菜单、 键盘或导航栏),access 将触发查询的重新执行。用户可执行此操作的代码通过调用标准的记录集Requery方法。如果参数值与窗体上的控件绑定,在重新查询时使用控件的当前值。当控件的值发生更改时,不自动重新执行查询。A refresh or requery command (via menu, keyboard, or Navigation Bar) in Access should trigger a reexecute of the query. Users can do this in code by calling the standard Recordset. Requery method. If the value of a parameter is bound to a control on the form, the current value of the control is used at requery time. The query is not automatically reexecuted when the value of the control changes.

当使用存储过程时:When used with a stored procedure:

与存储过程一起使用的示例输入参数属性字符串是:An example InputParameters property string used with stored procedure would be:

@state char=[Forms]![formname]![StateList], @salesyear smallint=[Forms]![formname]![Enter year of interest]@state char=[Forms]![formname]![StateList], @salesyear smallint=[Forms]![formname]![Enter year of interest]

该语法会将 @state 参数设为“状态列表”控件的当前值,并且提示用户输入 @salesyear 参数。如果有其他传递给存储过程的参数不在列表中,将为这些参数指定默认值。This would result in the @state parameter being set to the current value of the StateList control, and the user getting prompted for the @salesyear parameter. If there were any other parameters to the stored proc that were not in this list, they would get default values assigned.

应使用包含其中一个的 {call} 语法的命令字符串执行该存储的过程?在输入参数列表中的每个非默认参数的标记。The stored procedure should be executed using a command string containing the {call } syntax with one ? marker for each non-default parameter in the InputParameters list.

刷新或重新查询命令 (通过菜单、 键盘或导航栏),在访问中的应触发存储过程的重新执行。用户可执行此操作的代码通过调用标准的记录集Requery方法。如果参数值与窗体上的控件绑定,在重新查询时使用控件的当前值。当控件的值发生更改时,不自动重新执行存储的过程。A refresh or requery command (via menu, keyboard, or Navigation Bar) in Access should trigger a reexecute of the stored procedure. Users can do this in code by calling the standard Recordset. Requery method. If the value of a parameter is bound to a control on the form, the current value of the control is used at requery time. The stored procedure is not automatically reexecuted when the value of the control changes.

如果存储的过程具有参数第一次作为窗体的记录源选择存储的过程时,将调用此生成器对话框。首次创建输入参数字符串后, 此同一对话框更改字符串使用作为生成器。在这种情况下但是的参数列表来自已存在的字符串中。This builder dialog is invoked when a stored procedure is first selected as the record source of a form if the stored procedure has any parameters. After initial creation of the InputParameters string, this same dialog is used as a builder for changing the string. In this case however the list of parameters comes from what already exists in the string.

参数值也可设置在代码中使用 ActiveX 数据对象 (ADO)命令参数对象。如果结果返回结果集,可以将窗体绑定到它通过设置窗体的记录集属性。ADO 编码是处理不返回结果的存储的过程的唯一方法设置 (如操作查询),返回输出参数或返回多个结果集。Parameter values are also settable in code using the ActiveX Data Object's (ADO) Command and Parameter objects. If the result returns a result set, a form can be bound to it by setting the form's Recordset property. ADO coding is the only way to handle stored procedures that do not return result sets such as action queries, those that return output parameters, or those that return multiple result sets.

另请参阅See also

概念Concepts

报表对象Report Object

© 2018 Microsoft