Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting items from lists
Message
From
11/08/2005 10:09:11
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01040178
Message ID:
01040227
Views:
12
>Can anybody tell why when I click my remove button on my form that I get the messagebox stating I havent select anything in the list to delete when I have prior to the item actually being removed succesfully.
>
>
>with thisform.pageframe1.page6.list2
>for ix=1 to .Listcount
> if .Selected[ix]
> 	IF MESSAGEBOX("Are you sure you want to delete this item?",4)=6
> 	 	SELECT cmscomp
> 	 	DELETE
> 	ENDIF
> 	thisform.pageframe1.page6.list2.Requery()
> ELSE
> 	MESSAGEBOX("You have not selected a composition type to remove",0)
> endif
>ENDFOR
>ENDWITH
>
The way you've structured this, you get the message for each unselected record. Try something like this instead:
with thisform.pageframe1.page6.list2
   lAny = .F.
   FOR ix = .ListCount TO 1
     IF .Selected[ix]
       IF MESSAGEBOX("Are you sure you want to delete this item?",4)=6
         DELETE IN cmsComp
         lAny = .T.
       ENDIF
     ENDIF
   ENDFOR

   IF NOT lAny
     MESSAGEBOX("You have not selected a composition type to remove",0)
   ENDIF
ENDWITH
Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform