I am developing a website that has 2 comboboxes and 1 text input. The user can search for a record based on entering the name of a company on the text input, or search based on the name of a company and name of the county (on the dropdown box) or search based on the name of the company, name of the county and type of industry (the other drowpdown box). He can also select one criteria at time or two at a time. So because there 3 elements, there is a possibilty of 7 different types of search. I first had created a query for each (a query usin mxml tags) and it worked fine. But what I want to do is to create just one query and change the where clause according to the search options, but it is not working. I think there is something wrong with my query expression. Does anybody have any ideas on what needs to be changed? The query occurs after the user selects the options and click a search button. Then the graphic layer is created showing the points relative to the search and a datagrid shows the dataHere is the function for the button click to create the query protected function buttonclick():void { var querytask:QueryTask = new QueryTask(); querytask.url = "http://tfs-24279/ArcGIS/rest/services/ForestProducts/dynamic_layer_forest_products/MapServer/0" var query:Query = new Query(); query.outSpatialReference = myMap.spatialReference; query.outFields = ["Company"]; query.returnGeometry = true; query.where = expr; var expr:String = new String; querydg.dataProvider = querytask.executeLastResult.attributes; querydg.height=querytask.executeLastResult.attributes.length + 150 querydg.visible= querytask.executeLastResult !=null && querytask.executeLastResult.attributes.length>0 if (qText.text != "" && countycb.selectedItem != " " && industrycb.selectedItem != " ") { expr="Company Like '%{qText.text}%' AND County = '{countycb.selectedItem}' AND prim_bus = '{industrycb.selectedItem}'" } if (qText.text != " " && countycb.selectedItem == " " && industrycb.selectedItem == " " ) { expr= "Company Like '%{qText.text}%' " } if (qText.text =="" && countycb.selectedItem != " " && industrycb.selectedItem == " " ) { expr="County = '{countycb.selectedItem}'" } if (qText.text =="" && countycb.selectedItem == " " && industrycb.selectedItem != " " ) { expr= "prim_bus = '{industrycb.selectedItem}'" } if (qText.text != "" && countycb.selectedItem != " " && industrycb.selectedItem == " ") { expr="Company Like '%{qText.text}%' AND County = '{countycb.selectedItem}'" } if (qText.text != "" && countycb.selectedItem == " " && industrycb.selectedItem != " ") { expr = "Company Like '%{qText.text}%' AND prim_bus= '{industrycb.selectedItem}'" } if (qText.text =="" && countycb.selectedItem != " " && industrycb.selectedItem != " ") { expr = "County = '{countycb.selectedItem}' AND prim_bus= '{industrycb.selectedItem}'" } querytask.execute(query, new AsyncResponder (onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { if (featureSet.features.length == 0) { Alert.show("No matching records found. Please try again."); resizableDraggableTitleWindow.visible = false; querydg.visible = false; info.text = " "; } else { querydg.visible = true; resizableDraggableTitleWindow.visible = true; querydg.rowCount = querydg.dataProvider.length; myGraphicslayer.visible = true; import com.esri.ags.utils.GraphicUtil; } if (featureSet.features.length > 1) { info.text = "There are " + featureSet.features.length + " matching records"; } if (featureSet.features.length == 1) { info.text = "There is " + featureSet.features.length + " matching record"; } } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString(), "Query Problem"); } }