Applying a filter to a form

Yippiekaiaii

Registered User.
Local time
Today, 20:41
Joined
Mar 25, 2013
Messages
21
Hello All.

I am having a problem with a filter that i am trying to apply to a subform.

I have a buttom on the form that when clicked should filter the subform (which is in datasheet view) to the criteria i set.

This criteria will eventually run from a combo box but I wanted to just get the filter working first.

I put the following code into the onclick event of the button:

Items.Form.Filter = "Items.Form.[Master Category] = 2"
Items.Form.FilterOn = True

I chose the criteria 2 for the filter just as a test as I knew there are some records with that value in the master category field.

The problem is when ever i click the button to apply the filter it clears all the data as if it has not found any records with that value.

Is my syntax and method OK?
Any idea why its filtering everything out?

The only other thing to consider is that the field I am filtering on was set up using a lookup wizard linked to a table so the values stored are a foreign key (hence the value being 2 rather than something descriptive)

Any help would be appreciated.
 
Try:
Items.Form.Filter = "[Master Category] = 2"
Items.Form.FilterOn = True
 
Thank you, that seems to have worked. Was it just a case of wrong syntax then?
 

Users who are viewing this thread

Back
Top Bottom