I would do this using a gp script tool. The tool would have two parameters: Select Mall ID and Select Store ID. The script tool would also have a validation script that would control: when the script tool is first opened, only the Select Mall ID parameter would display a list of mall ids in a parameter pulldown box. Once you select a mall id, then the validation script would display on the Store IDs for that mall.The script tool would then pass the two parameters to the calling python script that would automagically set a layer def query.Here is a sample main python script that the script tool would call.mallID = arcpy.GetParameterAsText(0) #the first parameter in script tool storeID = arcpy.GetParameterAsText(1) #the second parameter in script tool mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "My Mall Layer")[0] lyr.definitionQuery = '"MallID" = ' + str(mallID) + ' AND "StoreID" = ' str(storeID) arcpy.RefreshActiveView()
The validation script (a property of the script tool) would look something like:def initializeParameters(self): #THIS IS CALLED WHEN THE SCRIPT TOOL OPENS AND AUTO POPULATES THE FIRST PARAMETER """Refine the properties of a tool's parameters. This method is called when the tool is opened.""" #Generate unique list of Mall IDs import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") mlyr = arcpy.mapping.ListLayers(mxd, "My Mall Layer") fieldName = "MallID" rows = arcpy.SearchCursor(mlyr.dataSource) uniqueMallList = [] for row in rows: if row.getValue(fieldName) not in uniqueMallList: uniqueMall.append(row.getValue(fieldName)) uniqueMallList.sort() self.params[0].filter.list = uniqueMallList return def updateParameters(self): #THIS IS CALLED WHEN THE FIRST PARAMETER IS SELECTED AND POPULATES 2ND PARAMETER """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parmater has been changed.""" import arcpy if self.params[0].value: #Generate unique list of Store IDs slyr = arcpy.mapping.ListLayers(mxd, "My Store Layer") fieldName = "StoreID" rows = arcpy.SearchCursor(slyr.dataSource) uniqueStoreList = [] for row in rows: if row.getValue(fieldName) not in uniqueStoreList: uniqueStoreList.append(row.getValue(fieldName)) uniqueStoreList.sort() self.params[1].filter.list = uniqueStoreList return
This code is untested and I'm sure has some silly typos but all the parts are here. I hope this helps,Jeff