Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511

    Question Unanswered: State of a Combo Box

    Is there a way to test for the click on a combo box followed by collapsing the combo without changing the combo selection?

    For example, a click on the combo box displays a fixed list in the drop-down for an item in the list to be clicked. This is a list of the alphabet where one can click on a letter and navigate to an area of an alphabetically sorted list box.

    What I want to do is change properties (such as Visible or Enabled) of a set of command buttons while the combo is in a drop-down state, and I can do that in the DropButtonClick and Change events. This scheme does not work when there is no change, which is when the drop-down arrow is clicked and then clicked again without changing the selection.

    My alternative if this is not possible is to have the dropped down combo list cover up a set of command buttons to effectively hide them.
    Thanks.
    Jerry

  2. #2
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    I am presenting a solution to knowing when a combo box value has changed or if the value remains the same after an event. My solution is in the form of an attached demo (Excel 2003). By saving the combo value in the combo Tag, values can be compared at the next event to see if there is a change. The function below is called from the combo's events. Example:

    Code:
    Private Sub cboMyCombo_Change()
        
        Me.lblChange.Caption = "Change Event at " & Format(Now(), "HH:MM:SS")
        Call isCBO_Changed(Me.cboMyCombo.Tag, "Change")
        
    End Sub
    
    Private Function isCBO_Changed(oldCBOValue, whatEvent)
    'Add text to form label advising if combo box text is changed or unchanged
    Dim tmpBool As Boolean
    Dim WaitASec As Variant
     
        If oldCBOValue <> Me.cboMyCombo.Text Then tmpBool = True
        Me.cboMyCombo.Tag = Me.cboMyCombo.Text
        
        If tmpBool Then
            Me.lblCBOChangeStatus.Caption = _
            "The combo box value WAS CHANGED" & vbCrLf & _
            "in the " & whatEvent & " event" & vbCrLf & Format(Now(), "HH:MM:SS")
            Me.lblCBOChangeStatus.ForeColor = vbBlue
        Else
            Me.lblCBOChangeStatus.Caption = _
            "The combo box value WAS NOT CHANGED" & vbCrLf & _
            "in the " & whatEvent & " event" & vbCrLf & Format(Now(), "HH:MM:SS")
            Me.lblCBOChangeStatus.ForeColor = vbBlack
        End If
        
        If Me.optWaitYes Then       'if more than 1 combo event occurs,
            WaitASec = Now()        'the events log will display a different
            While Now() = WaitASec  'time for each event.
            Wend
        End If
        
    End Function
    RESOLVED
    Attached Files Attached Files

  3. #3
    Join Date
    Oct 2011
    Posts
    1

    State of a Combo Box

    Hi
    It help me a lot, thanks for sharing.

Posting Permissions

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