Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

problem using related combo boxes in access 2007 database programming

$
0
0
I have a table named : schoolInfo in access 2007! and it has two fields ( schName and mjrName) Now I'm trying to design a combo in visual basic 6 (cboMajors) which is related to the other combo (cboSchool) as a matter of fact I wanna have to cascading combo boxes! when I choose an Item in cboSchool the other combo should represents just the related majors for that school ( 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


Now: the first combo gets correct values but the second one is completely Empty! could anybody help me please? thanks in advanced

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>