hi all:'(
i am a newbie want to know how to get values from two tables in database. I have three tables one is the student information and the other table is the subject and grades .Both tables have id number which may join them together But what i need to do is, i have a listview that i named lvMasterlist which displays the list of the students names and lvGrades which display the subject and the grades of the student from first grading till fourth grading and what i want is that everytime i click one of names in lvmasterlist it will display the data in the lvGrades. Is it possible. i have tried some codes below which it did'nt output the one i desired:

can anyone help me with this problem...anyway Im using navicat mySql as a database...

Private Sub lvMasterList_click()
lblName = lvMasterList.SelectedItem
LoadSubjects
LoadGrades
LoadLevel
LoadGender
LoadSection
End Sub

Sub LoadSubjects()
'-----------------------------------------------------------------------------------------------------
lvGrades.ListItems.Clear
connect
rs.Open "tblSubject ", con, 3, 3
Do Until rs.EOF
Set listitem1 = lvGrades.ListItems.Add()
listitem1.Text = rs("SubjTitle")
rs.MoveNext
Loop
rs.Close: Set rs = Nothing
con.Close: Set con = Nothing

End Sub

Sub LoadGrades()
'-----------------------------------------------------------------------------------------------------
lvGrades.ListItems.Clear
connect
rs.Open "tblsubject join tblenroll ", con, 3, 3
Do Until rs.EOF
Set listitem1 = lvGrades.ListItems.Add()
listitem1.Text = rs("SubjTitle")
With lvGrades.ListItems.Add(, , rs("FirstGrading"))
.SubItems(1) = (rs("SecondGrading"))
.SubItems(2) = (rs("ThirdGrading"))
.SubItems(3) = (rs("FourthGrading"))
End With
rs.MoveNext
Loop
rs.Close: Set rs = Nothing
con.Close: Set con = Nothing
End Sub
Sub LoadLevel()
'-----------------------------------------------------------------------------------------------------
connect
rs.Open "tbllevel ", con, 3, 3
Do Until rs.EOF
Set listitem1 = lvGrades.ListItems.Add()
lblLevel2 = rs("LevelName")
rs.MoveNext
Loop
rs.Close: Set rs = Nothing
End Sub
Sub LoadGender()
'-----------------------------------------------------------------------------------------------------

connect
rs.Open "tblstudent ", con, 3, 3
Do Until rs.EOF
'Set listitem1 = lvGr.ListItems.Add()

lblGender = rs("StudGender")
rs.MoveNext
Loop
rs.Close: Set rs = Nothing
con.Close: Set con = Nothing
End Sub
Sub LoadSection()
'-----------------------------------------------------------------------------------------------------
connect
rs.Open "tblsection ", con, 3, 3
Do Until rs.EOF
'Set listitem1 = lvGr.ListItems.Add()
lblName = lvMasterList.SelectedItem
lblSection = rs("SectionName")
rs.MoveNext
Loop
rs.Close: Set rs = Nothing
con.Close: Set con = Nothing
End Sub


:(

This is a traditional homework assignment huh?
I will not give you the answer but the hints to solve the problem

option one...
run one query on table 1, load data
run same query on table two altered, load data
(this is not the answer the teacher wants)

do a search for JOIN query in a) the help files b) on the web
there are three million samples for it available and a few very good ones out there.

This article has been dead for over six months. Start a new discussion instead.