|
-
Sep 9th, 2008, 10:12 PM
#1
Thread Starter
Member
Problem with listviews
I have this sub:
Code:
Private Sub lvwRSPageDemo_DblClick()
Dim dbDatabase As Database
Dim strSQL As String
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM (PROGRAMME LEFT JOIN TCOURSE ON PROGRAMME.Pid = TCOURSE.Pid) LEFT JOIN TRAINER ON TCOURSE.Cid = TRAINER.Cid"
rs.Open strSQL, conn, adOpenStatic, adLockReadOnly
'MsgBox rs.Fields("Tid")
If Len(lvwRSPageDemo.SelectedItem.Text) = 0 Then
Exit Sub
End If
Call rs.MoveFirst
Do Until rs.EOF = True
If lvwRSPageDemo.SelectedItem.Text = rs.Fields("ProgrammeName") Then
MsgBox lvwRSPageDemo.SelectedItem.Text
inputByName = rs.Fields("ProgrammeName")
pid = rs.Fields("PROGRAMME.Pid")
MsgBox rs.Fields("TName")
If (rs.Fields("TCOURSE.Cid") = "") Then
cid = "0"
End If
If (rs.Fields("TCOURSE.Cid") <> "") Then
cid = rs.Fields("TCOURSE.Cid")
End If
If (rs.Fields("Tid") = "") Then
tid = "0"
End If
If (rs.Fields("Tid") <> "") Then
pid = rs.Fields("Tid")
End If
Unload Me
Load frmTDetail
frmTDetail.Show
rs.Close
Exit Sub
End If
Call rs.MoveNext
Loop
'rs.Close
End Sub
And this Image:

If u can see, there are 2 data which is all field are the same but only the name is the different, for the first time, i use the primary key to validate which data i double click with. but the code above will take the first record even if i click the second record, so i bet i want to validate using the trainer name because only name and the primary key is the unique, but then i think again, it is possible if the name might be the 2 person, so it is not unique. So anyone have an idea so that i can validate using the primary key, or the listview will validate the number of rows i click?
Hope to see the reply soon...
thank u very much
 An Ordinary Person With An Extraordinary Determination 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|