MS Access Form Filter property

MS Access Form Filter property

MS Access Form Filter property

The Filter property of forms in MS Access allows you to specify a subset of records to be displayed when a filter is applied to a form. This is useful for displaying only the data that you want to see. To turn the filter on or off, you can use the form’s FilterOn property. When a filter is applied, only the records that meet the criteria will be displayed in the form. Additionally, you can use the KeyUp event to create a filter based on a control in the form.

The Filter property is a string expression consisting of a WHERE clause without the WHERE keyword. For example, the following Visual Basic code defines and applies a filter to show only customers from the USA.

				
					Me.Filter = "Continent = '" & strX & "'"
Me.FilterOn = True
				
			

In our downloadable file, we combined both of the IF condition with Form Filter Property. The IF condition, however, evaluates the conditions in the order listed. It will execute the corresponding code when a condition is found to be true. If no condition is met, then the Else portion of the IF-THEN-ELSE statement will be executed.

				
					Dim strX As String
strX = Me.cboContinent
If strX <> "" Then
    Me.Filter = "Continent = '" & strX & "'"
    Me.FilterOn = True
Else
    Me.Filter = ""
    Me.FilterOn = False
End If
				
			

Please visit our Pro Products here.

The content of our example has the list of all countries by continents.
Source of the content: https://simple.wikipedia.org/wiki/List_of_countries_by_continents