Check if list item should be selected

svjensen

Registered User.
Local time
Today, 08:22
Joined
May 6, 2010
Messages
37
I have a variable (string) in which I store the users selection from a listbox on a form. The user is allowed to make multiple selections, so the content of the variable could look like '1' (only one selection) or '1,3' (more selections.

On an other form I which to have a listbox with the same values, and as a default the same items should be selected as was the case on the other form.
My idea is to loop through the items in the list (see below) and chech if they are part of the variable. But the last bit is causing me some trouble.

Code:
For i = 0 to Me.lstStatus.ListCount - 1
    'If list item is part of variable
        Me.lstStatus.Selected(i)
    End if
Next i

How could/should my if sentence look? Do I need to split the variable and loop through those values as well?
 
I think you misunderstood me.
I am not storing multiple data in a single field, but I use a variable to pass data from one form to another. The variable contains the ids of the selected items in a listbox and is used to define WHERE clauses.

Anyways, your link helped me to find a solution, so thanks :)

/Soren
 
Glad it helped you.
 

Users who are viewing this thread

Back
Top Bottom