Filter main form based on criteria in subform

Hello~ can anyone help me with filtering a main form based on a value that's in a subform. The main form and subform are linked by a key identifier from the main form. My database does not have a join table. Any help is greatly appreciated. Thank you in advance.
jaguar5554Business AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

We need a bit more info.  The main form is based on some table.  What is the subform based on - another Table?  If so the Master and Child fields of the subform must be filled in with the appropriate field names from both tables, each containing the key identifier.
Jeffrey CoachmanMIS LiasonCommented:
You can do anything you want....
But filtering the main form from a record in the subform is inherently Backwards...

A Main form (Customers) will filter the records in a subform (Orders)
...Not the other way around.

So you will have to be very detailed in describing your design here, and the need for this...

If you want to do something like this, you will need and entirely Different/New "Form".
This new form will be based on the subform records only.
Then you can simply apply a filter for the "Main" form records)

Create the "Form" based on the Child table. (ex.: Orders)
Create a combobox on the form to list the "Parent" records (Customers)

Then on the after Update event of the combobox (or on a "Apply Filter" Button)
Do something like this:
Me.Filter="CustomerID=" & me.cboCustomerID    'For a Numeric Key
'Or this for a text key:
'Me.Filter="CustomerID=" & "'" & me.cboCustomerID & "'"

Then you can reset the filter (show all) with something like this:

Jeffrey CoachmanMIS LiasonCommented:

Then you can reset the filter (show all) with something like this:

...Should be:
Then you can reset the filter (show all) with something like this:
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Jeff, I haven't been doing much with Access for the past month but shouldn't those two lines be reversed?  When you create the filter, you create the text component, then turn the filter on.  I would have thought you should reverse the process - turn it off, then make the filter a zero length string.
jaguar5554Business AnalystAuthor Commented:
Hello boag2000~ you bring up a concept I did not think of before -- a different form completely. Let me try that and if it does not work, I will update my question with my database and current form setup. Stay tuned....
Jeffrey CoachmanMIS LiasonCommented:

To be honest, I am sure it would work either way...
So perhaps your syntax would be more elegant...

I just have always done it this way.
(I always do the filtering and clearing the filter via a button, ...if that matters

But trust me, I have been know to have been doing things wrong for years...


Jeffrey CoachmanMIS LiasonCommented:
<Hello boag2000~ you bring up a concept I did not think of before -- a different form completely.>
Again, what you asked for originally was a bit odd...

If you Selected a Customer on the main form (Customer 101), ...the subform would Only show records (ex. Orders) for Customer101.
...So how would the subform show any other main record than Cust101, for you to filter on?
Yeah ;-)
jaguar5554Business AnalystAuthor Commented:
Applied the following on the AfterUpdate event:
Dim strSQL As String
If IsNull(Me.Combo73) Then
    ' If the combo is Null, use the whole table as the RecordSource.
    Me.RecordSource = "tblMaster"
    strSQL = "SELECT DISTINCTROW tblMaster.* FROM tblMaster " & _
        "INNER JOIN rtblAttributes ON " & _
        "tblMaster.MasterID = rtblAttributes.MasterID " & _
        "WHERE rtblAttributes.Attribute = " & Chr(34) & Me.Combo73 & Chr(34) & ";"    'for text value
    Me.RecordSource = strSQL

End If

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jaguar5554Business AnalystAuthor Commented:
The solution was provided by AllenBrown (from his website) and did exactly what I needed the filter to do.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.