Hi!
Let we have a listbox on the form called 'ListBox1'. It contains 2 columns, 1 is item description, another is item id (it could be a single column if ID is an item), second column is hidden.
Scan all items and prepare selections string:
lcSelected=''
for i=1 to thisform.ListBox1.ListCount
if thisform.ListBox1.Selected(i)
lcSelected = lcSelected + allt(upper(thisform.ListBox1.LIST[i,2])) + ','
endif
endfor
Than save the content of the lcSelected variable into the memo field (or character field if you're sure it is not longer than 255 chars).
Than, in refresh of the listbox, you can do following:
&& assume lcSelected is a variable that contains list of ID values of selected items
lcSelected = ','+lcSelected
for i=1 to thisform.ListBox1.ListCount
if ','+allt(upper(thisform.ListBox1.LIST[i,2]))+',' $ lcSelected
thisform.ListBox1.Selected(i) =.T.
endif
endfor
You can, of course, make a separate table which contain ID of selected item in each record (I usually d that way because it is more useful for SELECT queries). In such case instead of collecting values in the string you will add new record in that table for each selected item. Before that, of course, delete records fro previous selection. Whe reading, just scan these records, find appropriate item in list of listbox and mark it as selected.
Hope this helps.
Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs