使用组合框选择要筛选报表的列



我是Access的初学者。我有几个是/否字段的查询。我有一个带有组合框的表单,其中列出了Yes/No字段的名称。我想制作一个基于查询的报告,该查询由组合框中选择的列过滤。换句话说,如果在组合框中选择了"column1",报告应该只显示column1 = True的记录。

理想情况下,我可以在报告的Filter属性中输入一些东西,并使用Filter On Load,但任何可行的方法,我都很感激。

我使用Access 2010

在DoCmd.OpenReport中使用 whereconcondition 参数。

例如,从包含组合框的表单上的命令按钮的click事件中,您可以这样做…

Dim strWhereCondition As String
strWhereCondition = "[" & Me!YourComboNameHere.Value & "]=True"
Debug.Print strWhereCondition '<- view this in Immediate window; Ctrl+g will take you there
DoCmd.OpenReport "YourReportName", WhereCondition:=strWhereCondition

最新更新