|
-
Sep 7th, 2003, 06:44 PM
#1
Thread Starter
Fanatic Member
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:
Private Sub lvwVolumeList_DblClick()
Dim a As String
Dim b As Long
Dim c As String
Dim lvw As ListView
Set lvw = lvwFileList
Set rs = New ADODB.Recordset
If lvw.ListItems.Count <> 0 Then lvw.ListItems.Clear
dtaBackups.RecordSource = "SELECT * FROM Files ORDER BY Container_Volume"
rs.Open dtaBackups.RecordSource, dtaBackups.ConnectionString, adOpenKeyset, adLockOptimistic
rs.MoveFirst
Do While Not rs.EOF
If Not rs!Container_Volume = lvwVolumeList.SelectedItem Then Exit Do
lvw.ListItems.Add , , rs!FileName
rs.MoveNext
Loop
For i = 1 To lvw.ListItems.Count
rs.MoveFirst
rs.Find "Filename = '" & lvw.ListItems(i) & "'", 0, adSearchForward
If rs.EOF = True Then
Exit For
Else
lvw.ListItems(i).SubItems(1) = rs!Size
lvw.ListItems(i).SubItems(2) = rs!DateTime
End If
Next i
rs.Close
Set lvw = Nothing
Set rs = Nothing
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.
-
Sep 7th, 2003, 06:50 PM
#2
Addicted Member
Code:
Private Sub cmdCreateNewVolume_Click()
Dim Response As String
Dim bSkip As Boolean
Do Until bSkip = True
If cboMediumType.Text = "" Then Exit Sub
Set rs = New ADODB.Recordset
Response = InputBox("Enter volume name", "New Volume")
SetMediaType
rs.Open dtaBackups.RecordSource, dtaBackups.ConnectionString, adOpenKeyset, adLockOptimistic
rs.Find "Volume_Name = '" & Response & "'", 0, adSearchForward
If rs.EOF = True Then
Set lstItem = lvwVolumeList.ListItems.Add(, , Response)
lstItem.SubItems(1) = lvwFileList.ListItems.Count
rs.AddNew
rs!Volume_Name = lstItem.Text
rs!Number_of_Files = lstItem.SubItems(1)
rs.Update
rs.Close
dtaBackups.RecordSource = "SELECT * FROM Files ORDER BY Filename"
rs.Open dtaBackups.RecordSource, dtaBackups.ConnectionString, adOpenKeyset, adLockOptimistic
For i = 1 To lvwFileList.ListItems.Count
rs.AddNew
rs!Container_Volume = Response
rs!FileName = Replace(lvwFileList.ListItems(i), "'", "", 1, , vbTextCompare)
rs!Size = lvwFileList.ListItems(i).SubItems(1)
rs!DateTime = lvwFileList.ListItems(i).SubItems(2)
rs.Update
Next i
lvwFileList.ListItems.Clear
cmdRenameSelectedVolume.Enabled = True
cmdDeleteSelectedVolume.Enabled = True
cmdRemoveSelected.Enabled = False
cmdRemoveAll.Enabled = False
Set lstItem = Nothing
Set rs = Nothing
'enough?
bSkip = True
Else
MsgBox "A volume with that name already exists. Please enter another name.", vbExclamation, "Name already exists"
'Exit Sub
End If
Loop
End Sub
Special thanks to some wonderful people,
such as Lothar the Great Haensler, Aaron Young,
dr_Michael, Chris Eastwood, TheOnlyOne ClearCode....
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
|