Cascading combo box doesn't change with record set

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pookaroo85
    New Member
    • Nov 2013
    • 34

    Cascading combo box doesn't change with record set

    I have a set of cascading combo boxes. The first (IDH) is based on a query. Then, I have the following code to change the second combo box.
    Code:
    Private Sub IDH_AfterUpdate()
    Dim strSource As String
    
    strSource = "SELECT Supplier " & _
                       "FROM tblMaterialSuppliers " & _
                       "WHERE IDH = '" & Me.IDH & "' ORDER BY Supplier"
    Me.Supplier.RowSource = strSource
    Me.Supplier = vbNullString
    End Sub
    This works as long as I stay on the same record, but when I change records the selection in the second combo box doesn't update.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    That's because when you change records, you're not updating the table data, so the code isn't going to run. Call the code as well in the form's Current event, that fires whenever you change records.

    Comment

    • Pookaroo85
      New Member
      • Nov 2013
      • 34

      #3
      I added the same code (copy/paste) to the form's on current event and now when I toggle records, the combo box is blank.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        The combobox value is blank or the combobox list is blank? The combobox value should be blank, you set it to null in your code. The combobox list shouldn't be blank assuming the record you're going to has a value in IDH.

        Comment

        • Pookaroo85
          New Member
          • Nov 2013
          • 34

          #5
          The combobox value is blank. It saves into the table, but then doesn't reappear when toggling records in the form. I removed "Me.Supplie r = vbNullString".

          Comment

          • Pookaroo85
            New Member
            • Nov 2013
            • 34

            #6
            Figured it out. Thank you!

            Comment

            Working...