I am trying to write code to have 3 comboboxes change upon selection of each. For Example: In combobox 1 they choose Urban which populates combobox 2 with 2010 and 2011 which then populates combobox 3 with houston, austin and so on. I am trying to use an If then loop but I am getting the error of "Invalid Qualifier" which I am not understanding because it is valid it's been used throughout the whole script. Any help would be great!
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 receiving the 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