我有一个报告设置,其中包含一个选择查询的记录源。
我要在表单上为每个经理设置一系列按钮,按下这些按钮将打开报表,并将选择查询条件设置为经理名称。
按下按钮时,我有:
Dim MgrName As String
MgrName = "Smith"
Call Testfunction (MgrName)
DoCmd.OpenReport "R_Test_Logout_10", acViewReport
也:
Public Function TestFunction(MgrName)
If MgrName = "Smith" Then
TestFunction = "Smith, Joe"
End If
End Function
当我尝试将TestFunction
放入选择查询的条件中时,如果输入的参数数量错误,或者输入为:
TestFunction (MgrName)
...自动将引号插入到:
TestFunction ("MgrName")
答案 0 :(得分:0)
将WhereCondition
参数用作DoCmd.OpenReport
方法。
例如,您可以定义一个函数,例如:
Function OpenMyReport(strMgr As String)
DoCmd.OpenReport "R_Test_Logout_10", acViewReport, , "Manager = '" & strMgr & "'"
End Function
(假设您的报告的记录源包含一个名为Manager
的字段)
然后从事件处理程序中为每个按钮的On Click
事件调用上述函数,例如:
Private Sub MyButton_Click()
OpenMyReport "Smith, Joe"
End Sub