Creating a Custom Report with Columns Summary: This technote explains how to create a custom report with columns using a single database. Creating columns requires placing field variables in the Report Designer to represent the columns and then assigning values to the variables in the report program. This technote explains how to setup the report and then modify the report code. Create a report in the Report Designer. Place variables in the report body to represent each column of the report. In this example, the report has 4 columns and prints 4 fields from each record. You may also define a GROUP is desired. Anymore than 1 group is note available. a$ b$ c$ d$ a1$ b1$ c1$ d1$ a2$ b2$ c2$ d2$ a3$ b3$ c3$ c4$ Place 1 field from the database on the report to link the report to the database. If you do not want this field to display, select its properties and turn pen and paper off. Modify the AFTER SELECT section of the report .SBP file as follows. (Tip: When you save a report, it creates 2 files, an .SBP and .SBV. After modifying the code in the .SBP file, if you go back into the Report Designer and save new changes, it overwrites your code (after warning you). To avoid this, work with 2 copies of your report. Copy1.SBV and Copy1.SBP are used to modify the .SBP file. Copy2.SBV and Copy2.SBP are used to modify the .SBV file. When editing in the Program Editor, work with Copy1.SBP. When working in the Report Designer, work with Copy2.SBV. Modify the REPORT USING "COPY1" to REPORT USING "COPY2" in Copy1.SBP. Use in Program Editor COPY1.SBV COPY1.SBP REPORT USING "COPY2" Use in Report Designer COPY2.SBV COPY2.SBV SUB main() REM Even though the report code opens the file I found that indicating the index field prior to running REM the report made things run cleaner. OPEN FILE "customer" INDEX "state" CALL RCUSTMR() END SUB SUB RCUSTMR() REPORT USING "RCUSTMR2" FOOTING 1 SET REPORT PAGE "F_PAGE" OUTPUT REPORT PAGE END FOOTING GROUP State.CUSTOMER BEFORE GROUP State.CUSTOMER REM Store the current GROUP name in a variable to compare later. REM GROUP is a system variable that returns the current group. gr$ = GROUP SET REPORT PAGE "H_State.CUST002" OUTPUT REPORT PAGE END GROUP AFTER SELECT REM Assign first record to variables in column 1. a$ = name :a1$ = address:a2$ = city + ", " + state + " " + zipcode :a3$ = telephone REM Check if end of file or change of group then select the next record IF NOT EOF ("") AND state = gr$ THEN SELECT NEXT REM Keep checking and reassigning variables for each column REM Assign variables in column 2. (The next 2 lines of code should be typed as 1) IF NOT EOF ("") AND state = gr$ THEN b$ = name :b1$ = address :b2$ = city + ", " + state + " " + zipcode :b3$ = telephone SELECT NEXT REM Assign variables in column 3. (The next 2 lines of code should be typed as 1) IF NOT EOF ("") AND state = gr$ THEN c$ = name :c1$ = address :c2$ = city + ", " + state + " " + zipcode :c3$ = telephone SELECT NEXT REM Assign variables in column 4. REM SELECT NEXT is not needed here since the report automatically selects the next record. IF NOT EOF ("") AND state = gr$ THEN d$ = name :d1$ = address :d2$ = city + ", " + state + " " + zipcode :d3$ = telephone SET REPORT PAGE "F_SELECT" OUTPUT REPORT PAGE REM Clear all column variables. CLEAR GLOBAL END SELECT REM Turn the query optimizer on for speed enhancements. By default this is off. REM Apply a filter and order if desired. SET QUERY ON SET QUERY LOCK OFF SELECT ; WHERE state.customer <> "" ORDER REPORT State.CUSTOMER TO WINDOW END SUB See also The following technotes offer more in-depth information regarding Custom Reports. 1. 4040 Debugging Custom Reports: Discusses the differences of Save and Save As program. 2. 4044 Suppressing Blank Lines in Reports: May be useful if you have an Address1 and Addresss2 field that does not always contain data. 3. 4054 Creating Summary Reports: Explains in more detail the functions of the different report bands. Program: Superbase Versions: 2.0 Date: November 30, 1993 D Date: