Yes you can do this, it all depends though on how your form is displaying in the data. I'm thinking your using data bound controls, in which case there are a number of ways to do it.
The easiest way is to apply the filter to the form. If you look at the properties of your form, under the data tag, you will see a Filter property. You need to set this to a filter expression in order to filter the records. A filter expression is like this '[Field] = value'. You also need to specify if the filter is on or off.
For example, I have a form thats bound to a table Customer, the form displays the tables [CustomerID] field. To filter by this field on the form I create a button and place this in its event handler.
Private Sub cmdFilter_Click()
Me.Filter = "[CustomerID] = 'ALFKI'"
Me.FilterOn = True
You can change the ALFKI to an variable, be sure that the filter matches the data type of the field, for example CustomerID is a text field and so the filter expression needs to be wrapped in single quotes.