How to refresh combo box values in the subform once selected in main form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dekk

    How to refresh combo box values in the subform once selected in main form

    Hi,

    I have a main form ("frm_TimeParen t") and a subform ("frm_TimeChild ").

    Issue: How do I refresh the combo box values in the subform once the contract has been selected in the main form?

    Background:

    The main form has a combo box ("cbo_Contract" ) which obtain data from a QUERY ( SELECT [tbl_Contract].[Contract], [tbl_Contract].[Contract Description] FROM tbl_Contract; ) and has a control source ("Contract_i d).

    The subform has a combo box ("cbo_Activity" ) which obtains date from a QUERY ( SELECT Reference.Activ ity, Reference.Contr act FROM Reference WHERE (((Reference.Co ntract)=Forms![frm_TimeParent]!cboContract)); ) and has a control source ("Activity_i d")
    Last edited by MMcCarthy; Oct 20 '10, 02:03 AM. Reason: added code tags
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32653

    #2
    It's good to get a question clearly asked.

    The only info missing is the name of the SubForm control on your main form. As you probably didn't realise this was pertinent though, I can't criticise. For now though, I will refer to it as [SubFormControl].

    What you need, in your cbo_Contract_Af terUpdate() event, is code to call a .Requery of the ComboBox control on your sub-form. Something like :

    Code:
    Private Sub cbo_Contract_AfterUpdate()
        Call Me.SubFormControl.Form.cbo_Activity.Requery()
    End Sub
    An alternative would be to replace .Form. with a simple ! as a shortcut.

    Comment

    Working...