How to refresh a Subform after updating a combo-box on the main form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a combo box on my main form (Vendor) that when changed I want a sub-form on the same main form to refresh and show all the child records from my Vendor Contacts table. I can get this working if instead of a sub-form for the vendor contacts I use something such as a combobox, but I would also like my subform's query to be based off this master combobox on the main form.

It is working if I change the vendor combo box and then navigate away from the main record and back then the subform shows the correct child records. It also works if after I change the main Vendor combobox and then right-click on the subform and choose "Remove filter/sort". However I would like to programatically do something similar after the the .AfterUpdate event fires on the main form when the user changes the Vendor combo box.

I hope I was clear in my mission! So you know I have tried to put in the .AfterUpdate event code to refresh the subform but that doesn't seem to work (it does work with the linked combobox as stated above however)

Any ideas

Thanks
JC
 
Why not just link the subform using the combo box on the main form as the
LinkMasterField and the corresponding vendor id in the record on the Form
embedded in the Subform as the LinkChildField? That should serve the same
purpose and be a lot simpler.

Larry Linson
Microsoft Access MVP

JCervantes said:
I have a combo box on my main form (Vendor) that when changed I want a
sub-form on the same main form to refresh and show all the child records
from my Vendor Contacts table. I can get this working if instead of a
sub-form for the vendor contacts I use something such as a combobox, but I
would also like my subform's query to be based off this master combobox on
the main form.
It is working if I change the vendor combo box and then navigate away from
the main record and back then the subform shows the correct child records.
It also works if after I change the main Vendor combobox and then
right-click on the subform and choose "Remove filter/sort". However I would
like to programatically do something similar after the the .AfterUpdate
event fires on the main form when the user changes the Vendor combo box.
I hope I was clear in my mission! So you know I have tried to put in the
..AfterUpdate event code to refresh the subform but that doesn't seem to work
(it does work with the linked combobox as stated above however).
 
Thanks Larry for the help.

That is what I'm doing however the Subform does not update when i change the Combo selection unless i move off of the master record then back. How would I get it to automatically refresh with the combo change?


----- Larry Linson wrote: -----

Why not just link the subform using the combo box on the main form as the
LinkMasterField and the corresponding vendor id in the record on the Form
embedded in the Subform as the LinkChildField? That should serve the same
purpose and be a lot simpler.

Larry Linson
Microsoft Access MVP

JCervantes said:
I have a combo box on my main form (Vendor) that when changed I want a
sub-form on the same main form to refresh and show all the child records
from my Vendor Contacts table. I can get this working if instead of a
sub-form for the vendor contacts I use something such as a combobox, but I
would also like my subform's query to be based off this master combobox on
the main form.the main record and back then the subform shows the correct child records.
It also works if after I change the main Vendor combobox and then
right-click on the subform and choose "Remove filter/sort". However I would
like to programatically do something similar after the the .AfterUpdate
event fires on the main form when the user changes the Vendor combo box...AfterUpdate event code to refresh the subform but that doesn't seem to work
(it does work with the linked combobox as stated above however).
 
Hi

What if I want to update a status (using a toggle button) in the main form and I also want to update the toggle button status in the subform, but I also want the ability to make changes to the toggle button status in the subform. Let's say the button in the main form is ship all, but sometimes you want to ship partial. I guess it's just like hotmail (or any web-based email, where you check the box on top, all emails will be checked, but you still have the ability to update individual emails). Please advise. Thanks a bunch

----- Larry Linson wrote: ----

Why not just link the subform using the combo box on the main form as th
LinkMasterField and the corresponding vendor id in the record on the For
embedded in the Subform as the LinkChildField? That should serve the sam
purpose and be a lot simpler

Larry Linso
Microsoft Access MV

JCervantes said:
I have a combo box on my main form (Vendor) that when changed I want
sub-form on the same main form to refresh and show all the child record
from my Vendor Contacts table. I can get this working if instead of
sub-form for the vendor contacts I use something such as a combobox, but
would also like my subform's query to be based off this master combobox o
the main formthe main record and back then the subform shows the correct child records
It also works if after I change the main Vendor combobox and the
right-click on the subform and choose "Remove filter/sort". However I woul
like to programatically do something similar after the the .AfterUpdat
event fires on the main form when the user changes the Vendor combo box..AfterUpdate event code to refresh the subform but that doesn't seem to wor
(it does work with the linked combobox as stated above however)
 
Back
Top