Results 1 to 4 of 4
  1. #1
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60

    dependent combo boxes

    I have a main form (MyMainform) that has a subform (MySubform) attached. On the subform, I have a set of dependent comboboxes: cboRegion and cboState. To illustrate, when the user selects "Southeast" from cboRegion, the only states available in cboState are AL, GA, TN, etc. Likewise, when the user selects "Northeast", then the states available are MA, CT, ME, etc.

    The problem is, when I open up just the subform from the Access Objects and make my selection in cbo Region, cboState adjusts accordingly. However, when I open the main form that has the subform attached and attempt to do the same I get a message box asking me to enter a parameter value.



    Here is the code I have in the AfterUpdate event for cboRegion:

    Private Sub cboRegion_AfterUpdate()
    Me.cboState.Requery
    End Sub

    Here is the Row Source sql I have for cboState:

    SELECT [tblRegions].[RegionID], [tblRegions].[RegionName] FROM tblRegions WHERE [tblRegions].[StateID] =Forms!sfrmMySubform.StateID ORDER BY [RegionName];

    What am I missing? Why does it work properly on the subform only but not on the subform attached to the main form?

    Please help!

    Thanks,

    Jamie

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    The syntax changes when it's a subform:

    Forms Refer to Form and Subform properties and controls
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jle0003 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    60
    Thanks for the quick response.

    I used the following syntax:

    Me!Subform1.Form!ControlName (Me!MySubform.Form!cboState) in the Rwo Source for cboState.

    However, I still got the same message (enter a parameter value).

    Did I do something wrong?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Me is only valid in VBA code. You need the full form reference.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Multiple dependent combo boxes
    By anunat in forum Forms
    Replies: 15
    Last Post: 07-09-2012, 03:09 PM
  2. Dependent Combo Boxes
    By schwabe in forum Forms
    Replies: 3
    Last Post: 01-09-2012, 04:33 PM
  3. Combo Boxes with dependent queries
    By K Roger in forum Access
    Replies: 3
    Last Post: 09-27-2011, 11:58 AM
  4. Dependent List Boxes do not refresh using ReQuery
    By weeblesue in forum Programming
    Replies: 2
    Last Post: 03-28-2011, 08:47 AM
  5. Replies: 3
    Last Post: 02-26-2009, 10:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums