Selecting Multiple Items in Listbox
Hi All,
I have a list box which is populated from an array in the following manner
VB Code:
For lintCtr = 0 To UBound(ClinicArray, 2)
'1 for Clinic name
ClinicList.AddItem ClinicArray(1, lintCtr)
'0 for Clinic id
ClinicList.ItemData(lintCtr) = CInt(ClinicArray(0, lintCtr))
Next
Now what I need to do is when I load my new form that it checks in the database for which clinics someone belongs to and then automatically selects them.
For example one person is connected to 2 clinics, clinicid 2 and clinicid 9
These integers match the integers populated in the ItemData options.
How would I go about using the ClinicList.Selected(???) = TRUE?
I have the following but it fails if the clinicid is greater than 9??
VB Code:
Do While Not RS.EOF
ClinicList.Selected(ClinicList.ItemData(RS("cu_ClinicID"))) = True
RS.MoveNext
Loop
Re: Selecting Multiple Items in Listbox
VB Code:
Do While Not RS.EOF
For intCount = 0 To ClinicList.ListCount - 1
If ClinicList.ItemData(intCount) = RS("cu_ClinicID") then
ClinicList.Selected(intCount) = True
Exit For
End IF
Next
RS.MoveNext
Loop