AnsweredAssumed Answered

Clearing a combobox of Previous Selections!

Question asked by MLCouden on Mar 13, 2013
Latest reply on Mar 13, 2013 by scjpike
I am loading comboboxes upon selection of previous comboboxes selections. I am having trouble clearing the box so that only the AddItems will show. For Example: Depending on what year they select only certain city names should show in the last combobox. But the combobox instead of clearing just keeps adding the city names. I have .Clear programmed but it's not working.  I've included my code below:

Private Sub UserForm_Initialize()      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()            If cboStations.Text = "Urban" Then         cboYear.Clear       cboYear.AddItem "2010"       cboYear.AddItem "2011"       cboYear.AddItem "2012"                                    End If                   End Sub Private Sub cboYear_Change()               If cboYear.Text = "2010" Then           cboDistrict.Clear         cboDistrict.AddItem "Abilene"         cboDistrict.AddItem "Amarillo"         cboDistrict.AddItem "Austin"         cboDistrict.AddItem "San_Antonio"         cboDistrict.AddItem "Waco"         cboDistrict.AddItem "Wichita_Falls"     ElseIf cboYear.Text = "2011" Then           cboDistrict.Clear         cboDistrict.AddItem "Beaumont"         cboDistrict.AddItem "Houston"     ElseIf cboYear.Text = "2012" Then           cboDistrict.Clear         cboDistrict.AddItem "Brownwood"         cboDistrict.AddItem "Bryan"         cboDistrict.AddItem "Childress"         cboDistrict.AddItem "Corpus_Christi"         cboDistrict.AddItem "El_Paso"         cboDistrict.AddItem "Lubbock"         cboDistrict.AddItem "Odessa"         cboDistrict.AddItem "Yoakum"                          End If                       End Sub

Outcomes