Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form properties & two instances of a form
Message
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00523092
Message ID:
00523705
Views:
8
>On one of my applications I have started to delete all the Public variables that I had declared, and have made them all properties of the form (as everybody recommends).
>
>However when I run two instances of the form, some of these variables that get changed or modified in one form, also get changed in the second form!! Is this correct?
>
>This is the same behavior as the old form I previously had with a bunch of PUBLIC variables declared in the forms load event.
>I thought that by making the variables properties of the form, and because the form was 2-Private data session, that a second instance of the form would be totally independent. Instead all these variables still seem to be public? So what is the advantage? Why not just stick to my old form with it's Public variables?
>
>Do I have to go somewhere to declare each form property Local or Private? If I do, will they also become (annoyingly) invisible to other pages on the page-frame, and to the reports? Where would I declare them?
>
>(I do not necessarily need to run a second instance of the form, but just thought I would try it.)
>
>Regards

I found the problem. One of the code snippets read:

sum qty*price for accno = Myaccno to thisform.myvar1

However I eventually realised that Myaccno was still a public variable, and was also being used by the second instance of the form, to effectively sum the same data (thereby storing the same result to thisform.myvar1 of each form).

Changing it to a property of the form (thisform.myaccno) has made both instances of the form work correctly and independently.

I can now start to see how Public variables can cause so much trouble.

Regards
David Wheeldon
Previous
Reply
Map
View

Click here to load this message in the networking platform