I have a user form with 3 (single-select) listboxes, which are populated
out of 3 .csv files.
Basically, there is a CLient drop-down list, after you select it
there is a references list (based on client you picked), and there is
the users-assigned list(out of a global user list, does not depend on
client, and is loaded at the userform initialze)
It works fine, except that I would like to pre-select certain values
when I pick the client,
ie I pick client X, then sub-client is populated with X1, X2, X3, users
with U1,U2,U3.
I'd want say, X3 and U15 to be pre-selected when I pick client C12.
I thought of using listbox.listindex, but that only works at the
initialize event, and it doesn't help me here as I want to be able to
change clients without unloading the form.
Private Sub cmbClient_Change()
Dim Wholeline, s, str As String
s = """"
If Trim(cmbClient) <> "" Then
cmbRef.Clear
cmbRef.AddItem "None"
cc = cmbClient
Open references For Input Access Read As #3
While Not EOF(3)
Line Input #3, Wholeline
str = Trim(Replace(Wholeline, s, " "))
If getCname(str) = getCname(cc) Then cmbRef.AddItem
getReference(str)
Wend
Close #3
End If
End Sub