>>>>
>>>>Actually, I tried it with DOEVENTS and it works for me, i.e. I can click 'Cancel' button and kill the loop by resetting in Click event some form property evaluated for EXIT within the loop.
>>>
>>>This is exactly what I was trying to do but I could not get the Click event fire. Maybe there is another property that I have to look into. I will keep trying a couple of more approached suggested in the thread.
>>
>>No, I tried brand new form, no special properties were involved. I just noticed that adding RELEASE THISFORM in Click does not work, i.e. form still wants to finish looping before closing; but if I put Thisform.Loopexit=.T. and 'loopexit' property is evaluated in the loop to EXIT then it works..
>
>Where did you put your loop code? Maybe I should have said it in the initial message. But long loop code is in the Activate method of the form. That is, as soon as the form shows, the loop code starts. The form also has a button where in the Click() method I put code THISFORM.lCancel = .T. But my loop that has DO WHILE NOT THISFORM.lCancel never stops.
>
>How is my case different from what you were doing?
I put it in Form.Activate now (it was in different place) and it still works Ok. Maybe, your loop code is something specific. Try it with 'empty' loop, just DOEVENTS.
Edward Pikman
Independent Consultant