I have made a Python add in toolbar that has 3 combo boxes with one button. The add in allows for a user to choose a layer, choose a field from the selected layer, enter a keyword, and then when the search button is pressed, a query is applied and the extent of the data frame is zoomed to selected features. Before I go on, the tool works perfectly just as I designed it except for when the field type is 'String'. Then to make it work the user must enter the keyword in quotes. My goal is to not have the user worrying about having to type stuff in quotes because then the user would have to know what the field type is for when they are searching and that is not the case.
This works because the field.type of HYDRANT_NO is not 'String'. In the below example, the user selects the LastName field which is a 'String' field.type. The first figure returns no results. The second image returns the expected number of results.
1. Does Not work
2. Does work - The actual word in the table is JONES and is handled in the code on how to handle it which is why it works.
I have taken into account that I am using a personal geodatabase and that matters when writing the where_clause since it differs from ArcSDE and file geodatabases. The way that I have written the query WORKS when I do it manually in ArcMap whether it is typed into the Python window or using the Select Layer By Attribute Tool. Below is how I wrote how to check the keywords for string. It works manually but not with the addin. I have also attached the full add-in which will show the variables that are referenced. I feel that I am either missing something so small or it doesn't work because it can't work that way.