Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2012
    Posts
    2

    Unanswered: Cascading Combo Boxes-Access 2007

    Hello All,

    I am new at Access and have been reading posts and trying to get all the help I can from tutorials online and books but I can't get my cascading combo boxes to work properly.

    I have created a Form called "Input"

    I have three combo boxes:
    Box1 is cboMake
    Box 2 is cboModel
    Box 3 is cboTrim

    Tables are:
    Make
    MakeID=Primary Key
    Make=Make of Car

    Model
    ModID=Primary Key
    Make=Joined to Make Table by Lookup Wizard (MakeID=Text)
    Model=Model of Car

    Trim
    TrimID=Primary Key
    Model=Joined to Model Table by Lookup Wizard (ModID=Text)
    Trim=Trim package of Car

    I can select my Make of the car in cboMake but cboModel is blank. I have noticed in the design view that my cboMake says make (I think this means it is bound by the Make table). My cboModel says unbound. I have used the following code to update the Rowsource for cboModel in the AfterUpdate Event of cboMake.

    Private Sub cboMake_AfterUpdate()

    Me.cboModel.RowSource = "SELECT Model FROM" & "Model WHERE Make =" & Me.cboMake & "ORDER BY Model"

    Me.cboModel.Requery

    End Sub

    Here are so parameters that I have on my cboModel:
    Column Count=2
    Column Widths=0",3"
    Width=3"
    Control Source=blank
    Row Source=blank
    Row Source Type=Table/Query
    Bound Column=3


    I haven't attempted to get the cboTrim to work yet. Any help would be appreciated. Thank you!

    Laurie

  2. #2
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Look at "Demo4ComboA2000.mdb" (attachment, zip).
    Maybe it can help you. Open Form1 and try.
    Look at VBA, tables.
    Attached Files Attached Files

  3. #3
    Join Date
    Mar 2012
    Posts
    2

    Question

    Thank you for your help. I have looked at your demo and changed all the code but still I can't get my second combo box to populate. I select my make and the model options should appear but the combo box is blank.

    I have changed my second combo box (cboModel) to:
    Row Source
    SELECT DISTINCTROW Model.Model FROM Model WHERE (((Model.Make)=[Forms]![Input]![cboMake])) ORDER BY Model.Model;

    like the example you gave but no luck.

    My VB code was changed and is now as follows:


    Option Compare Database
    Option Explicit
    Dim Inx


    Private Sub cboMake_AfterUpdate()

    Me.cboModel = ""
    Me.cboTrim = ""
    Me.cboModel.Requery
    Me.cboTrim.Requery

    End Sub


    Private Sub cboModel_AfterUpdate()

    Me.cboTrim = ""

    Inx = DCount("[Trim]", "Trim", "[Model]=""" & Forms!Input!cboModel & """")
    If Inx > 0 Then
    Me.cboTrim.Enabled = True
    Me.cboTrim.Requery

    Else
    Me.cboTrim.Enabled = False

    End If

    End Sub


    I know there is something I am missing, but can't figure it out. Any help would be appreciated. Thank you!
    Last edited by Missbehave; 03-15-12 at 14:42.

  4. #4
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    I suspect that you made a mistake in ROW SOURCE for cboModel and cobTrim.
    Maybe a tblName, or a field name.
    Check it.
    Last edited by MStef-ZG; 03-16-12 at 04:54.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •