General information
Category:
Forms & Form designer
>>>The reason for this problem as you can not remove an object from collection using FOR EACH loop. This problem was discussed here before and I admit I made the same mistake myself (and may be twice even). You need to loop using counter and from the last record to the first.
>>>
>>>Check How can I release all open forms FAQ #7975 It shows the main principle, you need to adapt that code for your case.
>>
>>Not sure how the above would be a problem here. Since the intention is only to remove one form then screwing up the further 'FOR EACH' processing shouldn't matter - especially if the FOR EACH loop was exited from within the IF..ENDIF ?
>>
>>>And also, as Boris said, you probably need to check name of the form, not caption.
>
>Well, even if this may not apply for this particular case (if you exit the loop immediatelly after release()) it is still good practice to avoid the mistake. Since you can not remove members from collection while looping through collection using FOR EACH loop, it's better to learn this once and don't use potentially unsafe code.
So. if you want to rule out the use of FOR EACH how should the required form be selected ?
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only