ComboBox true Change

  • Thread starter Thread starter Damien
  • Start date Start date
D

Damien

How can I track true Change events in a bound ComboBox ?

ie

If a bound ComboxBox has a value in it, and the user
clicks the dropdown, the Change event is fired.

This isn't really a true change if the user is just
clicking the box to see what else in there.

I'm thinking I need to use a Static variable or module-
level variable, but am wondering if there is a better way,
or someone has an example of recording a true change.

Thanks


Damien
 
Damien said:
How can I track true Change events in a bound ComboBox ?

ie

If a bound ComboxBox has a value in it, and the user
clicks the dropdown, the Change event is fired.

This isn't really a true change if the user is just
clicking the box to see what else in there.

I'm thinking I need to use a Static variable or module-
level variable, but am wondering if there is a better way,
or someone has an example of recording a true change.

Thanks


Damien

If you want to detect the case where a control's value is "changed" to
itself, you have to compare against something. If it's a bound control,
then you can use the control's OldValue property. For example,

Private Sub cboMyCombo_AfterUpdate()

Dim blnChangedValue As Boolean

With Me!cboMyCombo
If IsNull(.Value) <> IsNull(.OldValue) Then
blnChangedValue = True
Else
If .Value <> .OldValue Then
blnChanged = True
End If
End If
End With

If blnChanged Then
' ... do something ...
End If

End Sub

If the control is unbound, then yes, you need to use code to capture
some "initial" value of the control in a static or module-level
variable, because its OldValue property (IIRC) will then always be equal
to its Value property.
 
Back
Top