我在2007年有一個名爲:schoolInfo
的表,它有兩個字段(schName and mjrName)
。visual basic 6 access 2007數據庫編程級聯組合框
現在我試圖設計一個組合在Visual Basic 6 (cboMajors)
這是與其他組合(cboSchool)
相關。
事實上,我想要級聯組合框。當我在cboSchool中選擇一個項目時,其他組合應該只代表該學校的相關專業(records with schName=x and mjrName=y)
。
Private Sub Form_Activate()
connection
' the Connection is a code in module contains codes are needed to make the connection between form and the database
fill_schools
fill_majors
End Sub
此外,
Private Sub fill_schools()
With rs
.Open "select DISTINCT schName from tblSchoolsInfo", cn, 2, 3
Do While Not .EOF
cboSchool.AddItem (.Fields(0))
.MoveNext
Loop
End With
rs.Close
End Sub
Private Sub fill_majors()
With rs
.Open "select DISTINCT mjrName from tblSchoolsInfo where schName= '" & Me.cboSchool & " '", cn, 2, 3
Do While Not .EOF
cboMajors.AddItem (.Fields(0))
.MoveNext
Loop
End With
End Sub
現在:第一個組合獲得正確的值,但第二個完全是空的。
不!但我會:) – user2035282