Results 1 to 3 of 3
  1. #1
    cafirf is offline Novice
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    10

    Limit ComboBox value based on other ComboBox Selection

    Hi team!



    I added two combobox in a form from two tables connected to each other. Table A is the Master and Table B is the child. I created the form macro that requeries ComboBox B (Control Source: Table B) after ComboBox A (Control Source: Table A) value is selected.

    ComboBox B has a query with a criteria to filter the selection from ComboBox A [Forms]![frm_C]![Table_A], so I am only able to see values from ComboBox B that are related to ComboBox A

    The problem is, after I update column A at the form, all rows from all rows in the Form changes and not only the row I am using.

    need your help pls!

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933

  3. #3
    cafirf is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2015
    Posts
    10
    Quote Originally Posted by Ajax View Post
    Hi Ajax thank you! I used the the example in the link you provided. It worked almost perfectly. I created a macro on ENTER and EXIT events just as the example. 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.



    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.



    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. I went through all the example file but couldn't find any difference in the codes or Form specitication.

    Pls help !!
    Last edited by cafirf; 03-01-2016 at 02:49 PM. Reason: typo

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

Similar Threads

  1. Replies: 11
    Last Post: 11-21-2014, 01:17 PM
  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