KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Creating a Quick Report in list mode programmatically
PRODUCT: 4D | VERSION: 2004.1 | PLATFORM: Mac & Win
Published On: July 1, 2005

Below is a sample code that shows how to create a quick report in list mode programmatically. A quick report offscreen area is first created. Then, a current table is set for it. Next, columns are inserted and the sort order set. After setting the destination, the QR is executed and the offscreen area is deleted. The sample below creates a last name and first name column from the Employee table and the records are sorted based on their last name.

`Method: QRListSample

C_LONGINT(myQR)

myQR:=QR New offscreen area ` Create a QR offscreen area

QR SET REPORT TABLE(myQR;Table(->[Employee])) `Set Employee table as the current table for QR area

QR INSERT COLUMN(myQR;1;->[Employee]LName) `Insert LName field as 1st column

QR INSERT COLUMN(myQR;2;->[Employee]FName) `Insert Fname as 2nd column

ARRAY REAL($aColumns;1)

$aColumns{1}:=1 `Array for column to order.

ARRAY REAL($aOrder;1)

$aOrder{1}:=-1 ` Array for sort order. Negative 1 for descending and positive 1 for ascending.

QR SET SORTS(myQR;$aColumns;$aOrder) ` Set the sort order based on column. Sort LName in descending order.

QR SET DESTINATION(myQR;qr printer ) ` Set destination to printer

ALL RECORDS([Employee])

QR RUN(myQR) `Executes Quick Report.

QR DELETE OFFSCREEN AREA(myQR) ` Delete QR offscreen area