I have a continuous form that I would like to be able to filter, not too unlike a table, using combo boxes for two of the fields.
So far I have been able to make one filter work with a field that only has a couple options using the following as the On Change event:
Code:
Private Sub RoomFilter_Change()
If Me.RoomFilter = "Flower" Then
DoCmd.ApplyFilter , "[RoomName]='Flower'"
ElseIf Me.RoomFilter = "Current Flower" Then
DoCmd.ApplyFilter , "[RoomName]='Current Flower'"
End If
End Sub
I also have a button to remove all filters and clear both combo box values.
The second combo box has 80 or so options and I have tried a few variations of the following with no luck:
Code:
Private Sub StrainFilter_Change()
Me.Filter = "StrainName ='" & Me.StrainFilter & "'"
Me.FilterOn = True
End Sub
When I try using the second combo box, all records are filtered out so nothing is displayed. I have also tried using DoCmd.ApplyFilter ,"StrainName ='" & Me.StrainFilter & "'" with the same result.
I am also assuming that I will have to somehow combine the events so that when one is changed, it adds the second filter to the first like you can do on a table.
I don't know much about VBA (though looking for classes/books) so I could use all the help I can get.