Reputation: 35
I am a beginner with Access. I have a query with several Yes/No fields. I have a form with a combo box that lists the names of the Yes/No fields. I would like to make a report, based on the query, which is filtered by the column selected in the combo box. In other words, if "column1" is selected in the combo box, the report should only show records where column1 = True.
Ideally it would be something I could just enter in the Filter property of the report, and use Filter On Load, but anything that would work, I'd appreciate.
I'm using Access 2010.
Upvotes: 1
Views: 673
Reputation: 97111
Use the WhereCondition parameter with DoCmd.OpenReport.
For example, from the click event of a command button on the form which contains your combo box, you could do something like this ...
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
Upvotes: 1