AnsweredAssumed Answered

Script for populating comboboxes upon selection of each. Called Selection Change!

Question asked by MLCouden on Mar 12, 2013
Latest reply on Mar 12, 2013 by ldonahue
I am writing a script in VBA (ArcObjects) 6.0 for 3 comboboxes to communicate. For Example: When the user selects Urban from the first combobox the second combobox populates with the years 2010 and 2011, the user then selects a year from the second combobox and the third combobox is populated with Austin and Houston. I am trying to use If then loop but I am getting the error of "Invalid Qualifier" on my cboYear box which I am not understanding because it is used thoughout the whole script. My code is below.

Private Sub UserForm_Initialize()           cboStations.Value = "Annual"     cboYear.Value = "2012"          Dim WorkDB As DAO.Database     Dim workRecSetA As DAO.RecordSet     Dim workRecSetB As DAO.RecordSet     Dim x As Integer                    Set WorkDB = DBEngine.OpenDatabase("K:\TASS\2 - GEO-DATA PROCESSING SUPPORT\MICHELLE'S WORK_ENTER NOT!!\Work Folder\Map Automation Project\Access Tables\Map_Automation.mdb")     Set workRecSetA = WorkDB.OpenRecordset(Name:="select * from Districts order by District_Name", Type:=dbOpenDynaset)     Do Until workRecSetA.EOF         cboDistrict.AddItem workRecSetA("District_Name")         workRecSetA.MoveNext     Loop     Set workRecSetB = WorkDB.OpenRecordset(Name:="select * from Stations order by Station_Name", Type:=dbOpenDynaset)     Do Until workRecSetB.EOF         cboStations.AddItem workRecSetB("Station_Name")         workRecSetB.MoveNext     Loop          For x = 2010 To 2015         cboYear.AddItem x     Next            End Sub  Private Sub cmdCancel_Click()      frmMapSetUp.Hide      End Sub Private Sub cboStations_Change()          Dim cboYear As String          If cboStations.Text = "Urban" Then       cboYear.AddItem "2010", "2011", "2012"     >Here is where I am getting the invalid qualifier error!!                                    End If                   End Sub Private Sub cboYear_Change()      Dim cboDistrict As String          If cboYear.Text = "2010" Then         cboDistrict.AddItem "Abilene", "Amarillo", "Austin", "San_Antonio", "Waco", "Wichita_Falls"     Else         cboYear.Text = "2011"         cboDistrict.AddItem "Beaumont", "Houston"                      Else         cboYear.Text = "2012"         cboDistrict.AddItem "Brownwood", "Bryan", "Childress", "Corpus_Christi", "El_Paso", Lubbock, "Odessa", "Yoakum"     End If                       End Sub

Outcomes