Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to run a form saved as a class
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00400258
Message ID:
00400907
Vues:
27
>Ed,
>I have tried the following:
>loForm=Createobject('frmReport')
>loForm.Show
>Read Events
>
>This has resulted in the frmReport just being displayed very quickly and it then immediately disappears. I call this from a commandbutton on another screen, I dont know if this makes a difference. Also, on the calling screen I already have a 'Read Events' active so am wondering what is the need for another 'Read Events' . Anyway, the same result with or without the read events.
>
>Regards,
>Gerard

Gerard,

You cannot have more than one read events in effect. Any others are ignored after the first one.

Your problem is the scoping of the variable holding the form reference. loForm is being created as a private variable and goes out of scope as soon as the method ends. To get the scoping right you need to ask the question of how long is this new form supposed to hang around. One approach might be to create a form property named oReportForm, then use this code in the button's click;
WITH Thisform
   .oReportForm = CreateObject("frmReport")
   .oReportForm.Show()
ENDWITH
Be sure to put this code in the destroy of the calling form;
Thisform.oReportForm = NULL
This will put the form object reference into a form property and it will not go out of scope when your button code ends.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform