Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009

    Unanswered: Requery a Listbox whose Rowsource was changed in a Subform

    Hello, I have a listbox on my main form. I change the Rowsource query of this listbox from the OnCurrent event of a Sub Form (because the WHERE condition is dependent on what record is selected in the subform). I also requery the listbox in the subform's OnCurrent event, but the full results are not displayed in the listbox.

    Mainform = "ODS2Dashboard"
    Listbox = "lstCheckData"

    Here's the (simplified) code in the Subform:

    Private Sub Form_Current()
    Select Case Forms!ODS2Dashboard!tbCheckType.Value
    Case "NotAssigned"
    mySQL = "SELECT CheckSubmsnID as NotAssigned FROM [ODSsubmsnChecksSub-PropExpsr] WHERE CheckKey=tbCheckKey.value;"
    Case Else
    mySQL = "SELECT CheckSubmsnID as Other FROM [ODSsubmsnChecksSub-PropExpsr] WHERE CheckKey=tbCheckKey.value;"
    End Select
    Forms!ODS2Dashboard!lstCheckData.RowSource = mySQL
    End Sub

    For some reason, only the first record is displayed in the listbox (the column header changes (ie "NotAssigned" or "Other"). I added a button on the mainform to requery the listbox and it works once that is clicked, but I don't want the user to have to do that.

    I've experimented with all the events in the mainform to no avail.

    I hope you can help me.
    Last edited by PRicci; 06-22-09 at 09:59.

  2. #2
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    Try this:

    mySQL = "SELECT CheckSubmsnID as NotAssigned FROM [ODSsubmsnChecksSub-PropExpsr] WHERE CheckKey=" & tbCheckKey.value

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts