# DB Drop Down List allows selection that is not in List

**URL:** <https://forum.inductiveautomation.com/t/db-drop-down-list-allows-selection-that-is-not-in-list/34276>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [April 28, 2020, 5:46pm UTC](https://forum.inductiveautomation.com/t/db-drop-down-list-allows-selection-that-is-not-in-list/34276 "2020-04-28T17:46:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhicks1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mhicks1/32/14121_2.png) [@mhicks1](https://forum.inductiveautomation.com/u/mhicks1)\
**Post date:** [April 28, 2020, 5:46pm UTC](https://forum.inductiveautomation.com/t/db-drop-down-list-allows-selection-that-is-not-in-list/34276/1 "2020-04-28T17:46:06Z")

</div>

Hello, I am using a Drop Down List to select from a DB file. I would like to prevent a selection that is not in the list to be displayed.

Example, if My part number is BB777888 and I enter BB77, and select it, I would like to display EMPTY so we can then choose a correct part number or leave it as EMPTY if we are not using it.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 28, 2020, 6:31pm UTC](https://forum.inductiveautomation.com/t/db-drop-down-list-allows-selection-that-is-not-in-list/34276/2 "2020-04-28T18:31:43Z")

</div>

You’ll need to monitor for changes in the selectedLabel property. There are two possibilities for resetting the dropdown.

- Typing in an invalid entry from a no selection state
- Typing in an invalid entry from a previous valid entry.

Try this in the propertyChange event:

```python
if event.propertyName == 'selectedLabel':

	# check for invalid entry from no selection state
	if event.source.selectedValue == event.source.noSelectionValue and event.source.selectedLabel != event.source.noSelectionLabel:
		event.source.selectedLabel = event.source.noSelectionLabel
	
	# check for invalid entry from previous valid entry
	if event.source.selectedValue != event.source.noSelectionValue and event.source.selectedLabel != event.source.selectedStringValue:
		event.source.selectedValue = -1

```

---

<div class="post-metadata">

**Author:** ![mhicks1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mhicks1/32/14121_2.png) [@mhicks1](https://forum.inductiveautomation.com/u/mhicks1)\
**Post date:** [April 28, 2020, 6:55pm UTC](https://forum.inductiveautomation.com/t/db-drop-down-list-allows-selection-that-is-not-in-list/34276/3 "2020-04-28T18:55:07Z")

</div>

OK. So I will need to try that code in my “Accept” button on the propertyChange tab, correct?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/50c736547812750fb568518a58e1ed389716fc45.png)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 28, 2020, 7:01pm UTC](https://forum.inductiveautomation.com/t/db-drop-down-list-allows-selection-that-is-not-in-list/34276/4 "2020-04-28T19:01:26Z")

</div>

I had put mine in the propertyChange event of the dropdown.

---

<div class="post-metadata">

**Author:** ![mhicks1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mhicks1/32/14121_2.png) [@mhicks1](https://forum.inductiveautomation.com/u/mhicks1)\
**Post date:** [April 28, 2020, 8:18pm UTC](https://forum.inductiveautomation.com/t/db-drop-down-list-allows-selection-that-is-not-in-list/34276/5 "2020-04-28T20:18:21Z")

</div>

OK. Thank you for the help. I will give it a shot tonight.

---

<div class="post-metadata">

**Author:** ![mhicks1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mhicks1/32/14121_2.png) [@mhicks1](https://forum.inductiveautomation.com/u/mhicks1)\
**Post date:** [April 28, 2020, 8:54pm UTC](https://forum.inductiveautomation.com/t/db-drop-down-list-allows-selection-that-is-not-in-list/34276/6 "2020-04-28T20:54:06Z")

</div>

Thank you again for the help. I added your code to the Drop Down and it got me what I asked for. After that I found another bug but was able to fix because of how you helped me.

I compared my Material Choice text to the Drop down selected string value to enable my Accept button.

Works like a champ…

Nothing better than a day where you learn at least 10 new things…
