How to update a combo box in a sub-form from a combo box on a main (single) form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Me nnell I
    New Member
    • Oct 2010
    • 1

    #1

    How to update a combo box in a sub-form from a combo box on a main (single) form

    I have a single record form with a combo box to update a field.
    The form contains a sub-form with a solitary combo box to be able to select a sub-group of the combo box on the main form.
    I have the following code in the row source of the subform:

    Code:
    SELECT [Class Times].[Class ID], [Class Times].Class
    FROM Members LEFT JOIN [Class Times] ON Members.Class = [Class Times].Class
    WHERE ((([Class Times].Class)=[Forms]![Form - Current Members]![Class]));
    When I change the combo box on the main form the combo list on the subform doesn't refresh? I have tried the following code in the AfterUpdate event of the first combo but it just says it can't find the form?

    Code:
    Private Sub Class_AfterUpdate()
        Forms![Form - Class Register Subform]![Class ID].Requery
    End Sub
    Any help on this would be great?
    Last edited by NeoPa; Oct 9 '10, 02:00 PM. Reason: Please use the [code] tags provided.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    I would start with renaming your forms using no special characters (like the minus sign "-" and spaces " ").
    Access acts sometimes strange on the minus sign :-(

    Next use to requery the subform:

    Me.sfrmName.Req uery

    Replace the sfrmName with the name of the subform as recorded in the properties!

    Nic;o)
    Last edited by nico5038; Oct 9 '10, 02:44 PM. Reason: Thanks to NeoPa :-)

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Nico's on the button with this one - except the spelling of .Requery is all.

      Comment

      • Me Nell I

        #4
        Thanks

        Many thanks for the replies guys. sorted it now. :-)

        Comment

        Working...