Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2012
    Posts
    2

    Unanswered: combo box cascading

    Hello Im trying to use a few cascading combo boxes, I have been reading through the forum but havent found an answer to my problem.
    Ive tryed to solve it in two diferent ways

    Table cod_caja
    Fields, cod_almacen, cod_habitaculo, cod_armario

    I want to cascade two three combo boxes
    cboalm
    cbohab
    cboarm

    When I cascade cbohab with cboalm it works perfectly both ways but when i try to cascade cboarm with the following conditions it doesnt work.
    Notice that cod_almacen and cod_habitaculo are unic whereas cod_armario is not. And afterwards I would like to cascade other 3 combo boxes which will depend on various of the comboboxes.


    1. Doing a query on rowsource of properties dialoge box

    SELECT DISTINCT cod_caja.cod_almacen, cod_caja.cod_habitaculo, cod_caja.cod_armario
    FROM cod_caja
    WHERE ((([cod_almacen]=[Formularios]![formname]![cboalm] & [cod_habitaculo])=[Formularios]![formname]![cbohab]));

    2. Coding in VB

    Private Sub cbohab_AfterUpdate()
    Me.cboarm.RowSource = " SELECT DISTINCT cod_almacen, cod_habitaculo, cod_armario" & " FROM cod_caja " & " WHERE (cod_almacen = ' " & Nz(Me.cboalm.Value) & " ' & cod_habitaculo = '" & Nz(Me.cbohab.Value) & " ') "
    End Sub

    Thanks a lot

  2. #2
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Look at "Demo4ComboA2000.mdb" (attachment, zip).
    Open Form1 and try, (4 cascading combo).
    Look at VBA.
    Attached Files Attached Files

  3. #3
    Join Date
    Aug 2012
    Posts
    2
    Hello, thanks for you quick answer.
    I need to do what you suggest me but i have a different data structure. I have all my data in the same table, and I was looking for a posibility of doing it just adding conditions to the comboboxes. Is it necesary that I create a jerarchical structure to make it work?
    Thanks

  4. #4
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Send a short example of your table, (or mdb, Access 2000, or 2002-2003),
    and tell what you want to do.

  5. #5
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    994
    Provided Answers: 2
    The idea of cascading combo boxes is that they allow you to drill down through a hierarchy. A set can be based on a single table, but it requires all columns used before the final one not to have unique values. This is not the case with your data structure as described.
    When I cascade cbohab with cboalm it works perfectly both ways
    This does not ring true. Cascades only go in one direction - the value selected in the first combo box drives the value(s) that appear in the second, and so on. Once you have selected a value in the first box, it should not be affected by subsequent selections.

    MStef-ZG is right. Post an example of your data, along with your expected results, and we might be able to help.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

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