If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > State of a Combo Box

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-28-11, 01:07
JerryDal JerryDal is offline
Registered User
 
Join Date: Jan 2002
Location: Bay Area
Posts: 473
Question 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
Reply With Quote
  #2 (permalink)  
Old 10-10-11, 16:43
JerryDal JerryDal is offline
Registered User
 
Join Date: Jan 2002
Location: Bay Area
Posts: 473
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
File Type: zip StateOfComboDemo.zip (17.5 KB, 6 views)
Reply With Quote
  #3 (permalink)  
Old 10-12-11, 05:39
Betinawilliams Betinawilliams is offline
Registered User
 
Join Date: Oct 2011
Posts: 1
State of a Combo Box

Hi
It help me a lot, thanks for sharing.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On