# Preventing Double Barcode Scans

**URL:** <https://forum.inductiveautomation.com/t/preventing-double-barcode-scans/22855>\
**Category:** Ignition\
**Created:** [February 25, 2019, 3:51pm UTC](https://forum.inductiveautomation.com/t/preventing-double-barcode-scans/22855 "2019-02-25T15:51:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 25, 2019, 3:51pm UTC](https://forum.inductiveautomation.com/t/preventing-double-barcode-scans/22855/1 "2019-02-25T15:51:16Z")

</div>

I have a text entry component that I have set to remain in focus at all times. This screen is dedicated to barcode scanning. On the propertyChange event, I have it read the text input, parse it, and write it to a tag and insert into a db table. Each scan compares the input text to the tag written to previously. If they are the same, it is supposed to reject the scan and do nothing. Every now and then a double scan still gets through. It seems that the employee scans it and may not see it populate the table, showing the scan history, immediately so they scan it again to make sure it takes. Every time I try to recreate a double scan it never works, I always get just one scan input. Am I missing something, is there a better way to do this? The basic code works like this,

```auto
if event.PropertyName == 'text':
        input = event.source.text
        lastScan = system.tag.read('compare').value
        if input != lastScan:
                insert into db
                write to compare tag

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 25, 2019, 4:39pm UTC](https://forum.inductiveautomation.com/t/preventing-double-barcode-scans/22855/2 "2019-02-25T16:39:46Z")

</div>

> [@dkhayes117](#):
>
> input = event.source.text

It's possible that there's a race condition between the property change event firing on your change script and the property change firing on the component itself. Try `input = event.newValue` instead of reading the component's property.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [February 25, 2019, 6:19pm UTC](https://forum.inductiveautomation.com/t/preventing-double-barcode-scans/22855/3 "2019-02-25T18:19:38Z")

</div>

I changed the code like you suggested and everything seems to work fine. I will keep monitoring it and see if it remedies the double scan. Thanks
