Print Page | Close Window

CascadingComboInSubform.mdb (intermediate)

Printed From: Roger's Access Library
Category: Roger's Access Library
Forum Name: Roger's Download Samples
Forum Description: A compendium of Microsoft Access 97 and 2000+ routines, each separated into its own sample database.
Printed Date: 30 Nov 2020 at 7:05pm
Software Version: Web Wiz Forums 12.03 -

Topic: CascadingComboInSubform.mdb (intermediate)
Posted By: Roger Carlson
Subject: CascadingComboInSubform.mdb (intermediate)
Date Posted: 03 Aug 2008 at 11:05pm

Please consider donating $1 per sample downloaded, - find out why here .


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
Access 97 (37 KB): -
Access 2000 DAO (105 KB): -

Consider donating $1 per sample downloaded," rel="nofollow - find out why here .<

Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 -
Copyright ©2001-2019 Web Wiz Ltd. -