Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can i add table in the data environment of report.
Message
From
01/10/2001 12:13:23
 
 
To
01/10/2001 11:13:50
Deepak Chopra
IBM Global Services India Pvt. Ltd.
Pune, India
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00562575
Message ID:
00562614
Views:
20
Most of my reports are based on data in a single table, whose alias is named Rprt. Therefore, I never needed a dataenvironment statment.

I recently found that I needed to have a one-to-many report, so I solved it in the following way. I needed the dataenvironment to be able to refer to 2 files, and relate them.

In the report, I may or may not have a Dataenvironment object (if you look at tmprprt.frx where tmprprt is the name of the report, you may see a record with the following info (no reference to any file names):

Objtype=25

Name=Dataenvironment

Expr=;
Left = 1
Top = 220
Width = 767
Height = 276
Name = "Dataenvironment"

When I know that I will be using the 2nd file, I modify the report as follows:

USE tmprprt.frx
m.PlatForm='WINDOWS'
LOCATE FOR ObjType=25
IF !FOUND() &&since it may not be there
APPEND BLANK
ENDIF
jcChr10=CHR(13)+CHR(10)
m.Name='dataenvironment'
m.ObjType=25
m.Expr='Left = 1'+jcChr10+'Top = 220'+jcChr10+;
'Width = 520'+jcChr10+'Height = 200'+jcChr10+;
'InitialSelectedAlias = "Rprt"'+jcCHR10+;
'Name = "Dataenvironment"'+jcChr10
GATHER MEMVAR FIELDS Platform,ObjType,Name,Expr MEMO
m.Name='cursor'
m.Expr='Alias = "Rprt"'+jcChr10+;
'CursorSource = DBF("RPRT")'+jcChr10+;
'Name = "cursor1"'+jcChr10
INSERT INTO TmpRprt (Platform ,ObjType,Name,Expr) ;
VALUES (m.Platform,26 ,m.Name,m.Expr)
m.Expr='Alias = "SecondFile"'+jcChr10+;
'Order = "Filename"'+jcChr10+;
'CursorSource = FULLPATH("SecondFile")'+jcChr10+;
'Name = "cursor2"'+jcChr10
INSERT INTO TmpRprt (Platform ,ObjType,Name,Expr) ;
VALUES (m.Platform,26 ,m.Name,m.Expr)
m.Name='relation'
m.Expr='ParentAlias = "Rprt"'+jcChr10+'RelationalExpr = "cLookUpVal"'+jcChr10+;
'ChildAlias = "SecondFile"'+jcChr10+'ChildOrder = "FileName"'+jcChr10+;
'OneToMany = .T.'+jcChr10+'Name = "relation1"'+jcChr10
INSERT INTO TmpRprt (Platform ,ObjType,Name,Expr) ;
VALUES (m.Platform,26 ,m.Name,m.Expr)

I then create the file called RPRT (which contains the the data that will printed), and right before I'm ready to print,

USE Tmprpt.frx
jcLookFor='DBF("RPRT")'
LOCATE FOR Objtype=26 AND 'CURSOR1'$UPPER(Expr) AND jcLookFor$UPPER(Expr)
IF FOUND()
m.Expr=STUFF(EXPR,AT(jcLookFor,UPPER(EXPR)),LEN(jcLookFor),&jcLookFor)
REPL Expr WITH m.Expr
ENDIF
jcLookFor='FULLPATH("SecondFile.DBF")'
LOCATE FOR Objtype=26 AND 'CURSOR2'$UPPER(Expr) AND jcLookFor$UPPER(Expr)
IF FOUND()
m.Expr=STUFF(EXPR,AT(jcLookFor,UPPER(EXPR)),LEN(jcLookFor),&jcLookFor)
REPL Expr WITH m.Expr
ENDIF
USE IN TmpRprt
SELECT Rprt
REPORT FORM TmpRprt PREVIEW

Hope this was helpful. I dynamically modify the reports, since if I'm not printing a specific field, I don't want a blank space to appear.

That's for a different time.

Pessy
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform