In the original, on the base, SearchTerm is set to txtSearch1 when ttSearch1 changes if userClickedSearch has changed from false to true. But look at the layer. txtSearch1 changes when txtSearch 1 (don't blame me if those names are confusing) loses focus, which it does when the mouse goes down on btnSearch. userClickedSearch value is changed to true when the mouse goes upafter going down (the default definition of clicking an object). So the search variable changes before the system recognizes that the search button has been clicked, and the condition is never fulfilled.