combo box event

I have an editable combo box , wherein the user selects an item and the remaining fields on the form get populated. Theres a scenario wherin the user can type in new text in the combo box , make some changes to the remaining fields and after this he selects another code from the list without saving the changes. I prompt him with a vbyesnocancel msgbox. On click of cancel I have to populate the combo text with the user typed text. Doing this in the click event clears the text field after the Exit Sub.  Could you provide me with a method for retaining the text.

Who is Participating?
rdobsonConnect With a Mentor Commented:
There is a microsoft kb article that provides a solution around this problem:

If you need more details of implementation, just let me know and I will post code.
you mean ComboBox.Text ?!
try using the validate event...
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

AssistiaAuthor Commented:
Yes it is combobox.text !!!
I am currently using VB 5.0 and the combo box events do not include any validate event as suggested by ute
not sure what you mean, but this might be it...

MsgBox "The item is " & TheCombo.List(TheCombo.ListIndex)

Is this what you were looking for?!

btw, you might want to do that on LostFocus()

AssistiaAuthor Commented:
Thanks Rdobson , this is exactly what I was looking for ..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.