'This is the code I will discuss on Wednesday for selecting features, 'and it is from Chapter 17 in Getting to Know ArcObjects: Programming 'ArcGIS with VBA by Robert Burke, 2003 (ESRI Press. ISBN: 1-58948-018-x). Option Explicit 'SelectionChange event code runs when a user clicks a name in the dropdown list Private Sub cboStateNames_SelectionChange(ByVal newIndex As Long) 'Declare and set variable for the map document Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument 'Declare and set variable to get the map collection from IMxDocument Dim pMaps As IMaps Set pMaps = pMxDoc.Maps 'Declare and set two IMap variables for EPA and USA maps Dim pEPAMap As IMap Set pEPAMap = pMaps.Item(0) Dim pUSAMap As IMap Set pUSAMap = pMaps.Item(1) 'Declare and set variables for toxic sites and county layers using QueryInterface Dim pToxicLayerDef As IFeatureLayerDefinition Set pToxicLayerDef = pEPAMap.Layer(0) Dim pCountyLayerDef As IFeatureLayerDefinition Set pCountyLayerDef = pEPAMap.Layer(1) 'Declare and set a string to hold query Dim strQuery As String strQuery = "State_Name = '" & cboStateNames.EditText & "'" 'Declare variable to EPA map's IActiveView and do QueryInterface _ from the pEPAMap variable that is declared to IMap Dim pEPAActiveView As IActiveView Set pEPAActiveView = pEPAMap '(Part of code to highlight the selected state in the USA map in red) 'Declare variable and set it to the states layer in the USA map Dim pUSALayer As IFeatureSelection Set pUSALayer = pUSAMap.Layer(0) 'Determine if user clicked If cboStateNames.EditText = "" Then 'Runs when user clicks and removes definition queries from both layers pToxicLayerDef.DefinitionExpression = "" pCountyLayerDef.DefinitionExpression = "" 'Clears the selection in the USA map when user clicks pUSALayer.Clear Else 'Runs when user clicks a state and sets definition query to those states and counties pCountyLayerDef.DefinitionExpression = strQuery pToxicLayerDef.DefinitionExpression = strQuery '(Part of code to highlight the selected state in the USA map in red) 'Create a QueryFilter for the first argument of the SelectFeatures method Dim pFilter As IQueryFilter Set pFilter = New QueryFilter '(Part of code to highlight the selected state in the USA map in red) 'Set QueryFilter's WhereClause = strQuery pFilter.WhereClause = strQuery '(Part of code to highlight the selected state in the USA map in red) 'Make the selection with the SelectFeatures method pUSALayer.SelectFeatures pFilter, esriSelectionResultNew, True '(Part of code to highlight the selected state in the USA map in red) 'Create an RGB color and set its Red property to 200 Dim pRedColor As IRgbColor Set pRedColor = New RgbColor pRedColor.Red = 200 '(Part of code to highlight the selected state in the USA map in red) 'Set the states layer's Selectioncolor property = the RgbColor object Set pUSALayer.SelectionColor = pRedColor End If '(Part of code to highlight the selected state in the USA map in red) 'QueryInterface to get pUSAMap's IActiveView interface _ and run its Refresh method on the USA map Dim pUSAActiveView As IActiveView Set pUSAActiveView = pUSAMap pUSAActiveView.Refresh 'After code to pick a state, to run IActiveView's Refresh method on the EPA map pEPAActiveView.Refresh End Sub