Solved Cascading combo boxes (1 Viewer)

PaquettePaul

Member
Local time
Today, 15:51
Joined
Mar 28, 2022
Messages
107
I have a form with a list box that has the key identifiers for a table and a subform for data entry/review. When the user clicks on an entry in the list box, the master key is set which changes the view in the child subform. In the subform, I have two combo boxes: a list of aircraft and the second is a list of rate plans for the aircraft. The rate plan combo box is based on a query which refers to the chosen aircraft (I.e., the aircraft combo box) which means that the user can only select rate plans pertinent to the chosen aircraft.

This process work great during the creation of a new record. However, I have an issue when selecting records from the list box. In most cases, the aircraft is shown but not the rate plan. In some cases, the rate plan is shown as well. If I click twice on the record identifier in the list box, both the aircraft and the rate plan show up most of the time. I tried doing a combo box.requery in the form_current routine but that did not fix the problem. The only code associated with this is the field form reference in the query.

Anyone have similar problems and know how to fix it?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:51
Joined
Feb 19, 2013
Messages
16,553
need to see your code otherwise pure guesswork. Include the names of the relevant controls as well as the values set for the subform linkchild and linkmaster properties
 

PaquettePaul

Member
Local time
Today, 15:51
Joined
Mar 28, 2022
Messages
107
As mentioned, there really is not any code. The master/child relationship between the form and subform works fine, the data field to link the cascade combo box works fine in data entry, and there is no other code. My unknown issue is why the aircraft rate combo box is not being filled when the master/child subform is executed or at least in a consistent manner.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:51
Joined
Feb 19, 2013
Messages
16,553
OK, I'll take one guess - the combo is not be requeried.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:51
Joined
May 21, 2018
Messages
8,463
Is the subform a continuous form?
 

PaquettePaul

Member
Local time
Today, 15:51
Joined
Mar 28, 2022
Messages
107
Last night, I checked the contents of the combo box. In most cases, the rate plan combo box would indicate the proper stored number and the five columns in the combo box would be filled as per a msg box. After clicking on several entries, the problem would occur where the value of the combo box would be correct but all of the columns for the combo box would be null.

This morning, I tried code that checked if the value was not null and the columns were null and did a combo box requery. This seems to have done the trick. Not sure why it was working sometimes but not others. If this did not work, I was going to change the key of the first Combo box from string (the airplane’s call sign) to a numeric key to see if that made a difference.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 19:51
Joined
Feb 19, 2013
Messages
16,553
to refresh a rowsource, you need to requery it. If the rowsource references another control you can do this in the other controls after update event
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:51
Joined
Feb 19, 2002
Messages
42,973
I was going to change the key of the first Combo box from string (the airplane’s call sign) to a numeric key to see if that made a difference.
This is somewhat disturbing. The combo should always use the FK as the bound column. That is normally hidden and only a text column is visible.
 

Users who are viewing this thread

Top Bottom