I am trying to call a value from a table that relates to a listbox. What I want to have happen is that when the form opens, the listbox will take the values and highlight the rows in the listbox that relate to the values.
The code below works if there is only one value: For intstatus = 0 To cbo_Status.ListCount - 1
cbo_Status.Selected(Status_Hidden) = True
I am trying to figure out how to accomplish the same task when multiple selections exist and are stored (e.g., "1,2,3").
The problem is I can't pass multiple values at once into the .Selected statement.
I think you must have the intstatus in the selected like this
cbo_Status.Selected(intstatus) = True
The intstatus give the row of the list box
if Status_hiden is the value you want for the row selected, test this solution
cbo_Status.Selected(intstatus) = cbo_Status.Column(Num_of_column Status_hiden,intstatus)
I am having some trouble getting that to work for me (it's probably me though).
Basically, I have a listbox field called cbo_Status. The values for the field are: New,Pending,On Hold, Completed
The field can actually be made up of multiple responses (e.g., It can be both "New" and "On Hold").
When a user selects the values in the listbox, a corresponding numeric value is stored in a table (e.g., If "New" = 1 and "On Hold" =3 then the table value stored would be 1,3).
What I want is that when I re-open the database at a later date, "New" and "On Hold" would be the only two rows highlighted.
The number of possible selections is variable and can be any amount up to the number of possible choices for the listbox. Where I hit the snag is when there is multiple values (such as in the 1,3 example), it fails because I am not certain how to parse this out.
You can try this :
Define your listbox like :
ColumnCount : 2
ColumnWiths: Lenght_fo_state;0 (the second column do not appears)
ListRows : Number of state possible
RowSource : In french "liste de valeurs" , in english ValueList ?
RowSourceType : New;1;Pending;2;On Hold;3; Completed;4
and put this code (I assume the name of the Field is State)
For intstatus = 0 To cbo_Status.ListCount - 1
if instr(1,Table![State],cbo_status.Column(1,intstatus))>0 then
cbo_Status.Selected(ntstatus ) = True
I can't open your base, i'm working with 97
Ouuups I'm sorry i give you a solution with a combo box not a list box. he only dif. is the columncount do not exist on listbox. Otherwise that's good.
I join my test base