Hello again, I thought I'd strike again while the iron is hot!!
Ok, I have 2 events (addfaultcause and deletefaultcause) - on_click
I want to be able to multiselect the items in my listbox (lstfaultcause) and be able to delete the items from both the list box and my SQL table. At present I can delete only one selection at a time, but I'd like to be able to select multiple entries and delete them all at once.
Can someone help? I need to be able to keep the index (shown in code below). I'm using RDO to connect
---Code Begins---
I guess that I'd have to change the deletefaultcause_click event with need code to allow Multiselect in the list box.Code:Private sub addfaultcause_click() Dim infault As String infault = InputBox("Please enter the Fault Cause? ", "Enter Fault Cause", "") If infault = "" Then Exit Sub ans = MsgBox("Are you Sure? ", vbQuestion + vbYesNo, "Question") If ans = 6 Then cnCon.Connect = "uid=sa;pwd=;server=" & txtsvr & ";driver={SQL Server};database=" & txtdb & ";" cnCon.CursorDriver = rdUseOdbc cnCon.EstablishConnection 'rdDriverNoPrompt cnCon.AddCause infault cnCon.Close lstfaultcause.AddItem (infault) End Sub Private Sub deletefaultcause_click() Dim DelSet As rdoResultset cnCon.Connect = "uid=sa;pwd=;server=" & txtsvr & ";driver={SQL Server};database=" & txtdb & ";" cnCon.CursorDriver = rdUseOdbc cnCon.EstablishConnection 'rdDriverNoPrompt cnCon.DelCause lstfaultcause.ItemData(lstfaultcause.ListIndex) 'Delcause is SQL-Defined code Set DelSet = cnCon.LastQueryResults lstfaultcause.RemoveItem (lstfaultcause.ListIndex) cnCon.Close end sub
Thanks
Craig.




