OnChange combo box

C

Confused Slug

I am using the On Change event to peform actions when the value selected in a
Combo box changes. However, if i select the value in the list which is the
same as the current value for the combo box the On Change event still sees
this as a change. How do i prevent this so that the On Change event only
occurs if the value selected in the list is different from the current combo
box value?
 
M

Marshall Barton

Confused said:
I am using the On Change event to peform actions when the value selected in a
Combo box changes. However, if i select the value in the list which is the
same as the current value for the combo box the On Change event still sees
this as a change. How do i prevent this so that the On Change event only
occurs if the value selected in the list is different from the current combo
box value?

Do not use the Change event for this. It fires for every
keystroke typed into the combo box's text portion. As your
question indicates, it doesn't provide the facilities to do
what you want either. Instead, you should perform your
actions in the combo box's AfterUpdate event.

If the combo box is bound to a record source field, you can
check the value against the combo box's OldValue property:

If Me.combobox <> Me.combobox.OldValue Then
'do your actions here
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top