Hi All,
I have two list boxes on a form - I'm currently populating the second list qwhen the first changes. Howewver, that means if you deselect the item from the first listbox it doesn't remove the items from the second; which is the behavour I'm aiming for. My current code looks like this:
What should I be trying to do in order to get it to dynamically know which items should be in the second list box?
Do I need my Trues and Falses in an array or summat? Brain freeze....
Fee
"The cure for anything is salt water – sweat, tears, or the sea." Isak Dinesen
I have two list boxes on a form - I'm currently populating the second list qwhen the first changes. Howewver, that means if you deselect the item from the first listbox it doesn't remove the items from the second; which is the behavour I'm aiming for. My current code looks like this:
Code:
Private Sub lstPCO_Change()
'clear the list of practices we choose
Dim i, a, b As Integer
a = Worksheets("Chosen").Range("B1").Value
Dim strCCG1, strfile, strCon As String
i = Me.lstPCO.ListIndex
strCCG1 = Me.lstPCO.List(i)
If Me.lstPCO.Selected(i) = True Then
'Use SQL to list the practices
OpenDB
strSQL = "Select [gpCode] , [gpName] , [gpPostCode], [gpDispensing] from [Address$] where [ccgName] = '" & strCCG1 & "'"
rs.Open strSQL, cn, adOpenStatic
With Me.lstPractices
Do
.AddItem
.List(a, 0) = rs![gpCode]
.List(a, 1) = rs![gpName]
.List(a, 2) = rs![gpPostCode]
.List(a, 3) = rs![gpDispensing]
a = a + 1
rs.MoveNext
Loop Until rs.EOF
Worksheets("Chosen").Range("B1").Clear
Worksheets("Chosen").Range("B1").Value = a
End With
i = Me.lstPCO.ListIndex
strCCG1 = Me.lstPCO.List(i)
Else
End If
End Sub
Do I need my Trues and Falses in an array or summat? Brain freeze....
Fee
"The cure for anything is salt water – sweat, tears, or the sea." Isak Dinesen