Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557

    Cascade Listbox's

    Hi Everyone

    I have cross-posted this on Utter Access https://www.utteraccess.com/topics/2.../posts/2762703

    I have 2 Listbox's - when I select an Item in the 1st Listbox I only want to see related records in the 2nd Listbox



    1st List122 Row Source is as follows:-

    Code:
    SELECT qryObjectiveList.GoalObjectiveID, [ObjectiveLetterNumber] & " - " & [Objective] AS O, qryObjectiveList.ObjectiveID FROM qryObjectiveList WHERE (((qryObjectiveList.StudentID)=[Forms]![frmStudentsProgress]![pkStudentID])) ORDER BY qryObjectiveList.ObjectiveID;
    2nd List187 Row Source is qryInterventionList

    The SQL is :-
    Code:
    SELECT tblObjectiveInterventions.GoalObjectiveID, tblObjectiveInterventions.InterventionID, tbluInterventions.Intervention, tblObjectiveInterventions.ObjectiveInterventionID
    FROM tbluInterventions RIGHT JOIN tblObjectiveInterventions ON tbluInterventions.InterventionID = tblObjectiveInterventions.InterventionID;
    
    I am trying to filter the 2nd List by GoalObjectiveID with no success
    
    Any help appreciated
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Unless the first listbox allows multiple selections, it's the same as combos:

    http://www.baldyweb.com/CascadingCombo.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi Paul

    The 1st List does allow multiple selections
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Then you'll need to loop it. You can adapt this, basically adding WHERE to the end of the SQL instead of using OpenReport.

    http://www.baldyweb.com/multiselect.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Oh, and using the the second cascading method, where you build the SQL in code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi Paul

    So instead of the Command Button for Open Report

    Do I need to place the SQL from the Command Button in the After Update of the 1st Listbox?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Basically you're using the second method in the cascading combo link, but rather than refering directly to the first listbox, you loop the selected items and use that in the WHERE clause.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi Paul

    I have tried the following Code in the Row Source of List187

    Code:
    SELECT qryObjectiveList.GoalObjectiveID, [ObjectiveLetterNumber] & " - " & [Objective] AS O, qryObjectiveList.ObjectiveLetterNumber, qryObjectiveList.Objective FROM qryObjectiveList WHERE (((qryObjectiveList.[GoalObjectiveID])=[Forms]![frmStudentsProgress]!
    [List122]));
    In the Click Event of List122 I have this:-

    Me.List187.Requery

    Still no luck in getting the 2nd List187 to display records that contain GoalObjectiveID
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  9. #9
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Hi Mike,

    See if this helps

    in your case the sql the afterupdate of list122 will be like (if I have list names in correct order)

    Code:
    Me.List187.Rowsource = "SELECT qryObjectiveList.GoalObjectiveID, [ObjectiveLetterNumber] & " - " & [Objective] AS O, qryObjectiveList.ObjectiveLetterNumber, qryObjectiveList.Objective FROM qryObjectiveList WHERE  qryObjectiveList.[GoalObjectiveID]  in(" &   getLbx(List122) & ")" 
    Attached Files Attached Files
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  10. #10
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi moke

    I now get the following error:-
    Attached Thumbnails Attached Thumbnails error.JPG  
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  11. #11
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Did you copy over the public function getLBX?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  12. #12
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi moke

    OK I did that and now I get the following error:-
    Attached Thumbnails Attached Thumbnails error.JPG  
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  13. #13
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Whats the datatype of the 1st column in the 1st listbox (list 122) and the datatype of GoalObjectiveID?

    did you look at the example db I posted? How it goes together?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  14. #14
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi moke

    1st Column is GoalObjectiveID

    In the data table it is the PrimaryKey

    I am then adding it to qryObjectiveList so that I can then make a reference to the GoalObjectiveID in List187
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  15. #15
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Could you post the sql of qryObjectiveList.
    Why use a saved query? (at least that is what it looks like your doing.)
    Even better if you can post an example db.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Cascade Menu
    By VICTOR HUGO in forum Forms
    Replies: 7
    Last Post: 10-12-2018, 12:14 PM
  2. Cascade Delete when Its not set?
    By Perceptus in forum Queries
    Replies: 16
    Last Post: 10-13-2015, 01:21 PM
  3. Help with cascade combo box
    By jwalther in forum Forms
    Replies: 2
    Last Post: 06-19-2015, 07:19 AM
  4. Relationship Cascade help
    By murry in forum Database Design
    Replies: 6
    Last Post: 04-16-2012, 10:49 AM
  5. cascade combo box
    By Andyjones in forum Access
    Replies: 6
    Last Post: 04-05-2012, 04:41 PM

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