Results 1 to 3 of 3
  1. #1
    Bcanfield83 is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    81

    Question Changing Row Source of Combo Box based upon Check Box selection

    Hi Folks,

    I'm looking to modify the Row Source of a couple Combo Boxes on a form based upon whether or not a check box is True or False.
    Is there a way to do this through one of the Combo Box properties? (e.g.: obviously "AfterUpdate" wouldn't work since the Row Source needs to be modified prior to the Combo Box being clicked).
    Currently, I have it in the AfterUpdate Property on the Check Box control but curious if there's another way to incorporate it.

    Code:
    Private Sub chkRCActiveYN_AfterUpdate()
    
    
    Dim strSQL As String
    
    
    strSQL = "SELECT SEC_ROLE_LISTING.RLS_ID, SEC_ROLE_LISTING.RLS_NAME " & _
     " FROM SEC_ROLE_LISTING " & _
     " WHERE SEC_ROLE_LISTING.RLS_ENABLED_YN = 'Y'" & _
     " ORDER BY SEC_ROLE_LISTING.RLS_NAME"
    
    
    If Me!chkRCActiveYN = True Then
    
    
        Me!cboNETRoleCompare1.RowSource = strSQL
        Me!cboNETRoleCompare2.RowSource = strSQL
    
    
    End If
    
    
    End Sub


  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    I would use your current approach, partly because altering combo row source at the point of click seems like a micro second too close to when it's needed to be known and isn't necessary to leave it to that point.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Bcanfield83 is offline Advanced Beginner
    Windows 7 32bit Access 2016
    Join Date
    May 2018
    Posts
    81
    Thanks! It does seem to be working fine, so "if it ain't broke.."
    In the past, I've taken a different approach of creating 2 distinct combo boxes - each with a different row source, and then use the check box control to either hide or show the appropriate one (e.g.: if box is checked, set cbo1 visible property to "True" and cbo2 visible property to "False"; if box is unchecked, then do the reverse.)

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

Similar Threads

  1. Replies: 6
    Last Post: 10-08-2017, 01:10 PM
  2. Replies: 3
    Last Post: 06-22-2017, 12:30 PM
  3. Replies: 2
    Last Post: 08-18-2015, 10:23 AM
  4. Replies: 3
    Last Post: 12-11-2012, 09:12 AM
  5. Changing combo-box to check box (a la Excel filter)
    By kagoodwin13 in forum Queries
    Replies: 3
    Last Post: 07-31-2012, 08:23 PM

Tags for this Thread

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