Link to home
Start Free TrialLog in
Avatar of rdani08
rdani08

asked on

How do I filter the data on a subform on a tab control based on the parent form in Access 2007?

I have an Access 2007 database where the parent table/form is for Unit Owner and the child/subform is for Visitors.  The subform (located on a tab control of the parent form) functions properly, however it displays all of the visitors.  In the Visitor table, there is a field for Out Date.  I only want to show the current visitors on the subform.  That would be any visitor record for that unit owner that has a Date Out of today or later OR when the Date Out field is blank.
Using the query as the record source to open the Visitor subform independently works only when I have the Unit form already open to a specific unit.  If I open the Unit form, several popup windows occur (because I'm assuming the query has run and the subform doesn't have any data to display).  Do I need to add code into the form's event properties?  On Open, On Load, After Update, etc?
The subform contains the following fields: Visitor, Category, Date In, and Date Out.  In the sample attached there are two Entry System forms.  I am working on the one that ends in "FD" as well as the subform named VisitorSubform FD.  The tables for UnitOwner and NotesVisitor link via the unit number.  I need both versions of the Entry System forms to work.  One will show all visitors, past and present, the FD version will only show those >Date() or is null.
EntrySystem.accdb
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

you can use the subformControl Master and Child Fields property to filter the subform.
your table UnitOwner field Unit does not have a value corresponding to field UnitNo in table NotesVisitors..


see this revised db
EntrySystem.accdb
Avatar of rdani08
rdani08

ASKER

The Master and Child fields are linked.  Unit to Unit ID. That is not the problem.  Let provide an example:
Unit 1 has Vistors A, B, C, and D.  In the Date Out field: A is Null, B and C are dates prior to Today, D is dated 3 months from now.  I only want to show Visitors A and D for Unit 1 when the form is opened.
see the file I uploaded
Avatar of rdani08

ASKER

That file does not work properly either.  What form and subforms did you modify?  What steps are you taking?  This is a sample database and I need to be able to recreate the solution in the actual database.  Thank you
are you reading my post?  http:#a39769929
Avatar of rdani08

ASKER

Yes, I have read your posts.  The file you posted does not work the way I have asked.  There are no relationships created. Maybe I am not explaining the issue properly.  If I create the relationship in Database Tools between Unit and UnitNo, What do I do next to ensure I can still have two versions of the Entry System?  One is Entry System with VisitorSubform. This will show all Visitors (current and past) for the linked Unit. The other, Entry System FD with VisitorSubform FD, will only show Visitors for that Unit with no date entered (null) or a future date entered in Date Out.  I appreciate your responses but I need further explanation/help.
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial