Combo box value does not refresh subform

  • Thread starter Thread starter William Cunningham
  • Start date Start date
W

William Cunningham

Anyone know what could be causing the following problem:

From the main form, when I change a value in a combo box,
the subform doesn't refresh.

I can provide more info if needed as I'm just typing this
up for a co-worker who's at lunch.

Thanks in advance!
 
William Cunningham said:
Anyone know what could be causing the following problem:

From the main form, when I change a value in a combo box,
the subform doesn't refresh.

I can provide more info if needed as I'm just typing this
up for a co-worker who's at lunch.

Is there a reason it should?

If the ComboBox is used as the MasterLink property of the subform control, then the
subform "should" automatically change when the ComboBox is changed. I have seen
situations where I needed to explicitly issue a Requery against the subform though.
If the ComboBox is _not_ the MasterLink for the subform, then what is its
relationship to the subform that you think it should change? If the subform's query
is using the Combo as a parameter, then you will definitely need to use code to
requery the sub any time the Combo is changed.
 
thanks for the reply.. The main form and subform have the
correct master and child link keys, however I originally
thought the reason the subform was not querying when the
combo box value changed was because the associated key to
the subform was hidden on the main form. I have tried to
force a requery from the after update module on the main
form and that did not work either. Just to make things
easy, we have a form (master) that contains a combo box,
and when the combo box gets changed the subform does not
recognize the new value. The only way you can see the two
related items is by using the bottom (record selectors),
in the bottom of the window, should I hide these? Any
thoughts would be great.
-----Original Message-----


Is there a reason it should?

If the ComboBox is used as the MasterLink property of the subform control, then the
subform "should" automatically change when the ComboBox is changed. I have seen
situations where I needed to explicitly issue a Requery against the subform though.
If the ComboBox is _not_ the MasterLink for the subform, then what is its
relationship to the subform that you think it should
change? If the subform's query
 
Russ said:
thanks for the reply.. The main form and subform have the
correct master and child link keys, however I originally
thought the reason the subform was not querying when the
combo box value changed was because the associated key to
the subform was hidden on the main form. I have tried to
force a requery from the after update module on the main
form and that did not work either. Just to make things
easy, we have a form (master) that contains a combo box,
and when the combo box gets changed the subform does not
recognize the new value. The only way you can see the two
related items is by using the bottom (record selectors),
in the bottom of the window, should I hide these? Any
thoughts would be great.

You still haven't explained *why* the subform should change when the ComboBox is
changed.

Is the ComboBox used as the MasterLink for the subform? I'm assuming not since you
say the linking field is hidden on the main form.

Does the subform's query reference the ComboBox on the main form?

Does changing the CombBox cause other fields/controls on the main form to change thus
affecting a field/control that the subform "cares" about?
 
-If you change the combo box, yes i want to see the
related fields in the sub query.
-Currently the sub form query is not querying against the
given value, now that you brought that up its starting to
make sense.
-Changing anything on the main form does not change at all.

I went through the wizard to create a multiform table. 1-
being the master (the one with the combo box) and a few
other fields, and two sub-forms. The 2 sub forms are ok,
if i click on one subform, the related (second subform)
does requery fine, but anything I change on the main form
(the one with the combo box) does not. I will try to have
the subform requery against the combo box options. Do you
have any examples?
 
Russ said:
-If you change the combo box, yes i want to see the
related fields in the sub query.
-Currently the sub form query is not querying against the
given value, now that you brought that up its starting to
make sense.
-Changing anything on the main form does not change at all.

I went through the wizard to create a multiform table. 1-
being the master (the one with the combo box) and a few
other fields, and two sub-forms. The 2 sub forms are ok,
if i click on one subform, the related (second subform)
does requery fine, but anything I change on the main form
(the one with the combo box) does not. I will try to have
the subform requery against the combo box options. Do you
have any examples?


I know nothing about how the subform wizard works as I've never used it. I can
tell you this: There are two ways that a subform will change it's data based on
a ComboBox being changed on the main form. The "usual" way is to use the two
properties (MasterLink and ChildLink) of the subform control . If the
MasterLink property is a reference to either the ComboBox control or the name of
the field that the ComboBox is bound to then changing the ComboBox entry should
cause a corresponding change in the data displayed in the subform. If your
subform has an additional subform within it you can examine these properties on
the second subform and see how they are set up.

The second way is if the query that the subform is based on uses the ComboBox of
the main form as a criteria reference. The query would be something like...

SELECT * FROM SomeTable WHERE SomeField = Forms!NameOfMainForm!NameOfComboBox.

In that case the subform would likely not change automatically when the ComboBox
value is altered. You would have to issue a Requery command for the subform
when the ComboBox is changed.

If you have neither of these set up then there is nothing that will cause the
subform to change when you make changes on the main form.
 
Hi Russ,

Rich has provided good suggestions. Here is a sample for your reference:

1. Open the sample database NorthWind.mdb
2. Click the Forms objects, click the new button.
3. In the New Form windows, select Design View, in the "Choose the table or
query where the object's data comes from" list box, select Employees, click
OK.
4. Drag some fields to the form.
5. Enable control Wizard, drag and drop a combox control to the form, the
combo box wizard starts, select "find a record on my form based on the
value I selected in my combo box", click Next.
6. Select FirstName into Selected field.
7. Click Next twice, click Finish.
8. Drag and drop a subform control on the form.
9. On the Subform wizard, select "using existing tables and quries", click
Next.
10. Select table Orders, select the available fields, click Next.
11. Click Next, click Finish.
12. Save the form.
13. Open the form, select a firstname in the combo box, the subform's
contents change accordingly.

Please feel free to reply to the threads if you have any concerns or
questions.




Sincerely,

Alick Ye, MCSD
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.



--------------------
| Content-Class: urn:content-classes:message
| From: "Russ" <[email protected]>
| Sender: "Russ" <[email protected]>
| X-Tomcat-NG: microsoft.public.access.forms
|
| -If you change the combo box, yes i want to see the
| related fields in the sub query.
| -Currently the sub form query is not querying against the
| given value, now that you brought that up its starting to
| make sense.
| -Changing anything on the main form does not change at all.
|
| I went through the wizard to create a multiform table. 1-
| being the master (the one with the combo box) and a few
| other fields, and two sub-forms. The 2 sub forms are ok,
| if i click on one subform, the related (second subform)
| does requery fine, but anything I change on the main form
| (the one with the combo box) does not. I will try to have
| the subform requery against the combo box options. Do you
| have any examples?
|
| >-----Original Message-----
| >| >> thanks for the reply.. The main form and subform have
| the
| >> correct master and child link keys, however I originally
| >> thought the reason the subform was not querying when the
| >> combo box value changed was because the associated key
| to
| >> the subform was hidden on the main form. I have tried
| to
| >> force a requery from the after update module on the main
| >> form and that did not work either. Just to make things
| >> easy, we have a form (master) that contains a combo box,
| >> and when the combo box gets changed the subform does not
| >> recognize the new value. The only way you can see the
| two
| >> related items is by using the bottom (record selectors),
| >> in the bottom of the window, should I hide these? Any
| >> thoughts would be great.
| >
| >You still haven't explained *why* the subform should
| change when the ComboBox is
| >changed.
| >
| >Is the ComboBox used as the MasterLink for the subform?
| I'm assuming not since you
| >say the linking field is hidden on the main form.
| >
| >Does the subform's query reference the ComboBox on the
| main form?
| >
| >Does changing the CombBox cause other fields/controls on
| the main form to change thus
| >affecting a field/control that the subform "cares" about?
| >
| >
| >.
| >
|
 
Back
Top