Determine if combo value is in the list

J

John J.

I have a combobox in which users can select from the list but they can also
enter a custom value. When executing code from a button I need to determine
if the combobox value is a custom one or picked from the list. Is there a
way to this?
Thank you,
John
 
D

Douglas J. Steele

How is the combo box populated: by a query or by adding entries to it?

If your combo box is being populated from the contents of a table, do you
want their new entry added to that table?

If so, set the combo box's LimitToList property to True, and put code in its
NotInList event. (See http://www.mvps.org/access/forms/frm0015.htm at "The
Access Web" for sample code)

Otherwise, you can always loop through the items in the combo box, comparing
to the value input.
 
D

Dirk Goldgar

John J. said:
I have a combobox in which users can select from the list but they can also
enter a custom value. When executing code from a button I need to determine
if the combobox value is a custom one or picked from the list. Is there a
way to this?


If the combo box's current value is not one of the items in the list, its
ListIndex property will be -1.
 

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