我有一个名为:schoolInfo
in access 2007 的表,它有两个字段(schName and mjrName)
。
现在我正在尝试在 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
现在:第一个组合得到正确的值,但第二个是完全空的。