Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Remove items from List Box
Message
From
09/06/2007 17:30:57
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
09/06/2007 16:59:32
Randy Hooper
Ranco Business Software
Tampa, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01231800
Message ID:
01231802
Views:
20
>How can I move item(s) from a list box campare to my table?
>
>this code is in a command button.
>
>
>for i = 1 to thisform.list2.listCount
>   go top
>   locate for alltrim(categoryPick) == alltrim(thisform.list2.list(i))
>   if !found()
>     thisform.list2.removeItem(thisform.list2.listIndex)
>   endif
>endfor
>
This should work, but you need to go backwards, i.e.

for i = thisform.list2.listCount to 1 step -1

because when you remove the nth list element, the list is shorter by one - then the n+1st element is what at the loop start was actually n+2nd. Going backwards gives the effect that anything you've deleted is behind you, you won't step over it again.

The simpler way would be to just base the listbox on a cursor derived from your table (even if just a single-field one), and repopulate the cursor in listbox's .requery(). That way you don't need any loops to match listbox with the table - you pull what you need from the table and tell the listbox to use it.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform