Roger's Access Library Homepage
Forum Home Forum Home > Roger's Access Library > Roger's Download Samples
  New Posts New Posts RSS Feed - CascadingComboInSubform.mdb (intermediate)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Please consider donating $1 per sample downloaded, (find out why here)

CascadingComboInSubform.mdb (intermediate)

 Post Reply Post Reply
Message Reverse Sort Order
Roger Carlson View Drop Down
Microsoft MVP
Microsoft MVP

Joined: 20 Feb 2008
Status: Offline
Points: 261
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roger Carlson Quote  Post ReplyReply Direct Link To This Post Topic: CascadingComboInSubform.mdb (intermediate)
    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, find out why here.<
Back to Top
Sponsored Links

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

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