CascadingComboInSubform.mdb (intermediate)

Please consider donating $1 per sample downloaded, find out why here
Access 97 (37 KB)

Here's the problem: The normal method of cascading combos is to reference the first combobox in the rowsource of the second and also requery the second combo after the first is updated. This works fine in a single-form view of a form. Unfortunately, as the sample illustrates, this won't work in a continuous form. Only the active record will show the value in the second combo. It is still there, but you can't see it, because that value is no longer in the rowsource.

Here's the solution: Programmatically modify the rowsource, so it references the first combobox ONLY when the second combobox has the focus (the code in in the OnGotFocus event of the second combo) and when it looses focus, change the row source so that it shows the whole list.

Caveat: There are circumstances under which the values can appear to vanish, as in the problem form. The there is code in the LostFocus event of the second combo that requeries subform, but the bookmark needs to be stored, otherwize the focus will return to the first record in the subform. The best I can come up with is to return to the same record you just left. It is not perfect, but gets you in the ballpark. -RC




Need Winzip?

Return to Main Page