Results 1 to 12 of 12
  1. #1
    bishop is offline Novice
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Posts
    21

    How to synchronize Access combo boxes...stuck

    Here is my problem. I am stuck on how to set this up. Here are my tables:

    tblCategories
    tblExercises


    tblSubCategories Back, tblSubCategories Biceps, tblSubCategories Triceps, etc.

    tblCategories has one column:
    Column name "Categories"
    Shoulders
    Core
    Biceps
    Triceps

    All tblSubCategories has multiple columns with data underneath. Example:
    tblSubCategories Back
    Column name DB
    Back Row
    Column name TRX
    TRX Rows
    TRX Rear Fly
    Column name Band
    Band Rows

    I need to create a form that has 3 combo box that is dependent on the other. For example:

    If I pick Back from combo box Categories , the SubCategory combo box would have column names from that (DB, TRX, Band, etc)

    Then the 3rd combo box would allow me to pick the exercises from the SubCategory combo box. So if I chose TRX it would list; TRX Rows, TRX Rear Fly, etc.

    Any help on this would be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Don't try setting RowSource for the two dependent comboboxes in the properties dialog. Use VBA in combobox AfterUpdate events to set the RowSource property. Use a Select Case structure.

    The second combobox RowSourceType could be Field List. Then use the VBA code to set the RowSource to the correct table.

    Set the two dependent comboboxes Visible property to No then in code make each visible after selection in previous combobox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bishop is offline Novice
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Posts
    21
    Quote Originally Posted by June7 View Post
    Don't try setting RowSource for the two dependent comboboxes in the properties dialog. Use VBA in combobox AfterUpdate events to set the RowSource property. Use a Select Case structure.
    How would I go about doing that?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Are you not familiar with VBA coding? The Select Case is a structure common to most if not all programming languages.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    bishop is offline Novice
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Posts
    21
    No sorry. I am new to all this and have researched throughout the web before posting this question. Getting very frustrated.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You have two ways to code in Access - macros and VBA. With rare exception, I use only VBA. I don't think macro can accomplish this particular procedure. Here is an example of a Select Case setting properties of a combobox based on selection of first combobox.
    Code:
    Sub cboFirstCombo_AfterUpdate()
        Select Case Me.cboFirstCombo
            Case ""
                Me.cboSecondCombo.Value = Null
                Me.cboSecondCombo.RowSourceType = ""
                Me.cboSecondCombo.RowSource = ""
            Case "State Number"
                Me.cboSecondCombo.RowSourceType = "Table/Query"
                Me.cboSecondCombo.RowSource = "SELECT DISTINCT StateNum FROM Submit;"
            Case "Sample Type"
                Me.cboSecondCombo.RowSourceType = "Value List"
                Me.cboSecondCombo.RowSource = "Acceptance;Independent Assurance;Information;Preconstruction;Quality"
        End Select
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    nurul is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    37
    hye June7,

    i need your help to explain to me this.
    "SELECT DISTINCT StateNum

    what is actually DISTINCT?
    is't StateNum is field name?


    i already make it like this but it will list all data in the field when i select the dropdown. suppose be it will only show the AA project.

    Case "AA"
    Me.qproject1.RowSourceType = "Table/Query"
    Me.qproject1.RowSource = "SELECT DISTINCT project FROM Table4;"


    can you help me to solve this problem..

    thank you.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    DISTINCT is a keyword used in SQL query so that only one occurrence of each value in a field will show in the results. Yes. StateNum is a fieldname in my table.

    If you want only AA project to show, then need criteria in the query. Use WHERE clause. However, won't the result be a single record?
    Me.qproject1.RowSource = "SELECT project FROM Table4 WHERE project=" & Me.combobox
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    nurul is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    37
    one more question,

    Me.combobox is what..?
    is it my combobox name for example qregion1

    i want when i select the qregion1 then for qproject1, it will list the project that have in qregion1..

    thank you

  10. #10
    nurul is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    37
    one more thing, the project will be more than one that will listed

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Use your combobox name in place of 'combobox'.

    Me.qproject1.RowSource = "SELECT project FROM Table4 WHERE region='" & Me.qregion1 & "'"

    Note the apostrophe delimiters in the WHERE clause. These are needed if region field is text. Date/Time type would use # and number type use nothing.

    Then you need to requery qproject1 combobox:
    Me.qproject1.Requery
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    nurul is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2012
    Posts
    37
    yeaayyy it workk....

    thank you very much June7..

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

Similar Threads

  1. Combo boxes Access 2007
    By Scotlands Lion in forum Access
    Replies: 13
    Last Post: 08-05-2014, 02:40 AM
  2. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  3. Find as you type Combo boxes in MS Access
    By HAPPYWITHU in forum Programming
    Replies: 13
    Last Post: 06-03-2010, 08:41 AM
  4. Stuck with combo boxes for ever !!! :(
    By Evgeny in forum Forms
    Replies: 9
    Last Post: 04-14-2010, 09:03 PM
  5. Replies: 3
    Last Post: 03-28-2009, 06:06 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