Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ Access Forms _ Cascading Combo Box On Continious Form Displays Incorrect Data

Posted by: oxicottin Sep 10 2019, 09:56 PM

Hello, I have a continuous subform that has two combo boxes. The first is just a combobox (cboComponent) that I make a selection then the second combo (cboComponentParts) is based on the first. For the Row Source of the second combo I am using.

SELECT tbluComponentData.Part, tbluComponentData.IsInactive
FROM tbluComponentData INNER JOIN tbl_Components ON tbluComponentData.Component = tbl_Components.Component
WHERE (((tbl_Components.ComponentID)=[Forms]![frm_UpdateProductComponentsParts]![sfrm_UpdateProductComponentsParts].[Form]![cboComponent]))
GROUP BY tbluComponentData.Part, tbluComponentData.IsInactive
HAVING (((tbluComponentData.IsInactive)=False));

Now, here is what happens. In the continuous forms first record I select a (cboComponent) and then the (cboComponentParts) populates that correct data so I go to record two and do the same thing and it works correctly. Now here is where it gets messed up, if I decide I want to change just the (cboComponentParts) from the first record it displays the data that would be for the second record and the only way to get it to change is if I change the (cboComponent) then the (cboComponentParts) will again display the correct data.

Now here is something else, I created a query (Query1) with the exact SQL from above and then opened the form and its subform and clicked on a record and then opened the Query1 and it always displayed the correct data but the combo box didn't?

What do I need to do to fix this? Thannks!

Posted by: oxicottin Sep 10 2019, 10:19 PM

Ok, after days of dealing with this I just ran across an example that fixed my issue. (txtComponentParts) is a textbox that displays the data sitting on top my (cboComponentParts).

Private Sub txtComponentParts_GotFocus()
DoCmd.GoToControl "cboComponentParts"
End Sub

Private Sub cboComponentParts_Enter()
End Sub

Posted by: BruceM Sep 11 2019, 07:47 AM

You can requery the combo box without going to it. Typically a cascading combo box is requeried when a selection is made in the previous one. For instance, if you have States and Counties, the list of counties would be updated when a state is selected, in the After Update event of the State combo box. Another consideration may be that you need to set the combo box row source in the Current event, so that if a State is already selected the list of Counties will match the State.