Results 1 to 2 of 2
  1. #1
    SamL is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Location
    NJ
    Posts
    20

    Multi-Select List Box issue

    Hi, I'm programming some annual management reports for a non-profit org. The data stretches back to 2015, so I have a cmbServiceYear combo box sorted in descending order so it's easy to pick the year for the annual report. This part works.



    The next tab stop on the form is a multi-select (simple) list box (lstPrograms) so management can select their pet programs. Every year they will be different, and I assume they will eventually report on all of them anyway. But they want it this way. OK. Problem: While the Row Source for list box works correctly, it doesn't populate the list box. It's totally blank. I checked column counts and widths, and the bound column, and they're all correct. The row source for the list box is a query, qryLstProgram, and here is the SQL:
    Code:
    SELECT ServicesSL.ProgramFROM ServicesSL
    WHERE (((Year([Service Date]))=[forms]![frmRptMgmtMenu]![cmbServiceYear].[value]))
    GROUP BY ServicesSL.Program
    HAVING (((ServicesSL.Program) Is Not Null))
    ORDER BY ServicesSL.Program;
    If I stop execution after selecting the year, and run the query independently, it gives me all the programs that were on the table in that year. Why doesn't it populate the list box? Even clicking on the list box doesn't force the query to run.

    Thanks,
    Sam

  2. #2
    SamL is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2021
    Location
    NJ
    Posts
    20
    Solved. It seems that Access reads the row source property upon loading the form. Since upon loading, the value of the combo box is null, the list box is null as well.

    If I erase the info from the row source property, and put that info in the combo box's AfterUpdate event, the list box populates correctly. Thanks.

    It's simple:
    Code:
    Private Sub cmbServiceYear_AfterUpdate()
    
        Dim qryLstP As QueryDef
        
        Me.lstPrograms.SetFocus
        Set qryLstP = CurrentDB.QueryDefs("qryLstProgram")
        Me.lstPrograms.RowSource = qryLstP.SQL
        
    End Sub

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

Similar Threads

  1. Multi-Select List Box issue
    By SamL in forum Programming
    Replies: 3
    Last Post: 05-30-2021, 09:58 PM
  2. Replies: 10
    Last Post: 10-26-2019, 12:15 PM
  3. Replies: 15
    Last Post: 11-20-2013, 04:30 PM
  4. Replies: 5
    Last Post: 07-26-2012, 12:59 PM
  5. Replies: 1
    Last Post: 10-22-2010, 10:11 AM

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