Beginner question I should know the answer to - Form Filters

GK in the UK

Registered User.
Local time
Today, 07:42
Joined
Dec 20, 2017
Messages
281
Having trouble with un-setting a filter in VBA. It may be to do with master-child relationships, not sure, everything works apart from an Automation Error I'm getting.
I have a sub form with a query with no parameters. So if I run the query manually it selects every record from the table. The query is the RecordSource of the sub form.

My sub form runs with one of two master child relationships according to which main form it's hosted in:
either NominalID > tlNominalFk OR ProductID > tlProductFK.
So one main form shows all transactions relating to a given Nominal Account, the other main form shows all transactions relating to a given Product.

Is this the right way to do it ? The query has no parameters. But the form 'drops' the Master/Child keys into the data source query somehow and shows the right selections ? Is that how it works ?

What I'm not fully understanding is that the form design shows (eg) Filter: NominalID=20024 and for the other form Filter: ProductID=22

Is this the Master/Child relationship working ?

The reason for the beginner question is: does the query pass the entire table to the form and the form then filters it ? or does the query pass only the selected records ?
I think of a 'filter' as something that happens after the SQL selection has been passed. Maybe I've got it wrong.

To try and get rid of my sticky form filter that I don't want, I put 2 lines in the load event:

' Me.Filter = vbNullString
' Me.FilterOn = True

And I was surprised to see that the form would open only with the very first record in the table. Leading me to think the filter and the SQL are sort of the same thing. Is there a difference between a 'Filter' in the form design and a 'Filter' applied from a datasheet drop-down ? Does the drop-down filter re-run the SQL with the new criteria ? I didn't think so, but now I'm wondering
 
You already has the answer.
On form is link to nominalid and the other on productid.
 
Hi. I don't think the linked fields and the form's filter are the same thing, but they do behave similarly.
 

Users who are viewing this thread

Back
Top Bottom