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