Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to access one form's controls from another
Message
From
06/11/2000 21:01:57
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00438353
Message ID:
00438647
Views:
9
Hi Gerard,
I would advocate passing an object that supplies the information needed to run the report. For example:
DEFINE CLASS ReportInfo AS Custom
   FRXName = ''
   IsPortrait = .T.  && to help size the preview window.
   IsLegal    = .F.  && same reason.
   OrderBy    = 1    && to aid in Print When's
   Property1  = ' '
   ManyMoreProps  
ENDDEFINE

In your Print() you can populate the properties, 
or better still, create the object in the specific 
form's Load() and bind the properties to the 
appropriate controls using the ControlSource.

LOCAL oReportInfo
* Create the object and populate the properties.
oReportInfo = NEWOBJECT('ReportInfo', 'SomeClassLib.VCX')
WITH oReportInfo 
   FRXName = 'ReportA.FRX'
   OrderBy = 2  && Order by Name, not Number.
   etc.
ENDWITH
DO ReportForm WITH m.oReportInfo

In the ReportForm you can use the properties by creating a custom property.
PROCEDURE Init (ReportInfo)
This.ReportInfo = m.ReportInfo
ENDPROC
* When you are ready to print do this.
LOCAL ThisReport 
ThisReport = This.ReportInfo
* You may use ThisReport.OrderBy or ThisReport.Property1 
* in your report, it's in scope even though you might think it isn't.
REPORT FORM ThisReport.FRXName TO PRINTER &MoreStuff.
>I have a generic Form which I call to do all my reports. I would norammly call this from the application forms e.g.
>
>In MyAppForma Do form ReportForm with 'Reporta'
>In MyAppFormb Do form ReportForm with 'Reportb' etc.
>
>Then, ReportForm allows selection of Screen/printer/File etc.
>
>Quite often , I will need to access properties of the first calling form (.i.e MyAppForma, MyAppFormb etc) within the report irself.
>
>I could maybe pass these as parameters, but the paramters going into ReportForm will be dependant on the calling screen, and will change each time.
>
>Is there any way to pass the whole form as an 'Object' into ReportForm so that i could say somthing like:
>
>laVar1= ReportForm.oCallingForm.Property1
>lavar2= ReportForm.oCallingForm.Property2 etc.
>
>and then have these available to print on the report.
>
>Thanks for your help
>
>Gerard
Q
Charlie
Previous
Reply
Map
View

Click here to load this message in the networking platform