Results 1 to 4 of 4
  1. #1
    cafirf is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2015
    Posts
    10

    Filter the ComboBox Values Based in Other ComboBox Selection

    Hi Team I need a help!

    I am trying to make a ComboBox in a Form to show only the values related to the selection of other ComboBox. I created two macros in the Child ComboBox: The first is a ENTER Event, and changes the rowsoure to show only the values related to the ComboBox selection on the first ComboBox, the second is an Exit event, that changes back the query to show all available values. I also created a macro in the master ComboBox to clean the child ComboBox once I change the selection in the Master ComboBox.


    I created 3 codes:


    1- The first code erases the child ComboBox column, called "Categoria_2"selection
    2- the second is a ENTER event where the list is filtered to show only the values based on the Master ComboBox column (cdo_categoria_1) selection.
    3- The third code is a EXIT event to return the query that shows all records from the Child table.

    For some reason, my table has some bugs and when change rows in the child column the value of the last selected row in the child column simply disappear.

    Code:
    Private Sub cdo_Categoria_2_Enter()
        'MsgBox (cdo_Categoria_1)
        cdo_Categoria_2.RowSource = "SELECT [tbl_Categoria2].[ID],  [tbl_Categoria2].[Categoria_2], [tbl_Categoria2].[Categoria_1_2] FROM  tbl_Categoria2 WHERE [categoria_1_2] = [cdo_Categoria_1] ORDER BY  [Categoria_2] "
    End Sub
    
    Private Sub cdo_Categoria_2_Exit(Cancel As Integer)
        cdo_Categoria_2.RowSource = "SELECT [tbl_Categoria2].[ID],  [tbl_Categoria2].[Categoria_2] FROM tbl_Categoria2 ORDER BY  [Categoria_2]"
    End Sub
    
    Private Sub cdo_Categoria_1_AfterUpdate()
        cdo_Categoria_2 = ""
    End Sub
    so, when I change the comboBox from Categoria_2 column, the value of the last active row disappear.

    Pls help !!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Have you done a search on "Cascading Comboboxes" yet. There are tons of threads on the topic.

  3. #3
    cafirf is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2015
    Posts
    10
    Thank you RuralGuy, I have searched for this topic in the forum and on the internet but I could not find any Cascading ComboBox for Continuous forms.

  4. #4
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    if it is in the detail section the combobox in a continuous form must be bound to a field in the record source; if unbound it will change in all records. If bound or in the header of the continuous form it will behave the same as a single view form.

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

Similar Threads

  1. Replies: 8
    Last Post: 06-12-2014, 05:25 AM
  2. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  3. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

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