Results 1 to 2 of 2

Thread: Someone help me fix this!!

Threaded View

  1. #1

    Thread Starter
    Fanatic Member hothead's Avatar
    Join Date
    Mar 2002
    Location
    Missouri
    Posts
    692

    Someone help me fix this!!

    Sorry, this is an old post I figured out almost immediately, I tried to edit this before anyone saw it, so disregard the reply I got.

    Here is a sub I wrote for a listview's doubleclick event:

    VB Code:
    1. Private Sub lvwVolumeList_DblClick()
    2.     Dim a As String
    3.     Dim b As Long
    4.     Dim c As String
    5.     Dim lvw As ListView
    6.     Set lvw = lvwFileList
    7.     Set rs = New ADODB.Recordset
    8.     If lvw.ListItems.Count <> 0 Then lvw.ListItems.Clear
    9.     dtaBackups.RecordSource = "SELECT * FROM Files ORDER BY Container_Volume"
    10.     rs.Open dtaBackups.RecordSource, dtaBackups.ConnectionString, adOpenKeyset, adLockOptimistic
    11.     rs.MoveFirst
    12.     Do While Not rs.EOF
    13.         If Not rs!Container_Volume = lvwVolumeList.SelectedItem Then Exit Do
    14.         lvw.ListItems.Add , , rs!FileName
    15.         rs.MoveNext
    16.     Loop
    17.     For i = 1 To lvw.ListItems.Count
    18.         rs.MoveFirst
    19.         rs.Find "Filename = '" & lvw.ListItems(i) & "'", 0, adSearchForward
    20.         If rs.EOF = True Then
    21.             Exit For
    22.         Else
    23.             lvw.ListItems(i).SubItems(1) = rs!Size
    24.             lvw.ListItems(i).SubItems(2) = rs!DateTime
    25.         End If
    26.     Next i
    27.     rs.Close
    28.     Set lvw = Nothing
    29.     Set rs = Nothing
    30. End Sub

    This sub will only work when there's one item in the listview. When there's more than one, it only works for the last item. Why is this?
    Last edited by hothead; Sep 7th, 2003 at 06:54 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width