An Access Problem:How to combine delete filter on columns permanently
I have 12 colomns in my Access 2010 form, now I want to re开发者_如何学Pythonmove all the filters on the columns so that user is not able to filter records. I want user to only filter from combo box, how can i do this?
Seems two me there are two parts to your question:
- Discard or ignore any existing filters
- Prevent the user from any filtering
For the first, you can use this to ignore any existing filters.
Me.FilterOn = False
For the second, you can set the form's Allow Filters property to No.
Then you can accomplish your filtering by using the combo's after update event to revise the form's Record Source.
Dim strSql As String
strSql = "SELECT field1, field2, field3 FROM YourTable WHERE some_field = " & _
Me.YourComboName
Me.RecordSource = strSql
Re-assigning the RecordSource will automatically force a requery.
That would work if the bound value of YourComboName is numeric. If its text data, you will have to enclose its values with quotes when you build strSql.
strSql = "SELECT field1, field2, field3 FROM YourTable WHERE some_field = """ & _
Me.YourComboName & """"
精彩评论