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.
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=388
Printed Date: 30 Nov 2020 at 7:05pm
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


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, http://www.rogersaccesslibrary.com/whydonations.htm - find out why here .

CascadingComboInSubform.mdb

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
 
Download
Access 97 (37 KB):
http://www.rogersaccesslibrary.com/forum/uploads/5/CascadingComboInSubform97.zip - CascadingComboInSubform97.zip
Access 2000 DAO (105 KB): http://www.rogersaccesslibrary.com/forum/uploads/5/CascadingComboInSubform2k.zip - CascadingComboInSubform2k.zip



-------------
Consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm" rel="nofollow - find out why here .<



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net