hello. how to do if when we double click at list view, then the information from list view will be appear at label. many times i tried but always debug (run time error '_2147217904(80040e10) 'no value given for one or more required parameter) .

Private Sub ListView1_DblClick()
strSql = "SELECT * FROM Schedule WHERE ReservationCode=" & ListView1.SelectedItem.Text & ""
rec1.Open strSql, con, adOpenStatic

lblReservationCode.Caption = rec1!ReservationCode
lblDestination.Caption = rec1!Destination
lblDate.Caption = rec1!Date
lblTime.Caption = rec1!Time
End Sub

always use ITEM_CLICK event of the LISTVIEW control to extract information of a specific item from the database.check out the following sample code. it uses an access database and connect through DAO.

before running this code create an access database "resv.mdb" and four fields which are "resv_code","dest","date","time" & also insert some records there.

take one LISTVIEW control & name it as "lvdetails". add four colume headers as "Reservation Code","Destination","Journey Date","Journey Time".
four LABELS and name them "lblresv_code","lbldest","lbldate" and "lbltime" accordingly.

**********IN FORM_LOAD EVENT********
'extracting all records from the database and displaying those in a lv control.

Dim db As Database
Dim rs As Recordset
Dim li As ListItem

Set db = OpenDatabase(App.Path & "\resv.mdb")
Set rs = db.OpenRecordset("details", dbOpenTable)

If rs.RecordCount > 0 Then
While Not rs.EOF()
With lvdetails
Set li = .ListItems.Add(, , rs!resv_code)
li.SubItems(1) = rs!dest
li.SubItems(2) = Format(rs!Date, "MMM-dd-yyyy")
li.SubItems(3) = Format(rs!Time, "hh:mm:ss")
End With
End If
Set rs = Nothing

'clicking an item will extract it's specific information fom the database and display those in the labels.

Private Sub lvdetails_ItemClick(ByVal Item As MSComctlLib.ListItem)
Dim db As Database
Dim rs As Recordset

Set db = OpenDatabase(App.Path & "\resv.mdb")
Set rs = db.OpenRecordset("select * from details where resv_code='" & Item.Text & "'")
If rs.RecordCount > 0 Then
lbldate.Caption = IIf(IsNull(rs!Date), "", rs!Date)
lbldest.Caption = IIf(IsNull(rs!dest), "", rs!dest)
lblresvcode.Caption = IIf(IsNull(rs!resv_code), "", rs!resv_code)
lbltime.Caption = IIf(IsNull(rs!Time), "", rs!Time)
End If
Set rs = Nothing
End Sub

hope you will grab some idea from this sample. if require any more help post it in the same thread.


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