问题
All,
I am using Crystal Reports in VS2010. I want to execute a query that lists records as row, and as a sub-query as you like, display a record within something that resembles a Flow Layout (.Net/Java style).
I am executing a stored procedure to get my data in one, for example:
SELECT Table1.Field1 AS Title
Table2.Field1 AS RowRecord1
Table2.Field2 AS RowRecord2
Table3.Field1 AS DataRecord
FROM Table1
JOIN Table2 ON Table1.id = Table2.table1_id
JOIN Table3 ON Table2.id = Table3.table2_id
So Table1 is the top level parent, Table2 is an intermediate, Table3 has my child data that I want to display differently - not in a row.
So dummy data in select will look like:
Title RowRecord1 RowRecord2 DataRecord
My Test Some Row1 Test 1 D1
My Test Some Row1 Test 1 D2
My Test Some Row1 Test 1 D3
My Test Some Row1 Test 1 D4
My Test Some Row1 Test 1 D5
My Test Some Row2 Test 222 D1
My Test Some Row2 Test 222 D2
My Test Some Row2 Test 222 D3
So I want the overall report to look like as follows:
**My Test**
Some Row1 Test 1
D1 D2 D3 D4
D5
Some Row2 Test 222
D1 D2 D3
DataRecord will fill the section up from left to right (single value) - in a Flow Layout.
Ideally I want to know how to do this in Crystal if at all possible. If not I will listen to alternative ideas or solutions. I've tried a few things to no avail and not found anything on line as yet.
Thanks,
Andez
回答1:
I think something like this should work:
First group in Crystal by Title
, RowRecord1
, RowRecord2
Then create three formulas:
In the deepest group header put:
WhilePrintingRecords;
Global numberVar count := 0;
StringVar ConCat:= "";
In detail section:
WhilePrintingRecords;
StringVar ConCat;
Global NumberVar count;
if ((count Mod 4) = 0) then
ConCat:= ConCat & {DBTABLE.DataRecord} & ChrW(13) //adds a line break
else
Concat := Concat & {DBTABLE.DataRecord};
count := count + 1
ConCat
In group footer
WhilePrintingRecords;
StringVar ConCat;
Concat;
来源:https://stackoverflow.com/questions/11960545/crystal-reports-flow-layout-view-of-records