Full Version: Requery Combobox On Subform From Another Form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Nunya
I have googled myself silly and can't resolve this. frmEntry has a subform named frmEntrySub with a combobox named boxGuideTypeId. When a new guide type needs to be added another form opens to add the record. Upon closing this form I want the combobox on the subform to have the new record. I have tried multiple ways and can't get the combobox to refresh. If I press F9 when I'm returned it works so the record is there.


Private Sub Form_Close()
If Me.Dirty Then DoCmd.RunCommand (acCmdSaveRecord) ' save the record
DBEngine.Idle dbRefreshCache 'supposed to force a write of the record
DoEvents
DoEvents
Forms!frmentry.Visible = True
[Forms]!frmentry!frmEntrySub.Form.Requery ' none of thes work or throw an error
[Forms]!frmentry.frmEntrySub.Requery
Forms![frmentry]![frmEntrySub].Requery
[Forms]!frmentry!frmEntrySub.Form.Requery
End Sub

Drives me crazy that there are multiple ways to refer to subform objects. I have tried change the name of the subform control so it is different from the name of the subform and nothing seems to work.

pullhair.gif
MiltonPurdy
In the afterupdate of the popup, try:

forms!subformname.form.controlname = me.comboname.value

OR me.comboname.column(1)
Nunya
Finally got it. This code in the close event procedure of the pop-up form gets the combo box to requery.


Private Sub Form_Close()
If Me.Dirty Then DoCmd.RunCommand (acCmdSaveRecord)
Forms!frmentry.Visible = True
Forms!frmentry!frmEntrySub.Form!boxGroupTypeId.Requery
'______main____subform__________combobox
End Sub


Is the above the 'proper' way to refer to a control on a subform?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.