Results 1 to 6 of 6
  1. #1
    ebjers is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    3

    Question filtered listbox on subform

    I have a form with a listbox to select records from one table, the list box has Project_ID (PK, hidden) and Project_Name
    There is a subform with another listbox pulled from another table that has; Office_ID (PK, hidden), Project_ID (FK, Hidden), Office_name
    Click image for larger version. 

Name:	Access Form.jpg 
Views:	19 
Size:	104.4 KB 
ID:	34725

    The forms are linked on Project_ID

    The record selector for the sub form shows the correct number of records and cycles through the related records


    The listbox on the subform shows all records in the table and not just the ones related to the selection in the parent form

    What do I need to change so the listbox on the subform only shows the records based on the selection in the listbox in the parent form?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you are doing this backwards. Why not put the subform listbox on the MAIN form, if you want to filter the main form?

    but you can filter anything by just using the full path (see builder)

    me.filter = "[field]=" & forms!myform!subForm!form.listbox2
    me.filterOn = true

  3. #3
    ebjers is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    3
    Quote Originally Posted by ranman256 View Post
    you are doing this backwards. Why not put the subform listbox on the MAIN form, if you want to filter the main form?

    but you can filter anything by just using the full path (see builder)

    me.filter = "[field]=" & forms!myform!subForm!form.listbox2
    me.filterOn = true
    Hello Ranman256,

    I am trying to filter the listbox on the subform based on what is selected in the parent form not to filter the listbox on the parent form.

    Where do I apply those filters?

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    ebjers,

    Please tell us more about "your business" in simple terms. You have Projects and Offices. How are Offices and Projects related? Forget forms and listboxes for the moment and, using simple English -no jargon, tell us about an Office(s) and a Project.

  5. #5
    ebjers is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    3
    Quote Originally Posted by orange View Post
    ebjers,

    Please tell us more about "your business" in simple terms. You have Projects and Offices. How are Offices and Projects related? Forget forms and listboxes for the moment and, using simple English -no jargon, tell us about an Office(s) and a Project.
    Each project can have one or more offices
    Each office can be related to only one project
    There may be more than one office in the same city for different projects so office name is not unique in the database but the office ID (PK in office table) is unique

    Click image for larger version. 

Name:	Relation.png 
Views:	9 
Size:	8.1 KB 
ID:	34734

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    This is cascading or dependent combo/list box - a common topic. Need a WHERE clause in the offices listbox that references projects listbox. Then need code that requeries the offices listbox. Probably need in projects AfterUpdate event as well as the subform Current event.

    What is purpose of offices listbox? Is it BOUND?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-29-2017, 10:24 AM
  2. Replies: 2
    Last Post: 12-13-2014, 08:52 PM
  3. Export Filtered ListBox output to a Excel Sheet
    By gokul1242 in forum Programming
    Replies: 4
    Last Post: 10-11-2012, 02:19 PM
  4. Open Report filtered by Date in ListBox
    By TinaCa in forum Programming
    Replies: 1
    Last Post: 03-06-2012, 02:29 PM
  5. Sub form filtered by listbox
    By BorisGomel in forum Forms
    Replies: 3
    Last Post: 05-04-2011, 09:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums