Requery a subform combo box based on a main form combo box

G

Guest

I have two combo boxes. One is based on my main form (LEASE_FORM) and is
named LEASE_COMBO and the other is based on my subform (TRACT_FORM) and is
named TRACT_COMBO. The LEASE_FORM and the TRACT_FORM are linked by the field
"OCS/SL." I have linked the two through the rowsource and the code that the
combo box wizard writes in the AfterUpdate section of each combo box. This
works beautifully the first time I select a lease from LEASE_COMBO and then
select a tract within the lease from TRACT_COMBO.

My problem is that when I go to select a different lease from LEASE_COMBO,
my TRACT_COMBO does not update to my selection. I have read that I should
requery LEASE_COMBO in the AfterUpdate section, but I already have code in
that section and I do not think this will work for a combo on a main form
linked to a combo on a subform.

How do I requery combo boxes when one is on the main form and one is on the
subform and I already have code in the AfterUpdate sections of each combo
box. I hope this was clear, and I appreciate any help with this!
 
M

Marshall Barton

emily said:
I have two combo boxes. One is based on my main form (LEASE_FORM) and is
named LEASE_COMBO and the other is based on my subform (TRACT_FORM) and is
named TRACT_COMBO. The LEASE_FORM and the TRACT_FORM are linked by the field
"OCS/SL." I have linked the two through the rowsource and the code that the
combo box wizard writes in the AfterUpdate section of each combo box. This
works beautifully the first time I select a lease from LEASE_COMBO and then
select a tract within the lease from TRACT_COMBO.

My problem is that when I go to select a different lease from LEASE_COMBO,
my TRACT_COMBO does not update to my selection. I have read that I should
requery LEASE_COMBO in the AfterUpdate section, but I already have code in
that section and I do not think this will work for a combo on a main form
linked to a combo on a subform.

How do I requery combo boxes when one is on the main form and one is on the
subform and I already have code in the AfterUpdate sections of each combo
box.


Just add a line to the code in the lease combo's AfterUpdate
event procedure:

Me.subformcontrolname.Form.TRACT_COMBO.Requery

Note that the name of the subform control that displays the
TRACT_FORM object may be different than the name of the
form.
 
G

Guest

Thanks that did the trick!!

Marshall Barton said:
Just add a line to the code in the lease combo's AfterUpdate
event procedure:

Me.subformcontrolname.Form.TRACT_COMBO.Requery

Note that the name of the subform control that displays the
TRACT_FORM object may be different than the name of the
form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top