RSCR
RSCR
RSCR
Creating Reports explains how to create reports with ReportSmith. It familiarizes you
with basic tasks such as creating a basic report, and advanced topics such as working
with macros.
Introduction
formatting characters, using the Style Extractor and report styles, aligning items, and
displaying graphics filenames as pictures.
Chapter 6, Graphs describes how to convert a report to a graph.
Chapter 7, Crosstabs shows you types of crosstabs you can create, describes three
methods for creating a crosstab, and shows you how to modify and format a crosstab.
Chapter 8, Macros introduces you to macros and ReportBasic, shows you how to
create and use a simple macro, and gives examples of sample macros.
Chapter 9, Printing a report shows you how to print a report.
Chapter 10, Customizing ReportSmith shows you how to customize ReportSmiths
options, its menu and toolbar, and how to run a ReportSmith report from an icon.
Chapter 11, Runtime Viewer shows you how to install and run this feature.
Chapter 12, Creating and using a data dictionary shows you how to create a view,
assign aliases, and use the ReportSmith data dictionary.
Appendix A, Using ReportSmith with other applications discusses how to embed
an OLE 2.0 object into a report, how to call ReportSmith from another application, and
how to call an application from ReportSmith.
Appendix B, Macro reference provides a command reference for ReportSmiths
macro facility.
Creating Reports
Because ReportSmith uses a visual layout approach, you can specify data you want and
use live data as you edit and format reports. You decide how you want data to appear,
using drag and drop techniques to place data, graphics, OLE objects, charts, and text.
ReportSmith saves the layout and uses it each time you run your report.
You can add finishing touches to your report such as fonts, number formats, and
borders with Windows-standard features: icons, a toolbar, a formatting ribbon, snap-to
grids, adjustable rulers, zoom, and alignment capabilities.
The keyboard
Letters like Esc designate key names on your keyboard. Here, Esc represents the
Escape key. Keys on your keyboard may not be labeled exactly as shown in this
manual, so check your computer manual if they differ.
Arrow keys refer to the Up Arrow (), Down Arrow (), Left Arrow (), and Right Arrow ()
keys.
Combination keys appear with a plus sign (+). For example, Alt+F1 means you should
hold down the Alt key while pressing the F1 key.
Text
The text you type appears in monospace font. Type in the text exactly as it appears,
including uppercase and lowercase letters and spaces between words, letters, and
symbols.
Filenames and database table names appear in UPPERCASE.
New terms and emphasized items appear in italics.
A light bulb in the margin indicates a useful tip or shortcut.
Procedures
In many of ReportSmiths dialog boxes, you can use three methods to place an item
from a list box into another list box. You can:
Drag and drop it into the list box using the mouse
Double-click on an item to place it in a list box
Select an item and press the appropriate button in the dialog box
Installed files
The Delphi installation automatically installs some ReportSmith drivers and files for
you. To view a list of these files, open the FILELIST.DOC installed with ReportSmith.
Introduction
Creating Reports
Chapter
Chapter 1
This chapter identifies the database types you can use with ReportSmith and shows you
how to connect to your database tables. It also shows you how to save connections to
frequently used tables.
Informix
InterBase
ORACLE
Paradox
Raima
AS/400
SQL Server
SQLBase
Sybase
Teradata
Text Files
Unify
Watcom SQL
Databases accessed through generic ODBC drivers
Connecting to tables
To connect to a database:
1 Choose File|New, or press the New Report button on the toolbar. ReportSmith
displays the Create A New Report dialog box.
2 Press the report button that corresponds to the report type you want to create and
press OK, or double-click the report button that corresponds to the report type you
want to create. ReportSmith displays the Tables dialog box.
3 Choose Add Table. ReportSmith displays the Select Table To Be Added dialog box.
4 In the Type box, choose a database type. In the example above, weve chosen
dBASE(ODBC). Specify the location of the database in the Drives and Directories list
boxes, or if youve defined a connection, select it from the Connections list box.
A list of available tables appears in the Files box.
5 Select a table and press OK, or choose Server Connect to make a server-based
connection.
Creating Reports
The Get Connection Data dialog box appears with the connection type displayed at
the top. In the example below, the connection type is SQL Server.
6 Enter the information for the type of connection you want to make. In the example
above, ReportSmith prompts you to enter the name of the server, the user ID, and
password. (For specific information youll need for each database type, see
ReportSmiths on-line Help.) Press OK.
When you save a new report, ReportSmith saves all the connection information
except the password. The next time you create a new report, ReportSmith displays
the connection information from the last data source you connected to. You can
cancel it if you intend to use a different data source.
to re-enter the server name, user name, and directory path. Instead, you can select a
user-defined connection and ReportSmith will login to that database directly.
If required, ReportSmith prompts you to enter your password and connects you to the
database. Once you create a connection and save it, the next time you access the
database you created for that connection, you simply select the name you assigned to
the connection and ReportSmith makes the connection.
Note
See your system administrator for server IDs and help in setting up connections you
plan to use frequently.
To set up and save a connection:
4 In the Name box enter a name for the connection. For example, you may have a
database that holds employee sales records that you want to name Sales.
5 Enter the information for your connection type. ReportSmith needs the data path or
server information for your system.
6 Choose Save. ReportSmith saves the connection and places it in the Connections box.
To delete a connection, select it in the Connections box and choose Delete.
ReportSmith removes the connection.
7 Press OK. Now you can select this connection in the Connections box in the Select
Table To Be Added dialog box the next time you create a report.
Creating Reports
SQL
databases
PC
databases
Thirdparty
drivers
NATIVE
Borland
SQL
Links
ODBC
IDAPI
ReportSmith
Connection types
ReportSmith provides three types of connections to enable you to connect to data
sources: IDAPI, ODBC, and native connections. You may use one or more of these
connections, depending on the data sources you are working with.
Through IDAPI
Integrated Database Application Programming Interface (IDAPI) enables you to
connect to IDAPI-enabled Borland desktop products such as Paradox and dBASE, or
SQL data sources supported by the Borland SQL Links, such as InterBase (for a
complete list of supported IDAPI data sources, see Supported data sources on
page 10).
Note
For more information about IDAPI connectivity to SQL databases, double-click on the
IDAPI Configuration icon in the ReportSmith program group and choose Help in the
IDAPI Configuration Utility after you install the product.
Through ODBC
Open Database Connectivity (ODBC) drivers enable you to connect to PC and SQL
ODBC data sources. You can install your own or use those drivers installed by
ReportSmith. If you have installed your own ODBC drivers, ReportSmith overwrites
existing drivers if they are older versions than those shipped with ReportSmith (for a
complete list of supported ODBC data sources see Supported data sources on
page 10).
Note
Version
Access
All versions 1.0 through 2.x. ReportSmith does not supply the ODBC driver for
Access 2.0; its included when you install Access 2.0.
BTRIEVE.EXE versions 5.x and earlier. Connectivity to Btrieve 6 is available
through the ODBC driver from Q+E.
Btrieve
10
Creating Reports
Connection
type
ODBC
ODBC
Connection
type
Database
Version
DB2
dBASE
Excel
FoxPro
Informix
Ingres
InterBase
ORACLE
Paradox
SQL Server
SQLBase
Sybase
Teradata
Text files
Unify
Note
Native
IDAPI, ODBC
ODBC
ODBC
IDAPI
Native
IDAPI
Native
IDAPI, ODBC
Native
Native
Native
Native
ODBC
Native
For information about installing a specific data source, see Connecting to data sources
on page 9.
dBASE
ReportSmith provides an IDAPI connection to dBASE versions 5.0 and earlier and
dBASE V for DOS. For dBASE for Windows 5.0, IDAPI provides the only connection.
Note
For detailed information about dBASE IDAPI connections, double-click on the Release
Notes icon in the ReportSmith program group.
11
Paradox
ReportSmith provides an IDAPI connection to Paradox versions 5.0 and earlier. For
instructions on how to configure a Paradox connection, see your IDAPI documentation.
Access
ReportSmith provides an ODBC connection to Access version 1.x. The driver for Access
2.x is included with Microsoft Access. The ODBC Access Setup window that appears
when you choose to add the Access driver in the ODBC setup program is shown here:
12
Creating Reports
You must edit the default data source installed by ReportSmith to specify the path to
your Access database.
Make the following changes to your CONFIG.SYS and AUTOEXEC.BAT files:
Add this line to your CONFIG.SYS file: FILES= 50
Add this line to your AUTOEXEC.BAT: C:\DOS\SHARE.EXE /L:200. For large databases,
add this line to your AUTOEXEC.BAT: C:\DOS\SHARE.EXE /L:500
Note
For more information about Access databases, refer to the Access documentation.
To configure an Access ODBC data source:
Refer to the following table and enter the required fields in the ODBC Access Setup
dialog box. When youre done, press OK to create the ODBC configuration.
Setup field
Value
System Database
Page Timeout
Exclusive
Buffer Size
Solution
Btrieve
ReportSmith provides an ODBC connection to Btrieve versions 5.x and below. Before
ReportSmith can use Btrieve files, you must first incorporate them into XQL databases.
Incorporating Btrieve files into XQL doesnt change the files. You may still access
Btrieve files with Btrieve applications. It creates data dictionary information contained
in three files: FILE.DDF, FIELD.DDF, and INDEX.DDF. These files must be in the same
directory as your Btrieve files. Several vendors provide utilities to generate Btrieve data
definition files, for example, Xtrieve (by Novell), and Data Junction (by Tool and
13
Techniques Inc.). If you have Btrieve data from another application, that vendor may
have already provided it in XQL database format.
The ODBC Btrieve Setup dialog box that appears when you choose the Btrieve driver is
shown below:
14
For more information about Btrieve files, refer to your Btrieve documentation.
Creating Reports
To configure a Btrieve ODBC data source, refer to the following table and enter the
values in the required fields into the ODBC Btrieve Setup dialog box. When youre
done, press OK to create the ODBC configuration.
Setup field
Value
Collating Sequence
Page Timeout
Exclusive
All Btrieve files must be in the same directory as these generated data definition files.
Solution
dBASE/xBASE
ReportSmith provides an ODBC connection to dBASE/xBASE that supports dBASE II,
III, and IV file formats. ReportSmith supports xBASE formats that are compatible with
dBASE versions II, III, or IV. ODBC does not support dBASE for Windows version 5.0 or
dBASE V for DOS. These are supported by IDAPI.
15
The ODBC dBASE Setup dialog box that appears when you select the dBASE driver is
shown below:
For more information about dBASE databases, refer to your dBASE documentation.
To configure a dBASE ODBC data source:
Refer to the following table and enter the values shown in the required fields in the
ODBC dBASE Setup dialog box. When youre done, press OK to create the ODBC
configuration.
Setup field
Value
Collating Sequence
Page Timeout
16
Creating Reports
Setup field
Value
Exclusive
Check if you want to open dBASE files in exclusive mode. Exclusive mode
prevents concurrent access of files and enhances performance.
Check if you want rows marked as deleted to display (optional).
Uncheck if you do not want the table size statistic approximated. We
recommend that you do not check this option (optional).
Answer
Excel
ReportSmith provides an ODBC connection to Excel versions 4.x and below.
ReportSmith accesses only the information in the database portion of an Excel
spreadsheet. The ODBC Excel Setup dialog box that appears when you select the Excel
driver is shown below:
17
Value
Rows to Scan
Note
For more information about Excel databases, refer to your Excel documentation.
18
Symptom
Solution
Creating Reports
FoxPro
ReportSmith provides an ODBC connection to FoxPro versions 2.0 and 2.5. The ODBC
FoxPro Setup dialog box that appears when you select the FoxPro driver is shown
below:
Value
19
Setup field
Value
Collating Sequence
Page Timeout
Exclusive
Solution
Paradox
ReportSmith provides an ODBC connection to Paradox versions 3.x and 4.x. The ODBC
Paradox Setup dialog box that appears when you select the Paradox driver is shown
below:
Enter the values shown in the table below in the required fields and press OK to create
the ODBC configuration.
20
Creating Reports
Value
A short name for your data source. This name also becomes the
name of the profile that is created for you.
(Optional.) A description of the data source.
The name of the data source directory.
(Optional.) The maximum number of unused file opens to cache.
The table version you are using in your Paradox database.
The sort order: ASCII or International. The default is ASCII.
(Optional.) Check if you want the table to be write-locked to
ensure that all records can be re-read.
Description
Database Directory
FileOpenCache
Table Version
Sort Order
Read Consistency Isolation Level
Solution
21
Symptom
Solution
Text
ReportSmith provides an ODBC connection to Text files. The ODBC Text Setup dialog
box appears when you select the Text file driver.
Value
Extensions List
22
Creating Reports
Setup field
Value
Extension
Default (*.*)
Define Format
Press the Define Format button to view the Define Text Format dialog box:
Options within the Define Text Format dialog box are described in the following table.
Setup field
Value
Tables
This list box contains the names of tables defined in the directory. If a schema
entry exists for the highlighted table, the Columns side of the window contains
information about each column in the table.
Check this box if the first row in the table contains column name names instead
of data.
Choose one of the following text file formats:
Comma-Separated Values (CSV): Columns are separated by commas.
Tab-Separated Values: Columns are separated by tabs.
Custom Delimited: Columns are separated by the delimiter character
specified.
Fixed Length: Columns are not separated; rather, each column is a fixed
length.
The character that acts as the column separators (custom delimited files only).
The number of rows you want the driver to scan to determine the data type of
each column in the table (custom delimited files only).
Delimiter
Rows to Scan
23
Setup field
Value
If a schema entry exists for the highlighted table, the Columns list box contains
the names of each column in the table. If a schema entry does not exist, click the
Guess button to automatically generate the column data type, name, and width
values for the columns in the selected table by scanning the tables contents
according to the Format list box selection. Any previously defined columns in
the Columns list are cleared and replaced with new entries. Guess is available
only for CSV Delimited, Custom Delimited, and Tab-Separated Value formats.
These fields let you specify the schema for each data source. This information is
written to a SCHEMA.INI file in the data source directory. There is a separate
SCHEMA.INI for each text data source directory.
If the table format is fixed-length, Width is valid for all data types. If the table is
any other format, Width is valid only for Char or LongChar data types.
The character that acts as a separator in dates (custom delimited files only).
Date Separator
Refer to your SQL Links documentation for instructions on installing and configuring
SQL Links.
InterBase
ReportSmith provides an IDAPI driver that connects to InterBase versions 3.3 and 4.0
through SQL Links and version 4.0 through Client/Server Express.
Note
Informix
ReportSmith provides an IDAPI driver that connects to Informix version 4.1.0 through
SQL Links.
Note
24
Weve filled dialog boxes with valid parameters to illustrate examples; yours may differ.
Creating Reports
DB2
ReportSmith provides connections to DB2 via the MicroDecisionware Database (MDI)
Gateway and the Gupta DB2 Gateway. Before you can connect to DB2, the gateway
must be installed and working.
The Get Connection dialog box that appears when you select a DB2 Gupta ODBC
connection is shown here.
The Get Connection dialog box that appears when you select a DB2 MDI ODBC
connection is shown here.
Ingres
ReportSmith provides a native API connection to Ingres Networking for Windows.
25
When you choose an Ingres connection, the Get Connection dialog box appears,
prompting you for the following values:
ORACLE
ReportSmith provides a native API connection to SQL*Net for DOS. It also provides
Windows access to remote and ORACLE databases versions 6.0 , 7.0, and 7.1. If you
have an ORACLE ODBC driver, you can use it. However, this is the connection type we
recommend.
26
Creating Reports
When you choose an ORACLE connection, the Get Connection dialog box appears
with the following options:
Solution
27
Symptom
Solution
SQL Server/Sybase
ReportSmith provides a native API connection to SQL Server/Sybase. (For versions, see
the README.TXT.) This is the connection type we recommend.
28
Creating Reports
Solution
SQLBase
ReportSmith provides a native API connection to SQLBase version 4.0 or Quest 1.0 to
access SQLBase databases.
The Get Connection Data dialog box that appears when you select a SQLBase
connection is shown here.
Teradata
ReportSmith provides a connection to Teradata version 2.0 running Teradata
DBC/1012 version 4.1.1 or greater via the Micro Decisionware Inc. (MDI) Gateway.
29
The Connection dialog box that appears when you select a Teradata connection is
shown here.
Unify
ReportSmith provides a connection to Unify 2000. To connect to Unify please contact
Borlands Customer Service department to receive the Unify driver.
30
Creating Reports
Chapter
Chapter 2
ReportSmith lets you create system or custom report types and styles. Each time you
create a new report, choose a default report type: columnar, crosstab, form, or label.
You can create many custom report types, such as a master/detail report. This chapter
shows you default report types and explains the uses for each. It also shows you two
custom columnar report types: summary-only and master/detail.
31
Crosstab
A crosstab report displays data in a summary or spreadsheet format.
Form
A form report displays data in free-form across the report page. Each record always
starts on a new page, so there is just one record per page. If the record data is large, a
single record can span multiple pages.
Labels
A label report displays data in label format. ReportSmith can automatically generate all
types of Avery label styles for you.
32
Creating Reports
Master/detail
You can create a report using more than one query, called a master/detail report.
Generally, the master report contains one record per key value, while the detail report
contains many records per key value.
33
Summary-only
A summary-only report presents only summarized values, omitting the details used to
arrive at those values. For example, in a report summarizing the number of videos sold
by each video store, the total amount of sales for each video store appears, but not the
individual orders comprising the total.
Press a report type button to create a columnar, crosstab, form, or label report.
The default formatting style assigned to the report type you select appears in the dialog
box beside Style.
To choose a report type:
1 Choose File|New or press the New Report button on the toolbar. The Create A New
Report dialog box appears.
34
Creating Reports
2 Choose the report type youd like to createcolumnar, crosstab, form or label.
The default style attached to the report type appears beside Style in the dialog box. If
desired, choose Style to select a different style and press OK.
35
36
Creating Reports
Chapter
Chapter 3
ReportSmith provides Report Query dialog boxes which you can use to add tables and
build the report query. A report query is a request for specific data from your tables. It is
a question you ask about the data, such as Which employees sold above their quota
this month? ReportSmith uses the criteria to select just the records you specify, using
current data from the tables where the data is stored.
To bring data into a report, you can use either these dialog boxes, or if youre familiar
with Structured Query Language (SQL), you can use direct SQL entry. This chapter
describes both methods. After reading it, youll know how to
Use the Report Query dialog boxes to
Add tables
Link tables
Choose columns
Assign column aliases
Specify selection criteria
Group data
Use Direct SQL Entry
37
There are seven Report Query dialog boxes. Press a button at the top of the dialog boxes
that corresponds to the action you want to perform: Tables, Selections, Sorting, Derived
Fields, Database Grouping, Report Variables, or SQL.
Choose a button to display its corresponding dialog box. Buttons are described in the
following table. You can navigate between dialog boxes to change your report query in
any order; ReportSmith automatically updates it for you.
Button
Function
Function
38
Button
Creating Reports
Adding tables
After youve chosen a report type, add one or more tables to your report.
To add tables:
4 To add tables, choose Add Table and repeat the above steps. Do this for each table
you want to add.
When youve chosen the tables for your report, you can link them.
Joining tables
If you have more than table in your report, you need to link them using related fields.
The two fields must contain matching data in related records. Often, common fields
share the same name.
In the example below, the CUSTOMER and EMPLOYEE tables share the EMP_ID field
in common.
CUSTOMER TABLE
CUST_ID
EMP_ID
F_NAME
L_NAME
PHONE
EMPLOYEE TABLE
FNAME
LNAME
EMP_ID
Visual joins
Use this method to link two tables by tiling two reports, clicking on the common
column, and pressing the Merge button.
39
1 Add tables to your report using the Tables dialog box. In the dialog box, choose Add
New Link.
2 In the Create New Table Link dialog box, choose the tables and their common field.
In the example below, the common field for the CUSTOMER and DETAIL tables is
CSTMR_ID.
3 Choose OK.
Each table in your report must be included in at least one join. A good rule of thumb is
to make sure the number of links you have equals at least the number or tables in your
report, minus one.
To modify an existing link:
1 Use the Edit Table Link dialog box: in the Tables dialog box, select the link you want
to modify and choose Edit Link. The Edit Links dialog box appears.
40
Creating Reports
If you try to create a report with more than one table without linking tables,
ReportSmith alerts you with the following warning:
If you see this message, you have not created valid links between tables. If you press No,
ReportSmith creates a Cartesian product of the tables, matching each record in the first
table to each record in the second table. This results in a very large set of records.
You may not want to specify a table link if you are creating a more complicated join
between tables in the selection criteria. If so, use the Report Query dialog boxes to create
the table link in the selection before loading data into the report.
If you do not have system resources to generate such a large table, press the Yes button
and create a valid link between tables in your report.
Choosing columns
You can define specific columns from tables youve chosen to appear in your report.
ReportSmith offers you two ways to choose columns. You can
Use the Table Columns dialog box to exclude columns before loading them into your
report.
41
Select them visually and delete them from the report surface.
Choose the method that best suits your needs.
Note
1 In the Tables dialog box, select a table and press the Table Columns button. The Table
Columns dialog box appears listing columns in the selected table.
42
Creating Reports
Function
Include in report
You can change column selection at any time by opening the Table Columns dialog
box and choosing columns to include or exclude from your report once again.
ReportSmith re-loads data with the columns you specify, updating your report.
Double-click on a column to scroll through the value options at the bottom of the
dialog box.
4 Press OK. ReportSmith loads the specified columns into your report.
Visually
1 On your report, choose a column and press Delete.
2 To delete more than one column, use the following methods:
Ctrl+click one or more columns to select columns that are not contiguous and press
Delete.
Shift+click to select a block of columns and press Delete.
Note
Using this method only removes the columns from displaying on the report. The
columns you delete still exist in the report definition and can be replaced in the report
at any time.
43
descriptive name to the data. In a dialog box, youll see the alias name, rather than the
original name as it appears in the database.
Column headings use the original field name from the table by default. If youve
assigned an alias to a column name, it appears instead. To change the column heading
single-click the label, then single-click within the selected heading to use the text cursor
to edit its name. Save your changes and ReportSmith displays the field label as entered
each time you run the report.
To assign a column alias:
1 In the Tables dialog box, select the table that holds the field you want to assign an
alias.
2 Press the Table Columns button.
3 In the Table Columns dialog box, select a column from the Column list.
4 Enter the new name for the column in the text box and choose Assign New Alias.
ReportSmith places the alias in the Column Alias list box.
5 Choose a value option at the bottom of the dialog box for each column. Press
Advanced to view the Include column value only and Include only for use in query
options. (See page 43 for a description of these options.)
44
The SQL text box is recommended for people with comprehensive knowledge of SQL. If
you are unfamiliar with SQL, use the Report Query dialog boxes and let ReportSmith
build the SQL statement behind the scenes for you.
Creating Reports
What is SQL?
SQL is a language used by ReportSmith to communicate with your databases to retrieve
data. Usually, ReportSmith builds SQL statements behind the scenes for you based on
selections youve made in dialog boxes. In general, you arent required to possess an
extensive knowledge about SQL to use ReportSmith. In some situations, ReportSmith
does allow you to enter portions of the SQL text. For example, when you use one of two
methods to create selection formulas (Selections command) and when you create SQLdefined derived fields (Derived Fields command). ReportSmith combines the formulas
you entered with the remainder of the SQL statement that it generates for you.
After you create your own SQL statement or modify an SQL statement, you must
continue to change the query using the SQL method. The Tables, Sorting and Selections
portions of the Report Query dialog box are no longer available to you for this report.
However, you can still use all formatting and macro dialog boxes.
There may be situations where you want to enter your own SQL statement for a report.
If you are familiar with SQL you might want to enter the statement yourself for the
following reasons:
You want to use a feature of the SQL language particular to your database that
ReportSmith does not provide through its interface.
You are a SQL expert and want to quickly enter SQL statements without utilizing the
ReportSmith interface.
You want to paste SQL text from another source, such as another program.
45
The SQL dialog box appears displaying the SQL text for the report:
Here, you can examine the SQL text for clarification, documentation, or debugging
purposes. You can copy this SQL text to the Windows Clipboard for use by another
Windows program using commands on the Edit menu.
1 After creating a report using the ReportSmith dialog boxes, do one of the following:
Press the SQL button on the toolbar
Press the SQL button in a Report Query dialog box
Select Tools|SQL Text
The SQL dialog box appears.
2 Press the Edit SQL button. A warning message alerts you that after you change the
report to SQL Entry mode, you cannot return to regular mode. Press Yes to continue.
The SQL dialog box appears.
The SQL dialog box is similar to the SQL Selections Criteria and Derived Fields
dialog boxes. You can choose elements from the fields, operators, and functions list
boxes and insert them into the text box. Alternatively, you can type the text directly
into the text box.
46
Creating Reports
The order in which you select from these list boxes depends on what you are trying to
achieve. You do not have to choose a field, then an operator, then a function. Choose
them in any order you need to build the text you want to use for the report.
3 Press the Test button to test your statement. If you enter your formula incorrectly,
ReportSmith informs you of the error and directs you to it. If you entered your
formula correctly, ReportSmith informs you of the total number of records and
displays a success message.
4 Press OK to remove the message.
5 After editing the SQL text, do one of the following:
Press Done to save your changes. ReportSmith uses your text as the reports SQL.
The SQL dialog box appears from this point forward when you click the SQL icon
or select the SQL Text command on the Tools menu.
Press the Cancel button to cancel your changes.
The list boxes at the top assist you in adding fields, report variables, SQL operators and
keywords, and SQL functions to your SQL text.
The Data Fields list box contains a list of the fields retrieved from the database. When
you convert a report to SQL text entry, this list wont be known until the SQL statement
47
is executed. For a report already in SQL text entry mode, the list shows the fields
selected the last time the SQL statement executed.
To create a report using direct SQL entry:
5 Press Yes in response to the warning message. ReportSmith displays the SQL dialog
box.
Youll use this dialog box to write your own SQL statement instead of stepping
through the Report Query dialog boxes while ReportSmith builds it for you. There
are two ways to enter the SQL statement:
Type the statement directly into the SQL text box.
Place items from the list boxes into the text area box.
6 Press the Connection button and choose a data source in the Get Connection dialog
box. Press OK.
7 To enter your formula, do one of the following:
Place the cursor in the SQL text area box and type it directly into the SQL text box.
Use the Table and Column Browser to view fields in one or more tables. Place
fields, comparison operators, and functions into the SQL text area by dragging and
dropping them or by double-clicking on them.
To clear your formula, press the Clear button. When you press it, ReportSmith
displays:
Erase the current SQL text?
1 In the SQL dialog box, press the down arrow in the left-most list box and click to
select Table and Column Browser. A list of options appears.
48
Creating Reports
2 Double-click Add Table to List. The Select Table To Add To Browser dialog box
appears.
3 Select a table to place in the Browser and press OK. Do this for each table you want to
view. Use the Type, Drives and Directories list boxes to navigate to the location of a
table or press the Server Connect button to connect to the appropriate data source.
4 Press OK. ReportSmith displays corresponding fields under each table you select.
5 Place fields from the Browser into the SQL text area.
Press the Zoom button to enlarge your view of the SQL text area.
6 Sometimes you have too many tables in the Browser. To clear the list, choose the
Clear List option in the Browser list box and double-click on it.
7 You may need to press the Connection button to tell ReportSmith which table you are
looking at here, if you havent already. Use the Test button to test your formula.
You can write an SQL statement without using the Browser, then press the
Connection button. Alternatively, you can connect to a table in the Browser before
writing an SQL statement.
The first list box displays ReportSmith report objects and tables and columns you
have selected.
The second list box displays arithmetic functions and operators and other statements
to assist in building your query.
The third list box displays all SQL functions specific to your data source. Depending
on the database to which you are connected, ReportSmith forms this list for you. It
contains valid functions for that data source type.
For example, if you are connected to ORACLE, ReportSmith places all valid
ORACLE SQL functions here. You dont have to remember any SQL functions.
49
may be manipulating the database in ways that the ReportSmith interface doesnt
recognize.
Note
50
You can still use ReportSmith formatting, presentation and macro features even if you
use SQL text entry to retrieve the data from the database.
Creating Reports
Chapter
Manipulating data
Chapter 4
This chapter describes how to manipulate data in reports with sorting, grouping,
creating summary fields, derived fields, report variables, and master/detail reports.
Parts of a report
Page or
Report Header
Group Header
Field Labels
Fields
Columns
Group Footer
Page or
Report Footer
The action you perform on one selected item applies to all items in that category. If you
select a group footer and add a border, borders appear in all instances of that group
footer.
Note
For an illustration that identifies crosstab parts, see Parts of a crosstab on page 132.
51
The toolbar
ReportSmiths toolbar puts frequently used actions at your fingertips with easy-to-use
buttons. To see a description of a button, drag the mouse over it and look in the status
bar. The toolbar is located at the top of the ReportSmith screen.
To display or hide the toolbar choose View|Toolbar.
Zoom
New report
Save
Open
Header/Footer
Column/Form
mode
Summary functions
Best Fit
SQL
Merge reports
Sort
The ribbon
Use the ribbon to quickly apply formatting. For example, you can use it to change the
font style and size, to insert number formats, text or graphics, or to insert a graph.
To display or hide the ribbon choose View|Ribbon.
Font
Alignment
Bold Underline
Format
numbers
Crosstab
Report styles
Picture
Text mode
Style extractor
Graph
Sorting
You can sort data in a report in ascending or descending order with the Sort buttons on
the toolbar. You can also designate sort order with Tools|Sorting. In some cases,
ReportSmith sorts data for you, such as when you press a Header or Footer button.
To sort data with the toolbar:
1 Select Tools|Sorting to see the Sorting dialog box. Or, choose Sorting from a Report
Query dialog box.
52
Creating Reports
2 Place one or more fields from the Report Fields list box into the Sort list. The selected
field appears in the Sort List box. An asterisk appears beside sorted fields.
3 Choose Ascending or Descending. Add an additional report field to the Sort list by
selecting it in the Report Fields list and pressing the Insert Into Sort List button.
4 Choose Done. ReportSmith sorts fields in the order in which they are placed on the
sort list.
Grouping
You can break data into groups based on fields you select. ReportSmith lets you group
data after you load it into your report using Report Grouping; or, on the server, before
loading it into your report with Database Grouping.
You can use both types of grouping in one report.
Report grouping
Use the Report Grouping command to group data after it has been loaded into your
report. There are two ways to do this:
Using the Header or Footer buttons
Using the Tools|Report Grouping command
This section describes both methods.
To group data with the toolbar:
53
2 Press the Header or Footer button to sort the data based on the selected field and to
insert a header or footer in each group.
To place fields into the header or footer, see Placing items into a header or footer on
page 107.
To group data with Tools|Report Grouping:
4 Choose Group Properties to see the Group Properties dialog box. Here, youll define
how you want to group the selected fieldif you want ReportSmith to group all like
values together, choose Same Value. ReportSmith compares each field with the one
preceding it, and if the value is the same, groups the values together. If the values
differ, ReportSmith creates a new group. In the example below, we grouped fields by
each unique CONTACT_LN.
54
Creating Reports
To group by a specific number of records, choose Every and select a number from the
spin box that appears. In the example below we grouped by every 5 records in the
CONTACT_LN group.
5 You can print each value in a group just once instead of displaying it repeatedly. To
do this, select a field you want to suppress and choose Suppress. Do this for each field
you want to suppress.
ReportSmith places an asterisk beside suppressed fields. They appear just once per
group.
6 Press OK after youve set the properties for the defined group and choose Done.
Database grouping
For grouping to occur on the server before loading it into your report, use the Database
Grouping feature. For example, suppose you have a database containing information
about 10,000 employees from ten departments and you want a report displaying a sum
of salaries in each department. To increase performance, you would use Database
Grouping to have ReportSmith consolidate the data on the server and then download
just the ten records you requested.
If you are going to perform any database grouping, then it is a restriction of SQL that all
fields which provide a unique value per row must be grouped, while those that do not
should not be grouped.
For example, regular data fields musts always be grouped, since there is always a
potentially unique value for each record. Derived fields should not be grouped if they
are computing an aggregate (summary) value. A derived field of SUM(SALARY)
should not be grouped, because it generates a summary value for the entire group
which does not change for each record in the group. However, a derived field of
SALARY * .25 must be grouped, because it computes a unique value for each record.
55
Choose Group Data Before Loading Into Report. A list of fields from your report
appears in the Database Grouping Order window, and options in the dialog box
become enabled.
The upper portion of the dialog box defines what fields you want to group by. If you
are familiar with SQL, this part of the dialog generates a Group By clause. The lower
portion of the dialog box lets you select which groups to include in your report and
selection criteria. In SQL, it generates a Having clause.
2 Select a field you want to group by and use the ordering buttons to position it in the
list. The order in which you place fields in the list is hierarchical, moving from
highest to lowest grouping order.
3 You can choose to include or exclude a field from grouping with the Include Field
From Grouping and Exclude Field From Grouping options.
The Exclude Field option is disabled for tables that contain a unique value. This
means you must group by every field that contains a unique value per record.
Conversely, you can exclude fields that do not contain a unique value per row, such
as calculated fields.
4 To select groups to include in your report, insert a sentence into the selection criteria
in the lower portion of the dialog box and choose an operator (All, Any or None) to
apply to the statement.
Note
56
Press Test before loading data into your report. You can find and eliminate any errors in
your query before ReportSmith executes the underlying SQL.
Creating Reports
1 Select the column in your report by whose data you want to group. In the following
example, we selected the ACCT_NBR column.
2 Choose the Header or Footer button on the toolbar. ReportSmith sorts and groups the
data, and inserts a header or footer. In the example below, we inserted a header.
Headers
57
ReportSmith sorts and groups your data based on the field you selected. Additionally, it
labels the header. In the above example, the header is called Group Header
ACCT_NBR group.
To group data using Insert|Headers/Footers:
Use this method to insert a header or footer into your report without performing
sorting.
3 Choose a Group Name and check a Group Type option. Do this for each group
you want to create. In the example above, we chose to insert a page header. Press
OK to exit the dialog box and see the results of grouping on your report.
58
Creating Reports
The selection criteria limits the data set to display specific records, reducing the size of
data and making it more specific. To get the data we want, we created the following
selection criteria in the Selections dialog box:
After we apply the new selection criteria to our data, ReportSmith displays just the data
we specified on our report:
ReportSmith offers you two ways to specify selection criteria for your reports:
The Selections dialog box
The Field Selection Criteria dialog box
This section explains both methods.
Choosing records
You can use ReportSmiths Selections dialog box to specify which records you want to
display on your report. ReportSmith lets you use English sentences (as opposed to SQL)
to construct the selection criteria, building a basic outline which you can modify. You
can also use SQL to create your selection criteria.
The Selections dialog box where youll build a selection construct is shown below.
Click on highlighted or
underlined items to see contextsensitive lists
59
To add selection criteria, click on the number where you want to place a new sentence.
(In the dialog box above, youd click on 1.) ReportSmith displays a list of choices for
adding or deleting items:
Select this option
To...
Click on the Exclude Duplicate Rows option to avoid including any rows that contain
the same data as another row.
You can identify items which display drop-down liststhey are underlined or
highlighted. In the example above, since a basic construct exists, if you click on the 1.
again youll see a context-sensitive list:
As you choose items, ReportSmith alters the outline of the sentence dynamically to
ensure that it makes sense. There are numerous combinations of items which can be
created to form a sentence. You can specify any number of criteria in any combination,
simple or complex, to your report selections.
Here, well modify the Include statement at the top of the dialog box, Include records
in the report where all of the following apply: Click on all to display a list of criteria.
You can choose to include ALL, ANY, NONE or NOT ALL of the criteria you list below
it in the dialog box.
Select this option To...
ANY
ALL
60
Creating Reports
Include a record in your report if it meets ANY of the criteria beneath this list.
This places an implicit OR between each sentence.
Include a record in your report only if it meets ALL of the criteria beneath this
list. This places an implicit AND between each sentence.
NOT ALL
Include a record in your report if it meets NONE of the criteria beneath this
list. This places a NOT before each sentence and an AND between each
sentence.
Include a record if it does not meet every criteria listed below this list. It can
meet ANY portion of the list criteria, but NOT ALL of them.
Well select all to include a record only if it meets all of the criteria were about to
specify.
Next, click on data field in the basic sentence to see a list of field types to choose from:
If you choose data field and click on the next item in the sentence,
DETAIL.INVOICE_ID, ReportSmith displays a list of data fields. The data field you
select is the field against which youll compare your rows:
Click is equal to to choose a comparison operator. The comparison operator is the verb
of the sentence:
In our example, we chose is greater than because we want to display all sales in which
we sold more than a certain amount of items.
Click on the next item in the list to choose to what you are comparing your data field:
61
In our example, we selected text. ReportSmith displays a text entry box in the sentence
which you can fill with one or more values:
Enter a value. In our example, we entered CA and pressed the Enter key to place it into
the sentence.
Weve completed our first sentence. To enter another sentence to this list, click on 1. to
display the drop-down list and select a function.
This table describes the options in this drop-down list:
Select this option
To...
You can add numerous lists and sentences to create your selection criteria. Just follow
the steps above to add, remove and modify additional lists and sentences.
After youve created your selection criteria, press the Test Selections button to see the
number of records that it retrieves.
To delete an item or a list:
2 Press the Delete key, or select Delete This Item from the drop-down list.
If you selected a list, ReportSmith removes the list and its subcriteria from the
construct. If you selected an item, ReportSmith removes that item.
62
Creating Reports
You can use some key combinations while in the Selections dialog box to perform
certain functions. The following table describes them.
Key
Function
Arrow keys
Use the up, down, left and right arrow keys to navigate within your SELECT
statement.
Press the Enter key to insert a criteria or to make a choice in a drop-down list.
Press this key combination to display a drop-down list.
Press the Escape key to close a drop-down list without making a choice.
Enter key
Alt+
Esc
Choosing fields
The Field Selection Criteria dialog box lets you choose fields for your selection
statement. To open the dialog box, select a column, right-click the mouse and choose
Selection Criteria from the pop-up menu. Alternatively you can choose Tools|Field
Selection Criteria.
Go up one level
Check your selection
Create a selection criteria
Use the dialog box to create a basic selection criteria for a report from the report surface
(instead of navigating through the Report Query dialog boxes). For example, to select
only customers with the last name of Yates, select the CONTACT_LN column, rightclick the mouse, choose Selection Criteria and place the selection criteria into the dialog
box.
You can drag and drop fields from your report into the selection criteria. To do this,
select a field on your report and drag it into the dialog box. ReportSmith creates the
selection criteria for you.
63
In this example, well drag Yates from the CONTACT_LN column and place it into
the dialog box:
ReportSmith places the field into the dialog box and modifies the selection criteria.
Youll see the grab cursor when you drag and drop items from your report and place
them into the dialog box. Depending on the selection criteria you create, youll see one
of the following drop cursors:
If you drop the field in the current area,
youll add selection criteria.
If you drop the field in the current area,
youll insert the text field you grabbed into the current area.
1 Open a report and select a column youd like to modify. As an example, well select
the TOTAL column.
2 Right-click and choose Selection Criteria from the pop-up menu. The Field Selection
Criteria dialog box appears displaying a default construct, may be any value.
64
Creating Reports
Lets modify the selection construct. As an example well modify it to display all
transactions greater than or equal to $100 for certain cities.
3 Click on may be any value to see a list of options and select must be greater than or
equal to to place it in the construct.
4 ReportSmith has added number 0 to the construct so you can specify a value. Click
on 0 and enter 100 into the value entry box. Choose Apply to execute the selection
in your report.
Next well specify the cities we want to display on our report.
5 At the top of the dialog box, click on the drop-down list displaying TOTAL and select
CITY from the list. ReportSmith displays may be any value in the construct.
6 Click on may be any value and select must be in list from the drop-down list.
ReportSmith inserts the default for the in-list statement, of values.
7 Click on <values> to open the List Editor dialog box:
8 Enter a city into the text entry box and choose Add to place it in the list. Do this for
each value you want to add. After youve added the values, press Test to see how
many records match the value currently selected in the List box.
65
Note
9 Press OK and press Done to exit. ReportSmith applies the modified selection criteria
to your report and regenerates it for you with the specified values.
The changes you make in the Field Selection Criteria dialog box appear in the Selection
dialog box. You can modify your construct there also. As an example, lets take a look at
the selection criteria we just created in the Selections dialog box.
To view your selection construct in the Selections dialog box:
1 Open a report you modified using the Field Selection Criteria dialog box.
2 Choose Tools|Selections. The Selections dialog box appears with your modified
construct displayed.
To see the list of values associated with this construct, click on <values>.
ReportSmith displays the List Editor dialog box with the values you specified.
66
Creating Reports
A typical use of a derived field is to combine two text fields into one field. You might
have one field containing employee first names and another containing last names. You
can create a derived field that trims unnecessary space around the field name,
combining the fields.
Another way to use a derived field is to extract the number of a month from a field that
holds dates. The formula for this appears as MONTH(invoices.DATE).
Note
This is database-specific; not all databases have this function. Its format or name might
differ.
In this section, youll learn how to create derived fields that
SQL-derived fields
To create a SQL-derived field:
In this example, well show you how to create a derived field which calculates a 10%
sales commission.
Typically, ReportSmith uses SQL code to get the results of the derived field. This
means your database calculates the derived data.
4 Choose Add.
67
ReportSmith displays the Edit Derived Field dialog box where you define the derived
field formula.
Choose elements from the field, operator, and function list boxes and place them in
the Derived Field Formula window.
The order in which you select from these list boxes depends on what youre trying to
achieve; you dont have to choose a field, then an operator, then a function. Use them
in any order necessary to build the formula you want to apply to the data.
Note
Functions and operators appearing in the list boxes differ depending on the server
and database you use. Refer to your server or database documentation for
explanations of available functions and operators.
5 Press the down arrow beside the field, operator, or function box.
A list appears displaying available types of fields, operators, or functions. For
example, if you want to create a derived field based on report fields, select Data
Fields from the fields drop-down list. ReportSmith displays fields from the table in
your report.
6 Select the type of field, function, or operator and place it into your formula.
7 Test your formula using the Test button until you receive a success message. Choose
OK.
8 Use the Insert|Field command to place the derived field in your report.
Macro-derived fields
Typically, ReportSmith uses SQL code to obtain the results of a derived field formula.
This means your database calculates the derived data. However, there may be
information you need to show in a field which cannot be created by your database. For
example, to derive a percent of a total, you need to select the Defined by a ReportBasic
68
Creating Reports
Macro option to create the derived field locally. This is because SQL code cant access
summary fields, which are calculated locally.
You can create a derived field that calculates a percent of a total. For example, in our
Sales By Employee report, we want to determine what percent of William Blakes sales
can be attributed to each of his clients.
1 Open a report for which you want to calculate the percent of total.
2 Choose Tools|Derived Fields, enter a name and select the Defined by a ReportBasic
Macro option. Choose Add to see the Choose a Macro dialog box.
3 The Report Macros option is enabled. (Derived fields must be based on report
macros.) Enter an optional description for the macro function into the Description
text box.
69
ReportSmith has placed the first and last lines of your formula into the formula
window. You do not need to re-enter them.
5 Enter the macro code into the Macro formula text box:
Sub PerOfTot()
' Calculate the percentage of the total quantity of this employee's sales that the
' current record's quantity of sales represents.
' The Field$ function gets the QUANTITY record as a string.
' The Val() function converts it to a number which is stored in the variable "Quantity."
Quantity = Val(SumField$("SUBTOTAL", 'c:\rptsmith\samples\invoices.dbf",2,"Sum"))
' The Next line gets the total quantity for the current customer group
' and assigns it to a variable.
TotalQuantity = Val(SumField$('SUBTOTAL","c:\rptsmith\sampless\invoices.dbf",1, "Sum"))
' A divide by zero error will halt macro execution.
if TotalQUantity > 0 then
PercentOfTotal = Quantity/TotalQuantity
' The Derived Field statement reports the derived field value and is only
' valid in macros used to define derived fields.
' It takes a string value, so the Str$ Function is used to convert Number to a string.
DerivedField Str$(PercentOfTotal)
Else
' If TotalQuantity was zero there was an error.
DerivedField "Error"
End If
End Sub
6 Press Test to test your formula. If ReportSmith finds errors, correct them and press
the Test button until you receive a success message. Choose OK, then choose OK
again to exit the dialog box.
7 Choose Done to exit the Derived Fields dialog box. ReportSmith executes the Percent
of Total macro and inserts the results as the Percent of Total column.
70
Creating Reports
To show a percent of total sales for William Blake for each of his customers, we
would show that percentage in the customer group footer next to the sum of sales for
each customer.
8 Press the Form Mode button. Select the Percent of Total heading, then Ctrl+click to
select the Percent of Total fields. Drag and drop the selected items into the customer
group footer.
9 Choose the Percent button on the ribbon to format the derived field.
Note
1 Select the column to which you want to apply the summary operation.
2 Click the operation you want to perform on the column. You can choose the Sum,
Average, Minimum, Maximum or Count button. ReportSmith inserts the summary
field into each footer you have created in your report.
If you have not defined footers in your report, ReportSmith displays a message
informing you to insert footers so that you can see the summary fields.
To create a summary field using Tools|Summary Fields:
Function
Average
Count
First
Last
Maximum
Minimum
Std Deviation
Sum
71
Operation
Function
Variance
Calculates the variance from the mean in a report of data. It is the square of the
standard deviation. It is the measure of the amount by which all values in a group
vary from the average value in the group.
Summary fields placed into page headers and footers show summaries of the data
on each page.
Cumulative Sum
See Summary fields on page 105 for how to insert a page summary field.
4 Select the column you want to apply the summary field operation and place it into
the Summary Fields window.
5 Choose OK to exit the dialog box.
6 Insert headers or footers into the report, if you havent already done so, with Insert|
Headers/Footers. Use the Field command on the Insert menu to drop a summary
field into a header or footer.
In our sample report for Video West, we applied the sum operation to the
SUBTOTAL field for the customer name group. We then used the Field command on
the Insert menu to drop the summary field into the customer group footer.
Once placed, the total sales for each customer in our sample report appears in each
customer group footer:
72
Creating Reports
dialog boxes illustrated below is a report variable which obtains specific information
from the user to create a report:
The above example shows just three of the report variables you can create. ReportSmith
applies the users value to the report.
String
Number
Date
Time
Date and Time
There are also four entry types to choose from. Any entry type can be used with any of
the data types listed above:
Type-in
Choose from a list
Choose from a table
Choose between two values
73
The following table summarizes entry type options when paired with each data type:
Data type
Entry Options
String
Type-in
Requires users to type a response to the report variable. When you select this option, you can designate
the maximum characters users can enter in the Maximize Size option. The default number is 2000.
Choose from a list
Requires users to select a response to the report variable from a list box. When you select this option,
you must also enter the allowed values in the Allowed Values list box. Use this list box to specify a list
of values for the user to choose from. Type a value into the text box and press Add to place it into the
list. Do this for each value you want to add. Use the Delete and Replace buttons to remove or replace
values from your list.
Choose from a table
Requires users to choose values from tables and fields youve selected. Choose Select Table to place a
table into the report variable. Choose Select Field(s) to specify fields that the user can choose. Here, you
can choose a field to display from the Display value from field list and a field to use from the Use
Value from field list. (For example, you might want to use the CUST_ID field but display the
CUST_NAME on the report.)
Choose between two values
Requires users to choose a Yes or No value from a Message box or to choose from one of two values in a
Dialog box. Enter prompts into the prompt boxes.
Type-in
Requires users to type the number response to the report variable. When you select this option, you
must also select from the following check boxes: Signed determines whether users can type a + or
sign. If you leave this empty, ReportSmith uses a positive number and users cant type a + or .
Maximum determines the largest number users can type. Click this check box and enter the maximum
number youll allow users to enter. Minimum determines the lowest number users can enter. Click this
check box and enter the minimum number youll allow users to enter. Decimal determines the number
of decimal places users can enter. Click this check box and enter the number of decimal places.
ReportSmith uses the standard dollars and cents format. Spin indicates that a spin button (an up and
down arrow) appears beside the response area to allow users to use the mouse to change the entered
value. Available check boxes for this option are the same as for the Type-in option described above.
For Choose from a list, Choose from a table and Choose between two values, see entry options under
String, above. Options are the same.
Type-in
Requires users to enter the date response to the report variable. When you select this option you must
enter the date format you want to appear by entering it in the text box or choosing it from the dropdown list.
Choose from a list
Requires users to select a response to the report variable from a list box. When you select this option,
you must also enter the allowed values in the Allowed Values list box. Use this list box to specify a list of
values for the user to choose from. Use the spin box or calendar button to select a date or range of dates
and press Add to place it into the list. Do this for each value you want to add.
Choose from a table (see entry options under String, above).
Choose between two values requires users to choose a Yes or No value from a Message box and then
enter the date value using the spin and calendar buttons, or to choose from one of two values in a Dialog
box.
Type-in
Creates a variable that requires users to enter a time for a report. After creating the variable, select or
enter in the Format box the time format youll let users enter.
Number
Date
Time
74
Creating Reports
Data type
Entry Options
For Choose from a list, Choose from a table and Choose between two values see entry options under
Date, above.
For Type-in, Choose from a list, Choose from a table and Choose between two values, see entry
options under Date and Time, above.
Date/Time
1 In the Report Variables dialog box, select the report variable you want to modify
from the Report Variables list. The settings for the selected report variable appear in
the options.
2 Modify the appropriate settings in the dialog box and press Done.
To change the value of a report variable:
1 Select Tools|Report Variables, or, press the Report Variables button in a Report
Query dialog box. The Report Variables dialog box appears.
75
Youll use the Report Variables dialog box to create report variables by entering
information into each of the text entry boxes and by choosing options. Type a name
for your report variable into the Name box. The name appears in the Report
Variables list for your use. Names must begin with a letter and contain only letters,
numbers, and underscores.
Startdate is the name of our first report variable.
If you use a report variable in selection or derived field formulas, you must type the
report variable name exactly as it was entered when created, distinguishing between
uppercase and lowercase letters.
2 Press the down arrow in the Type list box and choose the data (or the type of
response) for your report variable.
The Startdate report variable uses Date as the type of response.
3 Enter the title you want to appear in the dialog box for the report variable.
Start Date is the title for the example report variable.
4 In the Prompt box, type the exact wording you want to appear in the user prompt.
We entered the following:
Please enter the start date for this report:
5 Press the down arrow under Format to see a drop-down list of date formats.
6 Choose a format. For our example well choose Default, which uses the format
mm/dd/yy.
7 Press the down arrow under Entry to choose how youd like the user to specify
values. For our example, well choose Type-In.
8 Choose Add to add the report variable you defined to the Report Variables list.
Youve created your first report variable. You can view the dialog box by selecting it
in the Report Variables list and pressing the Value button.
Setting a date value:
To set a date value for a report variable, you can either type it in manually, or use
ReportSmiths calendar.
1 Press the calendar button next to the text entry box to see the calendar.
2 To report the date value use the Year, Month and Day items:
Year
Month
Day
Use the right and left arrows on either side of the year shown to choose
the appropriate year.
Use the right and left arrows on either side of the month to choose the
appropriate month.
Press the button corresponding to the appropriate day.
3 Choose OK.
76
Creating Reports
1 Place the cursor into the Name box and type the following:
Salesperson
Blake
Ginsberg
Keats
Pound
Rimbaud
Snyder
6 Press the Add button on the left side of the dialog box to add the Salesperson report
variable to the Report Variables list.
7 To see the dialog box you just created, highlight Salesperson in the Report Variables
list and press the Value button. ReportSmith displays the Salesperson report
variable.
8 Press OK to exit the report variable.
After you create the report variables, press the Selections button to see the Selections
dialog box where youll insert them into your selection criteria. By inserting the
report variables into the Selection formula, ReportSmith selects the necessary data to
insert in your report up-front, based on the users responses to the prompts.
Before you delete a report variable, make sure it isnt used anywhere else in your
report. If it is, youll need to delete it from those areas.
77
1 Open the Report Variables dialog box. Enter a name for your report variable, choose
a data type, enter a title, and a prompt.
2 Under Entry, select Choose From A Table. The dialog box displays associated
settings.
3 Choose the Table button. The Select List Table For Report Variable dialog box
appears. In the Files list, choose the table that contains the column you want to use. If
you need to, navigate using the Type, Drives, Directories, or Connections list boxes.
Note
You can use a different table or data source type than the one your report was created
with. For example, if you have a dBASE report, but you have saved a list of values
you want in a FoxPro table, you can connect to FoxPro here and use that table.
4 Press OK.
5 Under Select, press the Field(s) button. The Report Variable Fields dialog box
appears.
6 Under Display Value from Field, choose a field to display to the user. This is the
value the user sees; it is not necessarily the value used. Under Use Value from Field,
choose the field you want to report the report variable equal to. This is the value used
by your report variable.
In most cases, the fields you choose for Display Value from Field and Use Value from
Field are the same. However, there are some cases when youll want to display one
field but use another.
For example, suppose you have two columns in your table: EMP_LNAME and
EMPLYEE_ID. The EMPLYEE_ID field has an index which enables you to search
through it quickly, so you want your selection criteria to search that field. However,
you dont want your users to have to know employee ID numbers in order to run a
report. In this case, youd display an employees name for your user to select, while
using the employees ID number as the value for your selection criteria.
7 Press OK and press Add. ReportSmith adds your report variable to the Report
Variables list.
8 Press Done.
78
Creating Reports
subquery, or detail. Generally, the master report has one record per key value, while the
detail report contains many records per key value.
An example of a master/detail report is your bank statementat the top, it displays
your name, account number, and address from a customer table. The next section
displays withdrawals for each account. You could also have another section which
displays only deposits. Information in each section originates from different tables with
different qualification. Furthermore, each section might have its own formatting and
totals.
The diagram below shows the idea behind a master/detail relationship for a bank
statement. The report created can describe three different queries: CUSTOMER=Bob
Smith, CUSTOMER=Bob Smith AND transaction_type= DEPOSIT, and
CUSTOMER=Bob Smith AND transaction_type=WITHDRAWAL. In this case, each
query is linked on the CUSTOMER field.
Another example of using a master/detail report might be one in which each
department shows a breakdown of information by each employee. In this case, the main
report uses the DEPARTMENT table, while the detail report uses the EMPLOYEE table.
Note
1 Create a new columnar report to serve as the master report. Choose Insert|Detail
Reports. In the Master/Detail Reports dialog box, Master Report is the default
name for the master query.
2 To add another query to your report, choose Add to see the Tables dialog box. In the
Tables dialog box, choose Add Table, select one or more tables and choose OK. Select
columns to include or exclude and press Done.
3 In the Link Master/Detail Reports dialog box, ReportSmith has selected a common
field in each table for linking tables. You can use these fields or select another
common field to link the tables. Place at least one common field into both Key Fields
list boxes and choose OK.
4 In the Master/Detail Reports dialog box, choose OK to load records onto your report.
Make sure View|Boundaries is on so you can see the distinct sections of your report:
Main Report l, and Detail Report 1.
Note
Once you create a detail report you can select it by choosing it from the drop-down
detail reports list box that appears in every dialog box after you create one.
1 With your report open, choose Edit|Detail Reports to see the Master/Detail Reports
dialog box. Select the detail report you want to name and choose Name.
79
2 Enter a name for the detail report and choose OK. The name appears in each
associated section on your report.
Option
Description
Add
Delete
Modify
Name
Links
Default
1 With your report open, choose Insert|Field Labels. Youll see that the dialog box
displays a list box containing the name of each detail report. Select a detail report.
2 Turn on Group Header/Footer and New Page options and choose OK. Labels now
appear for each set of data displayed for the detail report.
80
Creating Reports
Most other dialog boxes that let you modify your query will let you select which detail
report your changes apply to from a drop-down list box.
Saving a report
If youre ready to begin work on another report, or youd like to exit ReportSmith,
follow these steps to save your report.
3 Enter a name for your report into the Filename text box and choose OK.
4 To exit ReportSmith, choose File|Exit.
81
The temporary table itself must be stored in an ODBC connection, however, the original
data can originate anywhere.
When you save a report as a temporary table, it saves each aspect of the report as a
separate column. Data columns and derived fields are named numerically in order.
Summary fields appear as columns and use the following naming convention:
SumFunction|GroupLevel_Column#
Element
Description
SumFunction
Group Level
Column#
The summary function for the summary field (Min, Max, Sum and so on).
The group level to which the summary is set.
The position or order number of the summary column in your report.
For example, the name of a summary field that counted the number of values in the 3rd
column at the Entire Report Group level in your report is COUNT1_3, and the name of a
summary field that summarized the first column in your report at your primary group
(first group you have created) is SUM2_1.
To create and use a temporary table:
1 Open a report.
2 Write a report macro like the one below to export your report data to a temporary
table:
Sub temptable()
'Create a dataset object to hold the temp table values
dim DS as dataset
DS.SetFromActive
' Export the table to the database for this new report to use
DS.exporttable 'mytable', 55, "RS_dbase", ", " ", " "
End Sub
3 Link the macro you created to a report-level event, such as the closing of your report.
82
Creating Reports
4 After making sure this macro has run, create a new report, and choose the table with
the name that matches the name you indicated in the export table command in your
macro. In the above example, it is mytable.
You now have a new report containing a separate column for each data field, derived
field, and summary field from you original report. You can now manipulate these
fields in the same manner as regular data fields (sort, group, and perform
summaries.)
You can save your report as an .RQF file. This type of file can be used to update a
temporary table each time you run a report. It contains a description of how to get
the data you just exported from the source. Creating an .RQF file can be done
through File|Save As, or via a macro. If you choose to save the file via a macro, add
the following line to the macro above that is used to export the table:
DS.Save "Filename.RQF"
You probably want to name an .RQF file the same as you named your temporary table.
83
84
Creating Reports
Chapter
Formatting
Chapter 5
ReportSmiths versatile formatting capabilities let you transform your data into high
quality presentations. This chapter discusses formatting techniques you can apply to
any kind of report.
Columns
When you create a columnar report, fields appear as columns across the report page. A
column heading, or field label, identifies each column. ReportSmith takes field names
from your database and applies them to columns on your report, creating the field
labels. You can change the field labels after creating them.
Use Column mode to move columns horizontally across the page, moving labels along
with columns. Columns can move closer together as the selected columns are removed
and other columns shift to accommodate the selected columns.
If you delete a column in Column mode, ReportSmith repositions the remaining
columns moving them closer together and filling in the blank space.
Chapter 5, Formatting
85
After selected, you can move the column and its label to a different location, format
the column, or delete it from the report.
To select multiple columns:
Click and drag the mouse, stretching the dotted box until it surrounds all of the
columns you want to select
Ctrl+click to select more than one column and release the mouse.
To move a column:
1 Drag the column to a new location. Youll see a drop bar that indicates the position of
the column if you release the mouse in the current location.
2 Release the mouse. ReportSmith repositions the column and its label, rearranging the
columns around it.
To cancel the move while dragging a column, right-click the mouse. The column returns
to its original position.
Fields
Fields are the data within columns. Use Form mode to move individual fields freely
around the report pagehorizontally and vertically. Use this mode to place fields on
labels and forms and into headers and footers.
86
Creating Reports
Use the sizing handles that appear on the first record to resize all fields or to add
space between rows or columns.
Note
You can also use the Row Height or Field Height command on the Format menu to
specify a distinct size.
To select fields in multiple columns:
Click and drag the mouse, stretching the dotted box that appears until it surrounds
all the fields you want.
Ctrl+click on more than one column and release the mouse when youve finished
selecting.
Shift+click to select a block of column fields.
Rows
You can select rows of data across columns. A row is the set of values from within each
column that comprise a set of information. After you select a row, you can resize and
format it. Changes you apply to the selected row apply to all of the rows in your report.
You can resize a row to create blank space between your records or to create a form
report. You can stretch a row up to the size of a full page.
Selecting a row
Click the left margin of the row between the data and the edge of the report. A box with
sizing handles surrounds the selected row.
Chapter 5, Formatting
87
See Placing items into a header or footer on page 107 for how to place fields into a
header or footer.
Body
You can select a body of data in a report. A body is any data positioned between a
header or footer which appears as a group. After selected, you can add borders,
shading, or patterns to the body of your report. You can also resize the width of the
bodys border by dragging the sizing handles.
To select the body of a report, double-click in the body you want to select.
Text
You can select text on your report.
To select text:
1 Click once on the text to select it. You can then drag and drop it into place.
2 Click again. The Insertion Point cursor appears to the left of the text, indicating that
you are in Text Mode. You can now revise the selected text.
3 Once edited, click outside of the field to accept your changes.
Resizing objects
ReportSmith makes it easy for you to resize objects such as columns, fields and sections
in your report quickly. Just click to select the object and pull on the sizing handles
surrounding it to enlarge or decrease the size.
To resize objects in your report:
88
Creating Reports
3 Choose Detach Label. ReportSmith detaches the selected section from the size of the
labels. Now, you can use the sizing handles to resize it. Only the page header and
footer can be detached from the set of labels and independently resized or moved.
Note
Setting margins
Every report page has defined margins you can set with the Page Setup command on
the File menu. ReportSmith has options for the top, bottom, left, right, and gutter
margins.
To set margins for a report:
1 Open a report.
2 Select the Page Setup command from the File menu. The Page Setup dialog box
appears.
Note
Watch the Sample box as you adjust each margin setting. Changes you make are
reflected instantly so you can make sure youve specified exactly the settings you want.
Option
Function
Margins
Click in this option and the settings in the dialog box change to reflect settings for
margins including top, bottom, left, right, and gutter spacing.
Chapter 5, Formatting
89
Option
Function
Size and
Orientation
Labels
Click in this option and settings in the dialog box change to reflect size and
orientation settings including paper size, width, height, and orientation.
Click this option and settings in the dialog box reflect settings for labels. The
Labels option is only available for label reports. Other report types display this option
in gray to indicate that its not available.
Selecting any of the given label types changes the label dimensions, paper size, and
margins to match the label definition. The maximum number of labels that fits within
the page display in the Sample box.
ReportSmith uses the non-printing areas established for your printer as the default
printer margins. These margin settings appear in the Printer Margins dialog box. While
you can set margins that fall inside the non-printing areas, parts of your report can be
clipped off if you do. To view the print area, turn on the Print Area command on the
View menu.
Default measurements
The default measurement scale is in inches. However, you can change the default to
centimeters with the Options command on the Tools menu. To use a measurement scale
other than the default, enter the number and one of the following abbreviations in the
measurement boxes for each margin.
Measurement
Action
Inches
Centimeters
Picas
Lines
Points
If you use a measurement scale other than the default, ReportSmith converts it to the
default measurement. For example, if you enter 3 pi in the top margin box and inches is
the default unit, ReportSmith converts it to .50 inches
1 From the File menu, choose the Page Setup command. The Page Setup dialog box
appears.
You can also set paper size for many printers in the Print Setup dialog box. The
settings in the Page Setup dialog box override those set in the Print Setup dialog box.
2 Click the Size and Orientation option button in the Page Setup dialog box. Options in
the dialog box change to Size and Orientation settings; paper size, width, height, and
portrait and landscape options appear.
90
Creating Reports
3 Press the down arrow in the Paper Size box to select a default paper size youre using
to print the report. Alternatively, enter a custom paper size in the Width and Height
boxes.
4 Press OK.
To set the paper orientation:
Setting up labels
If youve chosen Label as your report type in the Report Types dialog box, youll need to
set up the layout of your labels (specifications). Youll do this in the Page Setup dialog
box, using the Labels option.
To set labels specifications:
4 Set the Width, Height, and Vertical and Horizontal Gaps. These settings indicate the
amount of space between labels.
5 Click in one of the following options: Display Across Then Down, or Display Down
Then Across.
If you choose Across Then Down, your labels appear like this:
Chapter 5, Formatting
91
If you choose Down Then Across, your labels appear like this:
1 Open a report.
2 Choose either Insert|Picture or Insert|Object.
3 Place the object on the report page, then click and drag one of the sizing handles until
the object is the appropriate size.
To reposition a background object, click and drag it to the new position.
4 Click and drag the body of the report until its positioned on top of the background
object. The object now resides in the background of the report.
To add a background with the Wallpaper option:
1 Open a report.
2 Choose File|Page Setup. The Page Setup dialog box appears.
3 Press the Wallpaper button. The Wallpaper dialog box appears.
With the Wallpaper options, you can specify the bitmap, its position on a page, and
whether you can print the bitmap with a report.
4 Click the down arrow and a drop-down list of bitmaps appears. These bitmaps are
stored in the ReportSmith directory.
5 Select a bitmap from the list. Alternatively, type in the path and file name of a bitmap
in another directory.
6 Choose an option to position the bitmap in the background of the report.
The following table lists all available options for positioning a bitmap:
92
Type
Entry Options
Center
Horz/Vert Just.
Left
Creating Reports
Type
Entry Options
Right
Vert
Top
Bottom
7 Make sure the Do Not Print check box is deselected so the bitmap prints with the
report.
8 Press OK.
ReportSmith places the bitmap in the background of the report according to the
settings youve chosen.
Use the Snap to Grid feature to place fields and text at these coordinates. The Snap to
Grid feature makes data placement and alignment easy. The grid is invisible until you
select the Grid option from the View menu. When you select this option the Grid
Attributes dialog box appears.
Formatting techniques
ReportSmith lets you format characters (text, numbers and symbols) in a column or field
label. Within a report, you can
Chapter 5, Formatting
93
Characters
You can format characters in a column by using
Format|Character command
The ribbon
Pop-up Format menu
To format a column with the Character command:
1 Click once on the column you want to format. Use Shift+click to select additional
columns.
2 To display the Font Dialog box, do one of the following:
Click the right-mouse button and select the Character command from the pop-up
Format menu.
Choose Format|Character.
94
Creating Reports
Note
Available font sizes depend on the fonts you have installed on your machine. Here are
examples of different font sizes:
24 pt
12 pt
10 pt
8pt
1 Select the formatting options you want. You can set the font, style (bold, bold italic,
and italic), size, effect (strikeout or underline), and color. You can use character
formats to emphasize text and to create special effects in your reports. The following
character formatting options are available in ReportSmith:
bold
italic
strikeout
colors
underline
bolditalic
You can apply a format by choosing it. Remove the format by choosing it again. You
can apply multiple character formats to the same text, such as adding an underline to
a bold word. The Sample window displays what each selected format looks like.
2 Click the OK button when youve finished setting the formatting options.
ReportSmith applies the settings to the selected column.
To format a column with the ribbon:
1 Click once on a single column or select multiple columns with the mouse.
2 Select the font and point size for the characters.
3 Use the following ribbon buttons to format the column.
Bold Underline
Center align
Font
Italic
Point size
Right align
Left align
1 Select the column or columns with the mouse. A box with sizing handles surrounds
the selected column or columns.
2 Click the appropriate alignment button on the ribbon.
Chapter 5, Formatting
95
Positioning columns
You can drag and drop columns in a report and place them in any order. You can also
adjust the distance between columns. When youre positioning columns, press the
Column Mode button on the toolbar. This mode lets you move columns, along with
column labels, vertically across the report.
Note
The database settings in the tables or files you include in a report determine the initial
width of columns.
To move a column:
3 Use the arrow keys or type a number in the Column Width box to set the width for a
selected column, or press the Best Fit button.
4 Do one of the following:
Press OK. ReportSmith applies the new width to the selected column.
Click the Use Default Width check box and press OK.
ReportSmith uses the default column width determined by the tables or files from
a database you included in a report.
Press the Best Fit button. ReportSmith determines the best width of a selected
column by scanning all records of your report for the largest field within that
column.
Note
96
For a large report, this function may take some time to calculate the best width.
Creating Reports
Field labels
You can format characters in a field label separate from the fields in a column. For
example, you can bold and increase the point size for emphasis.
To format a field label with Format|Field:
1 Select the first field label you want to format. A box surrounds the selected field label.
2 Use Shift+click to select all field labels in between the first selected field label and the
one you Shift+click. If you want to select more than one individual field label, use
Ctrl+click.
3 Right-click and choose Character, or choose Format|Character. The Font dialog box
appears.
4 Select the formatting options you want. You can set the font, style (bold, bold italic,
and italic), size, and effect (strikeout and underline). The Sample window shows the
selected format. Press OK.
To format a field label with the ribbon:
1 Select the field label you want to format. A box surrounds the selected field label.
2 Select the font and point size for the characters.
3 Press only the following buttons on the ribbon to format the field. For more detailed
formatting options, such as strikeout, underline and smaller fonts, use Format|
Character.
To create multiple-line field labels:
Chapter 5, Formatting
97
Percentage
Scientific
To set number formats with the Field Formats command:
1 Select the column with the dates or times you want to format. A box surrounds the
column.
2 Right-click the mouse and select the Field Formats command from the pop-up
Format menu, or choose the Field Formats command from the Format menu. The
Format Field dialog box appears.
98
Creating Reports
3 Select the format category you want from the Category box.
4 Select the format code you want from the Format Codes box, or type a custom code
format directly into the Format box. The selected code appears in the Format box.
Additionally, you can create your own customized formats. To create a custom format,
type one into the Format box using the following structural guidelines:
[positive format];[negative format];[zero value format]
Note
Chapter 5, Formatting
99
###.##;(Red)###.##;""
1 Choose Tools|Drawing and click the Text button on the Drawing toolbox, or press
the Text button on the ribbon.
2 Click where you want to place the text in your report.
Note
When placing text within a sectiona row or page header or footer, for exampleit
appears in each section of the same type. For example, if you place text in a row, it
repeats in every row. A blinking text cursor appears.
3 Type the text. Click the cursor anywhere on your screen when youve finished
typing.
To edit text:
1 Click once on the text you want to edit with the mouse to select it. A box with sizing
handles surrounds the text.
2 Click again within the text box and the text cursor appears for you to enter your text.
3 Modify the text.
4 Click outside the text box when youve finished editing.
To format text with the Character command:
1 Select the text you want to format with the mouse. A box with sizing handles
surrounds the text.
2 Click the right-mouse button and select the Character command from the pop-up
Format menu, or select the Character command from the Format menu.
The Font dialog box appears.
3 Select the formatting options you want. You can set the font, style (regular, bold, bold
italic, and italic), size, and effect (strikeout and underline). Press OK.
To wrap text:
100
Creating Reports
Adding borders
When youre formatting a report you can add a border for style or emphasis. This
section describes how you can add borders to reports and items within them.
To place a border around an item:
1 Make sure you havent selected anything else in the report and select the item you
want to place a border around.
2 Choose Format|Border, or select the item and right-click the mouse, then choose
Border from the pop-up menu. The Borders dialog box appears.
Note
The Sample window shows how a border changes as you select options. The gray
crosshatch represents the object surrounded by the border.
If you dont want to add a border around all sides, use a combination of the Left,
Right, Top, or Bottom styles to achieve the desired effect.
7 Set the distance between the border and the item with the Standoff option. Click
repeatedly on the bottom arrow to move the border closer to the body of the item.
Click repeatedly on the top arrow to move it further away from the item.
8 Set the line thickness for the border with the Thickness option.
9 Press the OK button when youre satisfied with the border settings. ReportSmith
places a border around the item.
10 Press the Whole Page button on the ribbon to see how the border looks.
Chapter 5, Formatting
101
To undo a border:
Examine the Sample to make sure you have the formatting look you want before
applying it.
8 Press OK. ReportSmith darkens the bottom and right side of the selected object based
on your settings.
To place a pattern and color within a bordered item:
102
Creating Reports
Inserting fields
You can place report fields into your report using the Insert|Insert Field command.
Report fields include fields that you create such as derived fields, report variables and
summary fields; fields included with ReportSmith for your use called system fields; and
each of the data fields in the table(s) to which your report is connected.
You can choose from a list of Fields in the Insert Database Field dialog box. The list is
shown below:
A list of fields in each category appear in the dialog after you select a category. For
example, if you select Data Fields, a list of the available fields from each database table
you are connected to appears in the dialog box. If you choose Derived Fields, a list of
each derived field you created for this report appears in the dialog box.
Note
If you havent created any fields such as derived fields, report variables, and summary
fields the list appears blank.
There are three ways to insert a field using the Insert Field dialog box:
Select the field and press the Insert button, and click on the report to place the field.
Select the field and while holding the mouse button, drag the field off the dialog box
and onto the report.
Note
You can use this method for all types of reports except crosstab reports.
Data fields
Data Fields are the columns of information contained in each of your tables. You can
insert a data field into your report using the Insert Field command on the Insert
menu.
Chapter 5, Formatting
103
Derived fields
You can insert derived fields that you create using the Insert Field command on the
Insert menu. A derived field is a field you have created using SQL code or the
ReportBasic macro language.
Report variables
You can insert report variables that you create using the Insert Field command on the
Insert menu. A report variable appears in your report as a dialog box and can prompt a
user for information.
104
Creating Reports
System fields
A system field is one that has been created by ReportSmith for your use, such as the
date, time or page number. ReportSmith offers you a selection of system fields.
Description
Todays Date
Current Time
Todays Date and Current Time
Page Number
Text Fields
Report Name
Summary fields
You can insert summary fields that you create by using the Insert|Insert Field
command. A summary field is a calculated field such as a subtotal or count.
Chapter 5, Formatting
105
If you place a summary field into a group header or footer, ReportSmith calculates the
field based on that group. If you drop a summary field into a page header or footer,
ReportSmith calculates the summary field based on the records per page and displays a
summary on each page.
To insert a summary field into a group:
1 Choose Insert|Insert Field. The Insert Database Field dialog box appears.
2 Press the down arrow in the list box and select the appropriate field category. A list of
data fields from each added database table appears for you to choose from.
3 Select a field name to insert from the Field Name list and press Insert.
4 Position the Object cursor in a group header or footer and click the mouse. The data
field appears on your report, calculating a summary for each group.
Note
If you decide to change the field to base it on a page, right-click the mouse and choose
Calculate Over Page from the pop-up menu.
To insert a summary field for each page:
1 Follow the above steps for inserting a field into your report.
2 Position the Object cursor in a page header or footer and click the mouse.
Note
If you decide to change the field to base it on a group, right-click the mouse and choose
Calculate Over Group from the pop-up menu.
1 Choose Insert|Field Labels. The Insert Field Labels dialog box appears.
2 Click the New Page check box and an X appears. The field labels appear at the top of
each report page and print with the report. (Click the check box again and the X
disappears. This turns off field labels so they dont appear at the top of each page.)
To insert field labels before or after grouped data:
1 Choose Insert|Field Labels. The Insert Field Labels dialog box appears.
106
Creating Reports
2 Click the Group Header/Footer check box to place an X in the check box. The field
labels appear after any set of group headers and footers that appear before a detail
section.
Note
Click again to delete the X in the check box and the field labels turn off.
Placement
Page
Entire Report Group
Places the header or footer at the top or bottom of each report page.
Places the header or footer at the top of the first report page or the bottom of the
last report page. Actions performed with the Entire Report Group affect all fields
in your report.
Places the header or footer above or below a selected group of data in your
report.
Group
Chapter 5, Formatting
107
1 Open a report and select a column which you would like to be of variable height.
2 Choose Format|Field Height, or right-click and choose Field Height from the pop-up
menu. The Field Height dialog box appears.
3 Choose an option in the dialog box. To allow the field to increase in height from the
default height, choose Can Grow. To allow the field to decrease in height from the
default height, choose Can Shrink. To allow the field to fit the data contained within
the field, turn on both options.
When you use the Field Height or Row Height command, the Repaginate button
appears on the toolbar. You can press the button to automatically repaginate your report
after youve resized fields or rows. (This button only appears when youre using these
commands.)
108
Creating Reports
still allow a field to grow, allowing you to control the size of row. For example, you can
ensure that the row does not exceed a specified size.
To specify the height of a row:
1 Choose Format|Row Height or select the row you want to be of variable height,
right-click and choose Row Height from the pop-up menu. The Row Height dialog
box appears.
2 Choose an option in the dialog box. To allow the record to increase in height from the
default height, choose Can Grow. To allow the record to decrease in height from the
default height, choose Can Shrink. To allow the record to increase or decrease in
height from the default height, turn on both options.
2 From the Apply to Section box, select the section with data you want to hide.
All the headers or footers in your report are listed. The Detail section also appears in
the list box.
Chapter 5, Formatting
109
3 Click the Hide Section option and press OK. The section you selected doesnt display
in the report. The data isnt deleted from the report. Click the Hide Section option
again to retrieve the hidden section.
Paginating a report
You can tell ReportSmith where you want pages to break before you print a report. The
Section command on the Format menu has options for inserting page breaks before or
after sections.
You can also use this command to ensure that a section doesnt break across two pages
and to keep multiple sections together so they always print on the same report page.
To paginate a report:
Result
Places a page break before a selected section and prints the section.
Places a page break after a selected section and begins a new page.
Prevents a section from splitting across two pages.
Ties two sections together so they always print on the same page, if possible.
Aligning objects
ReportSmith places useful alignment tools at your fingertips with the Align toolbox.
You can align objects or fields according to how they are positioned with each other or
with the baseline. Use the Align toolbox to ensure equidistant spacing between fields
and columns; to align items to the right, left, center, top or bottom; to add or remove
spacing above, below and between items; to stack items; or to align items in a row.
The Align functions behave differently according to whether youre in Form or Column
mode. When you align fields and/or columns use Form mode. In Column mode, the
alignment tool buttons have no effect on columns within the detail section of your
report. Selected columns act as anchors around which fields from other sections can be
aligned. This is especially useful for aligning summary fields from headers or footers
with the summary columns. In Column mode, columns remain stationary and align
relative to the right- or left-most column border.
To open the Align toolbox:
Choose Tools|Alignment.
110
Creating Reports
To move it, point in the title bar and drag it into place.
Function
Align to the top-most field.
Reduce vertical space equally between selected fields. Each time you press the button,
ReportSmith moves fields in a pixel at a time.
Space fields equally horizontally within the selected area.
Add equal horizontal space between selected fields. Each time you press the button
ReportSmith adds one pixel between each field.
Space selected items closer together vertically.
Align fields to a common baseline. The baseline is the line the letters rest on as opposed to the
text or column boundary.
Chapter 5, Formatting
111
Button
Function
Stack fields horizontally in a row aligned in relation to the baseline of the lowest column you
selected. This function is order-dependent.
Stack fields vertically in a column in relation to the boundary of the right-most column you
selected. This function is order-dependent.
B
C
To center objects:
If you select objects in a global section-a page header or footer, a row, and so onyou also select all objects in sections of the same type. For example, if you select all
objects in one page header, you also select objects in all page headers and the
alignment function you choose applies to them as well,
Click to select an object that you want to center vertically. Then press Ctrl+click to
select additional objects,
Note
If you only select one object, it aligns to the vertical center of the section its placed
in.
Select an entire section and you select all objects in the section.
112
Creating Reports
ReportSmith moves all selected objects (A, B, C) so theyre placed on the same
horizontal plane, based on the center object in a group of selected objects.
If you only select one object, it aligns to the bottom of the section its placed in.
Select an entire section and you select all objects in the section.
2 Press the Align to Bottom button. ReportSmith moves all selected objects (A, B) so
they align with the lower-most selected object (C).
To left-align objects:
If you only select one object, it aligns to the left of the section its placed in. If you
select a column or a row and another object, the column or the row is the anchor
and doesnt move. The other object aligns with the left edge of the column or row.
Select an entire section and you select all objects in that section.
2 Press the Align to Left button. ReportSmith moves all selected objects (B, C) so they
align with the left-most selected object (A). The left-most selected object serves as the
anchor and doesnt move.
Chapter 5, Formatting
113
If you only select one object, it aligns to the horizontal center of the section its
placed in. If you select a column or row and another object, the column or row is
the anchor and doesnt move. The other object aligns to the horizontal center of the
column or the row.
Select an entire section and you select all objects in that section.
2 Press the Align to Horizontal Center button. ReportSmith moves all selected objects
(A, B, C) so theyre centered horizontally.
To right-align objects:
If you only select one object, it aligns to the right of the section its placed in. If you
select a column or a row and another object, the column or row becomes the
anchor and doesnt move. The other object aligns with the right edge of the
column or row.
Select an entire section and you select all objects in that section.
2 Choose the Align to Right button on the Align toolbox. ReportSmith moves all
selected objects (A, B) so theyre aligned with the right-most selected object (C). The
right-most object serves as the anchor and doesnt move.
1 Click the left-mouse button and drag the rubber band around all objects in a section
you want to align, or click to select the left-most object. Press Ctrl+click to select
additional objects you want to move closer to the left-most selected object.
114
Creating Reports
2 Press the Decrease Horizontal Space button. ReportSmith moves all selected objects
toward the left-most selected object one pixel for each click of the button. The leftmost object serves as the anchor and doesnt move.
To equalize horizontal space among objects:
1 Click the left-mouse button and drag the rubber band around all objects in a section
you want to align, or click to select the left-most object that you want to space. Press
Ctrl+click to select additional objects.
2 Press the Equalize Horizontal Space button (shown below). ReportSmith adjusts all
selected objects (A, B, C) so theyre equally spaced. The left-most object (A) serves as
the anchor and doesnt move.
1 Click the left-mouse button and drag the rubber band around all objects in a section
you want to align, or click to select an object from which you want to move other
objects away. Press Ctrl+click to select additional objects.
2 Choose the Increase Horizontal Space button on the Align toolbox. ReportSmith
moves all selected objects away from the left-most object, one pixel for each click. The
left-most object serves as the anchor and doesnt move.
To decrease vertical space among objects:
1 Click the left-mouse button and drag the rubber band around all objects in a section
you want to align, or click to select an object to which you want to move other objects
closer. Press Ctrl+click to select additional objects.
2 Choose the Decrease Vertical Space button on the Align toolbox. ReportSmith moves
all selected objects up, toward the upper-most selected object, one pixel for each click.
The upper-most object serves as the anchor and doesnt move
To equalize vertical space among objects:
1 Click the left-mouse button and drag the rubber band around all objects in a section
you want to align, or click to select an object that you want to space. Press Ctrl+click to
select additional objects.
Chapter 5, Formatting
115
2 Press the Equalize Vertical Space button on the Align toolbox. ReportSmith adjusts
all selected objects (A, B, C) so theyre equally spaced. The upper-most object (A)
serves as the anchor and doesnt move.
1 Click the left-mouse button and drag the rubber band around all objects in a section
you want to align, or click to select an object from which you want to move other
objects away. Press Ctrl+click to select additional objects you want to move away from
the upper-most selected object.
2 Choose the Increase Vertical Space button on the Align toolbox. ReportSmith moves
all selected objects down from the upper-most object, one pixel for each click. The
upper-most object serves as the anchor and doesnt move.
To align text to a common baseline:
1 Click to select the first field you want to align to a common baseline. This field serves
as the anchor.
2 Press Ctrl+click to select additional fields you want to align to a common baseline.
3 Press the Baseline button. ReportSmith aligns all selected fields to the font baseline of
the anchor field.
To align objects in a row:
1 Click to select the object you want to align all other selected objects with, to create a
row. This object serves as the anchor and doesnt move.
2 Press Ctrl+click to select any other fields you want to align in the row.
3 Choose the Row button on the Align toolbox. ReportSmith aligns the selected objects
(A, C) to the right of the object serving as anchor (B). It places the objects in the row in
the order you select them, and each object touches the one next to it.
To stack objects:
1 Click to select the object under which you want to stack other objects. This object
serves as the anchor and doesnt move.
116
Creating Reports
Aligning text
Alignment refers to the placement of the field value within the space allotted for the
field on the report. ReportSmith lets you align text with the Text Alignment toolbox. To
access this toolbox, select the text you want to align, right-click the mouse and choose
Text Alignment from the pop-up format menu. Choose Text Alignment and the toolbox
appears.
To align text:
Aligning left
Click Left to place all field values flush left in the space allotted. The first character in the
value is flush against the left margin of the field border. When you select Left,
ReportSmith aligns the first character in each field:
Chapter 5, Formatting
117
Aligning center
Click Center to center the values within the space allotted by the border:
Aligning right
Click right to place all values flush right in the space allotted. The last character in the
value is flush against the right margin of the field. When you choose Right, ReportSmith
aligns the last character in each value:
Drawing
ReportSmiths Drawing toolbox helps you accurately draw commonly used shapes such
as lines, circles, boxes and polygons; you can position items in back or in front of each
other. You can type text into your drawings.
118
Creating Reports
Icon
Function
Arrow
Select an object.
Box
Draw a box. When the cross-cursor appears, select a starting point and hold
the left mouse button. Drag the cursor until the box is the size you require
and release the mouse button.
Line
Draw a line. When the cross-cursor appears, select a starting point and hold
the left mouse button. Drag the cursor until the line is the size you want,
then release the mouse button.
Polygon
Round
Rectangle
Draw a box with rounded corners. When the cross-cursor appears, select a
starting point and hold down the left mouse button. Drag the cursor until
the box is the size you require and release the mouse.
Circle
Draw a circle. When the cross-cursor appears, select a starting point and
hold the left mouse button. Drag the cursor until the circle is the size you
require and release the mouse.
Polyline
Text
Insert text into a report. When the Text cursor appears, position it where you
want to place text and left-click the mouse. Type in the text. When youve
finished entering text, click the Text cursor outside the text field or select
another tool.
Group
Group selected objects together. Select the objects you want to group (click
the first object; Ctrl+click to select additional objects.) Click the Group tool
and the objects group automatically. To select one object within the group,
click any object to select the group, then click on the object you want to
select.
Chapter 5, Formatting
119
Name
Icon
Function
Ungroup
Ungroup objects and select them individually. Click any object within the
group to select it, then click the Ungroup tool. Objects can now be selected
individually.
Move to
Front
Move a selected object to the front of other objects. Click the object you want
to move to the front, then click the Move to Front tool to place the selected
object on top of all other objects placed in the same position. If you have
several layers of object you may need to press this button more than once.
Move to
Back
Move a selected object to the back of other objects. Click the object you want
to send to the back, then click the Move to Back tool to place the selected
object behind all other objects that are placed in the same position. If you
have several layers of object, you may need to press this button more than
once.
Applying a style
Use the Report Styles dialog box to choose a report style, save or edit a style, assign a
default style to a report, and remove styles you no longer use.
To apply a style :
120
Creating Reports
1 Open a report and press the Style button. The Report Styles dialog box appears.
2 Choose a style from the System Styles or Custom Styles list boxes and choose Apply.
3 Select a style and preview it in the Sample box. Choose Apply.
4 To save a style, choose New and enter a name for it.
Default style
To use the default style already assigned, select a report type and press OK and create
your report.
To change the style, choose Style and select a style in the New Report Style dialog
box, and choose Use As Default. The default style appears in the Create A New
Report dialog box when you select the report type to which it has been assigned.
Creating a style
You can save styles you use frequently and apply them instantly. Styles that you create
appear in the Custom Styles list. If youve already formatted a report, most of the work
Chapter 5, Formatting
121
to create a style is behind you. Now all you need to do is assign names to report formats
you like. Alternatively, you can customize a system style.
To save a style:
You can save the current formatting of a selected report as a new style.
1 After applying formatting elements to your report, press the Styles button.
2 Choose New and type a name for your style into the Save As dialog box. If you want,
you can use the default style name ReportSmith assigns, such as Style 1, Style 2,
and so on. Style names can contain up to 24 characters and can include any
combination of characters and spaces. Style names are not case-sensitive;
ReportSmith treats Summary and summary the same. The name you assign a
style must be unique for a particular report. For example, a crosstab can only have
one style named Financial.
3 Press OK to add your style to the Custom Styles list, and press Apply to apply it to
your report.
Modifying a style
After youve defined a style, you can modify it and save it to another style. Redefining a
style updates that style only in the active document, leaving those reports which youve
previously formatted with that same style untouched. To modify other reports that use
the same style, open each report and apply the redefined style.
ReportSmith offers you two methods for modifying a report style:
Modify formatting on the report and save the style
Use the Edit Report Style dialog box
To modify a style on the report surface:
122
Creating Reports
1 In the Report Styles dialog box, select the style you want to modify and press Edit.
The Edit Report Style dialog box appears.
2 Scroll through the Object list, select the type of object you want to edit, and choose a
formatting button to select options in the associated dialog box. Set options and press
OK, then press OK again to exit the Edit Report Style dialog box. Choose Apply.
ReportSmith applies the style to the report.
Deleting a style
You can delete a custom style, but this affects reports which have been assigned that
style. ReportSmith alerts you with a message reminding you that removing the style
affects any reports with that style. When other reports are affected, you replace their
styles with the basic, non-formatted style. You cannot delete a system style.
1 In the Report Styles dialog box, choose the style you want to delete.
2 Press Delete. ReportSmith displays a message asking you to confirm that you want to
delete the style.
3 Press Yes to delete the style, No to cancel the delete.
4 Choose Close to exit the Report Styles dialog box.
Chapter 5, Formatting
123
This example shows how you can apply three formatting attributes (bold, no
underline, and larger font size) to other fields in your report with just a click.
124
Creating Reports
Note
ReportSmith takes the first row encountered and shrinks or expands the remaining
rows based on the height of the first row. You can adjust all of the rows by resizing the
row, then the picture.
The following example report contains two columns. The first, NAME, contains the
name of a picture (or .BMP) file. The second, IMAGE, contains the file name of each
picture. Here, well show you how to display the file names in the IMAGE column as
pictures.
1 Select the column containing the picture files. In this case, well select the IMAGE
column.
2 Right-click and choose Display as Picture. The Display As Picture dialog box appears.
3 From the Display Field As list, select the type of image file. Our files are bitmaps, or
.BMP files, so we have selected Windows Bitmap.
4 Adjust the Initial Scale option to scale the size of the picture that display on your
report and press OK. ReportSmith locates each file name on the system and displays
the picture stored inside it.
Chapter 5, Formatting
125
126
Creating Reports
Chapter
Graphs
Chapter 6
If you have Microsoft Graph installed on your system you can instantly transform
report data into graphs. You can create any type of graphs including pie, line, area,
column and combination graphs which you can format to suit your needs.
3 Move your cursor within the boundaries of a header or footer. The Graph cursor
appears.
Chapter 6, Graphs
127
4 Use the mouse to position the Graph cursor in the header or footer where you want
to place the graph. Click the left mouse button to place the graph.
To create a graph using Microsoft Graph:
1 Make sure nothing is selected in your report and press the Graph button.
2 Click in the header or footer to place the graph. The graph application opens.
3 Create a graph in Microsoft Graph. (Refer to your Microsoft Graph documentation.)
4 When youve finished, choose the Update command on the applications File menu.
This places the graph below the point where you clicked in your report. For OLE 2.0,
click outside the graph.
5 To return to ReportSmith choose File|Exit and File|Return to Report, or click outside
the window.
To reposition a graph within a header or footer:
1 Double-click the graph. The Graph tool opens. For OLE 2.0, the menus and toolbars
change to show Graph options.
2 Modify the graph.
3 Do one of the following:
Select the Update command on Graph tools File menu when youve finished
editing the graph and then choose the Exit command on the File menu to return to
ReportSmith.
Select the Exit and Return to Report command on the graph application File menu
to cancel or save your changes when prompted and return to ReportSmith.
Note
You cannot close your ReportSmith document until you exit Microsoft Graph.
To delete a graph:
1 Select a crosstab.
2 Press the Graph button on the toolbar or right-click and select Chart from the pop-up
menu.
3 Single-click in a header or footer to place the graph in your report.
128
Creating Reports
3 Drag the mouse to position the Graph cursor in the header or footer where you want
to place the graph and left-click the mouse. ReportSmith places the graph below the
point where you press.
4 Click to select the header or footer if the graph exceeds its boundaries. A box with
sizing handles surrounds the header or footer.
5 Drag a sizing handle until the entire graph falls within the boundaries, then release
the mouse button.
Placing a graph
Where you place the graph controls what data is included and how often it appears in
your report. If you drop the graph into a global region like a page header or report
footer, this creates the graph using all the data in the report and ReportSmith places it in
every page or in the report header or footer. If you drop it into a group header or footer,
the Graph tool creates a graph based on the data in just that group and ReportSmith
places it into that group header or footer. ReportSmith positions the graphs top left
corner where you click the mouse
Chapter 6, Graphs
129
130
Creating Reports
Chapter
Crosstabs
Chapter 7
With crosstabs, you can instantly summarize your data in a concise spreadsheet-like
layout. You can create a crosstab directly or generate one from an existing columnar
report. Each time you open your report, ReportSmith automatically updates the
crosstab if data changes.
You can instantly apply formatting styles, resize individual cells, drag and drop fields
and labels, automatically change the value hierarchy, drop fields directly into your
crosstab, use in-cell editing to change total and group headings, and more.
ReportSmith lets you create a crosstab with three methods:
Create a new crosstab and choosing Crosstab from the Create A New Report dialog
box
Create a crosstab based on an existing columnar report and specify rows, columns
and values in the Crosstab Report dialog box
Click to select columns in your columnar report and press the Crosstab button to
instantly transform them into a crosstab
Chapter 7, Crosstabs
131
Parts of a crosstab
Crosstab reports can consist of any number of rows, columns, and values.
Row labels
Column labels
Row
Value
Column
Total heading
Summary values
Types of crosstabs
You can create numerous types of crosstabs, combining multiple rows, multiple
columns, and multiple values. Some common variations are
Value-only
Single-row
Single-row/single-column
Single-column
Double-column
Double-row
Value-only
The Value-only crosstab consists of only two cells: the value field label and the grand
total value.
This report creates a summary total for one data field. The data set can be an entire
report if you place the crosstab in a global header or footer (that is, a page or report) or it
can be a section of the data if you place it in a group header or footer. You can make this
type of crosstab by only specifying one data field as a value in the crosstab.
132
Creating Reports
Single-column
The Single-column crosstab consists of a column and values.
It provides summary totals for each field within the column, as well as a grand total of
all value fields. The only difference between this type of report and the Single-row
crosstab is the print direction of the data.
Single-row
The Single-row crosstab consists of a row and values.
It provides summary totals of each unique value in a row, as well as a grand total of all
value fields. The only difference between this type of report and the Single-column
crosstab is the layout of the data.
Row
Row grand
totals
Report grand
total
Column grand totals
Chapter 7, Crosstabs
133
In the example above, CSTMR_NAME is the column and EMP_LNAME is the row. The
values within the crosstab are Blakes total sales for each customer, and Keats total sales
for each customer. There are also column grand totals and row grand totals and a report
grand total that combines the column and row grand totals.
For example, the row totals are the total values for each employee across all customers.
The column totals are the total values for each customer for all salespeople
(EMP_LNAME.) The report grand total adds all the row grand totals and all the column
grand totals.
Double-column
The Double-column crosstab provides an extra level of information within a column. It
consists of two columns and values.
The secondary column you select is a subset of the primary, or first, column you select.
Therefore, the value of each field within a secondary column is calculated based on the
value of each field within the primary column. These can be thought of as grouping
levels in a columnar report.
In this example, DATE is the primary column and EMP_LNAME is the secondary
column. The grand total adds the column totals to come up with total sales for both
salespeople.
134
Creating Reports
Double-row
The Double-row crosstab provides an extra level of information within a row. It consists
of two rows and values.
The second row you select is a subset of the primary, or first, row you select. This means
that the value of each field within a secondary row is calculated based on the value of
each field within the primary row.
In the example above, DATE is the primary row and EMP_LNAME is the secondary
row. The report grand total adds the row totals to come up with total sales for both
salesmen.
Description
Modify
Styles
Border
Select this option to view the Crosstab Report dialog box and to modify your crosstab.
Choose Styles to create, edit, and apply formatting styles to your crosstab.
Select Border to view the Borders dialog box, where you can customize crosstab
borders.
Choose this option to select everything in your crosstab, including all of the cells,
totals, and headings.
Choose this option to convert the crosstab to a chart using Microsoft Graph.
Choose Invert to swap rows and columns in your crosstab.
Select this option to delete your crosstab.
Choose this option to change general crosstab options.
Select All
Chart
Invert
Delete
Options
Chapter 7, Crosstabs
135
toolbox corresponds to actions you can also perform using the Crosstab menu. This
section describes the functions of each button on the Crosstab toolbox.
To display the Crosstab toolbox:
Modify
Crosstab styles
Borders
Select All
Graph
Invert
Delete
Note
When you press the Delete button, ReportSmith deletes your crosstab.
Creating a crosstab
There are three methods you can use to create a crosstab:
Choose Crosstab Report in the Create A New Report dialog box to create a crosstab
from scratch.
Specify rows, columns, and values in the Crosstab Report dialog box based on an
existing columnar report.
Click to select columns within a columnar report and press the Crosstab button on
the toolbar. This is called the visual method.
In this section, well show you how to create your crosstab using each of the three
methods.
136
Creating Reports
fields is significant; the first field you place in a list box becomes the primary value, the
second field becomes the secondary value, and so on.
Primary value
Secondary value
3 Drag and drop data fields into the Rows, Values and Columns list boxes.
Columns, rows
and values
4 If desired, specify row, value, or column options by choosing the associated Options
button beneath each and press OK.
Depending on the location of your mouse, the cursor becomes either a crosstab or a
No-drop cursor.
5 Move the cursor over the report header and click the mouse to place the crosstab.
Chapter 7, Crosstabs
137
6 Move the crosstab cursor over a header or footer and click the mouse to place the
crosstab.
7 To hide the columnar report, choose Format|Section. The Format Section dialog box
appears.
8 Select the Detail section, check the Hide Section box and press OK. ReportSmith
suppresses the columnar report.
1 Open a columnar report that has a header or footer and display the boundaries.
2 Choose Tools|Crosstab to view the Crosstab toolbox.
3 Click to select a column in your report youd like to appear as a crosstab row.
Ctrl+click to select two more columns for the column and values in your crosstab.
4 Press the Crosstab button on the toolbox.
5 Move the cursor into a header or footer and click to place your crosstab. The crosstab
appears on the report.
6 To hide the columnar report, use the Format Section dialog box. The columnar report
disappears and your report displays just the crosstab.
Placing a crosstab
If youve generated it directly, you can place the crosstab anywhere on the report page.
If youve generated the crosstab from a columnar report, when you move over one of
these drop zones, youll see the Crosstab cursor, indicating that you can click to place
the crosstab. If youre over a no-drop zone, such as the report detail, the No-drop cursor
appears, alerting you that you cannot place the crosstab in the current report section.
After you place a crosstab you can move it: double-click to select it, then drag to place it.
To place a crosstab:
1 Create a crosstab using either the dialog or visual methods previously described.
Depending on the location of your mouse, the No-drop cursor or the Crosstab cursor
appears.
2 Use the mouse to position the Crosstab cursor in the header or footer where you want
to place the crosstab and click the mouse.
138
Creating Reports
3 If the header or footer isnt big enough to hold the crosstab, the area resizes to fit it.
ReportSmith places the crosstab below the point where you press.
You can expand the header or footer to a full page or more to force a crosstab across
multiple pages vertically.
The type of header or footer within the columnar report that you place a crosstab
controls what values are used in the calculations and how often the crosstab appears in
your report. If you drop the crosstab into a global region such as a report or page header
or footer, it calculates values based on all data in the columnar report and it appears in
every report header or footer. If you place it in a group header or footer, it calculates
values based only on the data in each group and places it only into that group header or
footer.
To reposition a crosstab:
1 Double-click to select crosstab or position the cursor on an inside edge of the crosstab
until the selection finger cursor appears.
2 Drag the crosstab to a new location within a header or footer, then release the leftmouse button.
When you press and hold the mouse after selecting a crosstab, the movement cursor
appears. When you see this cursor, you can move the crosstab horizontally or
vertically. ReportSmith places the crosstab in the new location.
Expanding a boundary
If the crosstab doesnt fit within the header or footer of a columnar report, ReportSmith
suppresses the cells that fall outside the top or bottom boundaries. To expand the
boundary, click on it. Press and drag one of the sizing handles until the entire crosstab
fits within the boundaries. Also, you can stretch a header or footer across pages. This is
helpful if a crosstab is too large to fit on one page. If you stretch the header or footer to
the next page, the crosstab splits across the pages, in the vertical direction only.
1 Click in a field. A box surrounds the field and all other fields of the same type.
2 Ctrl+click to select additional fields types.
Chapter 7, Crosstabs
139
Modifying a crosstab
You can make changes to your report at any time. ReportSmith offers you many ways to
modify your crosstabs. You can use the Crosstab dialog box, drag and drop rows and
columns into place, directly edit crosstab cell values, and use the formatting ribbon and
toolbar.
To display the Crosstab toolbox, choose Tools|Crosstab.
You can modify your crosstab at any time. After you apply them, ReportSmith
regenerates the crosstab with your new changes. To modify a crosstab with the Crosstab
Report dialog box:
140
Creating Reports
2 Holding the mouse, drag and drop the selected item to another location.
Chapter 7, Crosstabs
141
Rows
To specify row options, press the Row Options button. The Crosstab Row Options
dialog box appears.
Options
Description
Name
Type
Label
Subtotal Heading
Calculation
Sort Order
Custom Values
142
Creating Reports
Values
Specify value options in the Crosstab Value Options dialog box. To view the dialog box,
highlight the value you want to customize and press the Value Options button.
Option
Description
Name
Type
Label
The name of the value field for which youre setting options.
The field data type, such as numeric, character or string.
Enter an alternate label into this box for your value label. This is optional. If you
leave this field blank, ReportSmith uses the field name from within the table as
the default label.
Enter a label for the summary heading. This is optional.
Press the down arrow to view a drop-down list of calculations which you can
perform on this field.
Summary Heading
Calculation
Description
Value
Percent of Row
Percent of Column
Percent of Total
Chapter 7, Crosstabs
143
Columns
To specify column options, press the Column Options button. The Crosstab Column
Options dialog box appears.
Option
Description
Name
Type
Label
Subtotal Heading
Calculation
Sort Order
Date Options
144
Creating Reports
Option
Description
Totals
Labels
Fix Cell Size
Format Pct
Inside Columns
Outside Columns
Inside Rows
Outside Rows
Alternate Total Heading
Chapter 7, Crosstabs
145
more columns or rows with these sizing handles also. The crosstab sizing handles are
described below.
Resize columns
Resize rows
Uniform column sizing
Individual rows
Use the row sizing handles on the left side of the crosstab to resize an individual row.
For example, to enlarge the size of two rows containing Rimbaud, shown above, grab
the row-sizing handle just above the cell and pull upward. Do the same for the second
row.
146
Creating Reports
Individual columns
Use the column-sizing handles at the top of the crosstab to resize an individual column.
For example, to remove the column Quarter 4, pull the sizing handle above the
column left until Quarter 4 disappears from view.
Below, the column containing Quarter 4 no longer appears. However, it still exists in
your crosstab. To make it reappear, select Edit|Undo, or pull the sizing handle right to
increase the column size.
Chapter 7, Crosstabs
147
Manipulating data
ReportSmith offers you numerous ways to expand your crosstabs. This section
describes
Grouping
Sorting
Inverting rows and columns
Calculations (including macro-derived fields)
Aliases
Grouping
ReportSmith groups all values by same value except for dates. Dates are automatically
grouped by quarter. You can use the options dialog box to customize grouping for
dates. For example, you can specify a date range, choose to display dates by month,
days or minutes, or you can define the first month of your fiscal year. When grouping
dates, ReportSmith offers you numerous options.
To specify dates in a crosstab:
In the Crosstab Report dialog box, select the DATE field you want to modify and
press the Options button that corresponds to it. An options box appears with settings
for the DATE field.
Option
Description
Name
The name of the field for which youre setting options. DATE should appear
here.
The field type, DATE, Date/Time, should appear here.
Enter an alternate label into this box for your DATE label. This is optional. If
you leave this field blank, ReportSmith uses the field name from within the
table as the default column label.
Enter a label youd like to appear as the subtotal heading.
Press the down arrow to view a drop-down list of subtotal calculations which
you can perform on the DATE field.
Type
Label
Subtotal Heading
Calculation
148
Creating Reports
Option
Description
Sort Order
Custom Values
Date Options
Group By
Group formats translate into field labels in your crosstab. You have the following
choices:
Group
Group Formats
Daily
Monthly
Weekly
Annually
Quarterly
Hourly
Minute
Second
Sunday or Sun
January or Jan
Week #
Year #
Quarter 1, Qtr 1, First Quarter, First Qtr, 1st Quarter, 1st Qtr
Hour #
Minute #
Second #
Format
If you select Daily, Monthly, or Quarterly in the Group By option, you can select a label
format and other options. Press the down arrow in the Format box to display a list of
choices. After you choose an option in the Group By box, the grouping options appear
in the dialog box.
The default format for dates is Quarterly with a Qtr 1 format.
Chapter 7, Crosstabs
149
Sorting
You can reorganize the order of the values within a selected row or column in a
crosstab. You can do this with the Sort options in the Crosstab Row Options or Crosstab
Column Options dialog boxes.
You can also use the Custom Sort option to exclude values you dont want to include in
your crosstab.
To sort fields in a crosstab:
2 Press an option in the Sort Order box. The table below defines your sort choices:
Ascending
Descending
None
Custom
If you select the Custom option, type a sort list for the fields in the selected row or
column in the Custom Values box. Each value should be separated by a comma. For
instance, if you want to reorder the CITY fields in the example, you could type San
Mateo, Los Altos, Woodside in the Custom Values box.
If you want to exclude a field in your crosstab, dont include it in your sort. For example,
if you dont want to include Woodside in the example crosstab, you would type Los
Altos, San Mateo in the Custom Values box.
150
Creating Reports
1 Press OK. Press OK again to exit the Crosstab Report dialog box. ReportSmith
generates the crosstab with the sorted fields.
To undo the Invert command, choose Edit|Undo Command, or select the Invert
command once again.
Calculating fields
ReportSmith enables you to calculate values in a crosstab based on other crosstab values
using ReportSmiths macro language. You can create SQL-derived fields in the Derived
Fields dialog box, and they appear in the crosstab just like regular data fields. However,
to include a macro-derived field in your crosstab, you must define it within the Crosstab
Report dialog box, using the Calculated Column option.
You can only calculate values in a crosstab, not rows or columns.
To create a calculated field:
1 Select the crosstab, right-click the mouse and choose Modify, or select the entire
report and press the Modify button on the Crosstab toolbox.
Chapter 7, Crosstabs
151
The Crosstab Report dialog box appears displaying the rows, values and columns
you have selected to include in it.
2 Under Type, select Calculated Fields. A symbol appears in the Name box, <New>.
3 Drag the <New> symbol from the Name box and drop it into the Values list box.
The Calculated Field dialog box appears, where you will tell ReportSmith what
calculation to perform on the field. The current value fields appear in the left-most list
box.
4 In the Name text box, enter a name for your calculated field. In the example, weve
named our calculated field NewSalary.
5 You can create the calculated field formula by typing it directly into the formula box,
or you can drag and drop items from the list boxes into the formula.
In the example below, weve created a formula which uses the SALARY field and
calculates a 10% raise for each employee.
6 After youve created the formula for your calculated field, press the Test button.
ReportSmith tests your formula and, if you entered it correctly, returns a success
message. If you entered it incorrectly, an error message appears. You need to correct
the formula before continuing.
7 Press OK to exit the Test message box. Press OK to exit the Calculated Field dialog
box. Your calculated field appears in the Values box. We named our sample
calculated field NewSalary. It appears in the Values list box beneath SALARY.
8 Press OK.
152
Creating Reports
1 Open a crosstab. Click on the field you want to edit, then click on it once again to
activate Text mode.
2 Type the alias over the field.
ReportSmith replaces each occurrence of that field in your report with its alias. Your
database remains unaffected; only the report changes. Now every time ReportSmith
finds E1-23 in this crosstab, it uses J. Smith instead.
Note
You can also create a single alias that includes multiple employees. Employees assigned
the same alias collapse into the same group.
To create aliases using the Options dialog box:
1 Open a crosstab. Select it and choose Modify from the pop-up menu, or double-click
to select the entire crosstab and press the Modify button on the Crosstab toolbox.
The Crosstab Report dialog box appears.
Chapter 7, Crosstabs
153
2 Select the field in the Rows, Columns or Values list boxes that you want to create
aliases for and press the Options button beneath it.
In our example well create an alias for the Account Number field. Well highlight the
field and press the rows Options button The Crosstab Row Options dialog box
appears with the selected field in the Name box.
3 Press the Alias button. The Data Value Aliases dialog box appears. If you have
created any aliases, they appear beside the data value which they represent.
4 Select a data value in the left list box. Click in the text box under the Alias list and
type an alias for it. Press the Assign button. ReportSmith places the alias in the Alias
list box beside its respective value. Repeat these steps for each alias you want to
create.
In this example, we created aliases for each Account Number field:
5 When youve finished creating aliases, press OK. ReportSmith replaces each data
value you assigned aliases to with its alias.
To correct a mistake in an alias:
Formatting techniques
You can format selected fields in a crosstab. You can change the font and point size, add
borders, patterns, and shadows, align characters, and so on. ReportSmith lets you save
your formatting changes in styles, or you can apply system styles that come with
ReportSmith.
This section describes how to use crosstab styles and how to resize items in a crosstab.
154
Creating Reports
Applying a style
You can apply a style using the ribbon or the Crosstab Styles dialog box.
To apply a style with the Crosstab Styles dialog box:
1 Select a crosstab, right-click the mouse, and choose Styles from the menu. The
Crosstab Styles dialog box appears.
2 Select a style in the System Styles list box or in the Custom Styles list box.
Chapter 7, Crosstabs
155
3 Press Apply.
To apply a style with the ribbon:
4 Press Done.
Creating a style
You can create a style based on a formatted crosstab. Styles that you create appear in the
Custom Styles list box. When you select a style, ReportSmith displays it in the Sample
box, so you can preview it. If youve already formatted a crosstab, most of the work to
create a style is behind you. Now all you need to do is assign a name to the style. A style
is created and is available for use with other crosstabs.
Create custom styles using, for example, your company colors. When you delete a
custom style it affects crosstabs which have been assigned that style. ReportSmith alerts
you with a message reminding you that removing the style affects any crosstabs with
that style.
3 Press the Style button, or right-click to display the pop-up Crosstab menu and choose
Styles. The Crosstab Styles dialog box appears.
4 Press the New button. Enter a name for your style into the Name text box. Style
names can contain up to 255 characters and can include any combination of
characters and spaces. They are case sensitive and must be unique.
5 Press OK and press Apply to exit the Crosstab Styles dialog box. Now, each time you
open the Crosstab Styles dialog box your new style appears in the Custom Styles list.
After you have defined a style, it appears in the Report Styles dialog box and you can
apply it to any number of crosstabs. Applying a style to a crosstab gives it the same
formatting as the crosstab you used as the model for that style.
Extracting a style
Suppose youve formatted a column, row, or value within your crosstab and youd like
to apply that style to other areas within your report. You can do this with the Style
156
Creating Reports
Extractor button on the toolbar. The Style Extractor extracts styles you select and applies
them to columns, rows or values that you click on.
To apply formatting using the Style Extractor:
ReportSmith applies the formatting changes from the Grand Total field to each Total
row value:
When you no longer need a style, you can delete it. When this happens, you replace any
crosstab formatted with this style to the basic, non-formatted style. You cannot delete a
system style.
To delete a custom style:
Chapter 7, Crosstabs
157
158
Creating Reports
Chapter
Macros
Chapter 8
Macros let you enhance your productivity and add complex features to your reports. A
macro is a list of actions you want ReportSmith to carry out for you. You can create a
macro or use one of the macros ReportSmith provides for you to do any of the following
tasks (and many more):
Automatically load and print reports
Customize ReportSmith by creating a custom dialog box, hiding or disabling menu
items, and creating new menu items and DDE topics
Create derived fields
Create customized prompts such as prompting a user for a password
Schedule report timing
Perform complex calculations
This chapter defines macros and shows you how to create and use them to simplify
many ReportSmith tasks. Finally, it describes some advanced macro concepts.
See Appendix B, Macro reference, for more information about macros.
Introduction to macros
In this introductory section, youll learn what macros are and how to use them. Youll
also learn the difference between global and local macros, and how they are used. This
section also provides basic information about using macros with other Windows
applications and about the ReportBasic programming language.
What is ReportBasic?
ReportSmith has licensed the Softbridge Basic Language (SBL) from Mystic River
Software, Inc. in order to provide ReportSmith users with a complete, high-level
Chapter 8, Macros
159
programming language. ReportSmith has also added commands to SBL that were
designed with reporting in mind. This combined command set is called ReportBasic, a
complete programming language designed specifically for report creation.
Because it is a complete programming language, ReportBasic can be used for a variety of
tasks. The following table provides a list of its more common uses.
Use
Description
With ReportBasic, you can create derived fields that are not stored in the database,
but are a result of a calculation using the values stored in your database fields.
ReportBasic lets you highlight a value if it meets a certain criteria in a report. For
example, you might want to display all sales transactions in a report that are greater
than a stated quota to print in a bolder, larger font than those that fall below the
quota. ReportBasic can also be used to warn a report reader that invalid data exists in
a database. Suppose a mailing list database contains a number of null values in the
state field. ReportBasic can print the value NO STATE CODE in place of the null
state code value.
You can use ReportBasic to create custom user interfaces such as dialog boxes that
contain user-entry fields, command buttons, and check boxes. A report user can
build a complex SQL query with a few mouse clicks, with the help of the report
designer who is familiar with ReportBasic. ReportBasic can also be used to add,
remove, or disable ReportSmith menus, menu items and toolbar icons. A report
designer may want to do this to prevent a user from modifying a report or to add
specific menu items that run specific macros. You can create your own DDE topics
and items. Macros can be assigned to run in response to a change in one of the items
or a request for data from another application.
ReportBasic can be used to load a number of reports, send them to a printer and
close those reports when they have printed. A user can link such a macro to a
specific event. A user could cause such a macro to execute in response to a user
keystroke, or other ReportSmith event. Or, a macro might be programmed to run
reports at midnight, when network traffic is low.
Advanced users can create ReportBasic functions that can be called by other
ReportBasic scripts or a ReportSmith event. Users can also call *.DLL functions,
created in other development environments, that can be used within ReportBasic.
ReportSmith, along with ReportBasic, can serve as either a DDE server or client. A
developer may want to build a number of reports with ReportSmith and build DDE
commands within the application that calls ReportSmith or ReportSmith Runtime to
print those reports when the user clicks a button or selects a menu option. This can
easily be done from within applications developed with Delphi. You can perform
DDE executes, pokes and requests and create your own DDE topics and items.
Scoping macros
You can create two kinds of macros: a global macro or a report macro. A global macro
belongs to the ReportSmith application and appears in the active list each time you run
ReportSmith. A report macro belongs to a given report and becomes a part of that report.
160
Creating Reports
When you save the report, ReportSmith saves any associated report macros in the .RPT
file.
Global macros
You can create global macros to customize ReportSmith or to automate global tasks. For
example, suppose you want to combine loading, printing, and closing a report into one
step. This same macro can also display a dialog box that prompts the user for the report
names. When you run the macro, it opens, prints, and closes each report the user
specifies in the dialog box.
You can create a global macro that only lets certain people access a given report by
prompting for a password, or one that hides the toolbar or executes a specific menu
command, such as File|Open.
Report macros
A report macro lets you automate tasks that are specific to a certain report. For example,
create a report macro that only lets a certain user access a confidential report by
prompting for a password, or by verifying the value of a DOS variable. For example,
you might have this line in your AUTOEXEC.BAT:
SET USER=John Doe
In this case, the macro opens the report only if the environment variable is set to John
Doe.
' This code will abort the open event if the user is not John Doe
' Get the user name
USER$=ENVIRON$("USER")
IF USER$ <> "John Doe" THEN
' Abort the report's loading
RESUMEEVENT 0
END IF
You can create a report macro that behaves dynamically according to changes in the
information it receives. For example, suppose you have a report that is unusually large,
and you dont want users opening it when network traffic is high (between 4:00 and 5:00
every week day). You can prevent a user from opening the report during peak time, and
display a message explaining why. In this case, the macro behaves differently according
to the time of day.
You can create a report macro that steps through the fields in a report column and
produces a summary field. For example, suppose your Sales Department has a
commission structure with different multipliers for different quotas. You could write a
macro that calculates a sales persons commission based on the commission structure,
and place that value into your report.
Chapter 8, Macros
161
to the Display event and use the FieldText command to change the text of each record.
You can then do a DDE request to your Excel table to locate the corresponding part
name for each part number.
You can also add C functions from a Windows Dynamic Link Library (DLL) into a
report macro. If you have a Windows DLL containing functions that perform
complicated financial computations, you can create a report macro that uses those
functions to calculate the data in your report.
2 In the Macro Name text box, enter a name for your macro into the Macro Name text
box. For our sample, we entered TEST. This enables the New button.
Note
Your macro name cannot be the same as a Basic reserved word, or errors result.
162
Creating Reports
Note
ReportSmith commands and the Basic commands are listed and described in The
Macro Command Reference in online Help.
You create the macro by inserting the commands you want in the Macro Formula text
box. Since youre creating a macro that displays a message box, youll use the
MsgBox command.
2 In the Basic Functions list box, scroll through the list to display the MsgBox function,
and then drag it to the beginning of the blank line in the formula (between Sub
TEST()and End Sub), then release the mouse button to insert the function into the
routine. (You can also type the command directly in the formula.)
3 In this exercise, you can also use the MsgBox command as a statement, so you must
edit the command by removing the parentheses. Delete the parentheses and commas
after MsgBox.
4 Enter the following into the Macro Code text box: 'This is a sample message.'
5 Choose Test. If you entered the routine correctly, ReportSmith displays a success
message. If your formula is incorrect, ReportSmith informs you of errors and lets you
fix the routine.
6 When you receive a success message, press OK to return to the Macro Commands
dialog box. Now you can run the macro and see the effect.
7 In the Macro Commands dialog box, choose Run. The message you created appears.
8 Press OK in the message box. Press OK again to close the Macro Commands dialog
box. Your macro is complete.
1 Open the Macro Commands dialog box and select your macro. For our example,
select TEST.
2 Press the Links button. The Macro Links dialog box appears.
If you press the down arrow in the Object Type list box, youll notice that it displays
the Application object only. This is because a global macro (which is the type you just
created) can only be linked to an application object.
3 Open the Events list box. This displays all of the events to which you can link your
macro. Lets link it to the KeyStroke event.
4 Select KeyStroke.
The KeyStroke event has several options for keys. You can choose to use any key on
your keyboard. When an event has several options, ReportSmith displays them in the
scroll box on the right.
Now link the test macro to a specific key.
Chapter 8, Macros
163
5 Scroll through the scroll box until you see [Ctrl+A] and select it. Press the Link button.
ReportSmith links the TEST macro to the [Ctrl+A] keystroke sequence. Notice that the
Link Number field (which originally displayed No Links) now displays 1 of 1.
This indicates you have linked the macro to one event.
If you like, you can link the same macro to more keystrokes or you can link it to
another event.
6 Select Application Startup from the Event list box, and choose Link. The Link
Number field displays 2 of 2, indicating that you have linked two events to your
macro.
Also notice that the scroll box on the right displays No Items. Unlike the KeyStroke
event, the Application Startup event doesnt have items tied to it.
7 To scroll through the links of a given macro, press the Previous Link and Next Link
buttons.
8 Press OK to return to the Macro Commands dialog box.
1 In the Macro Commands dialog box, choose a macro from the list of active macros.
For our example, select the TEST macro that you created in the previous exercise.
2 Press the Save As button. The Save Macro dialog box appears. Use the Drives list box
and the Directories scroll box to specify the path where you want to store the macro.
3 In the File Name field, enter a name for your macro file.
A macro file name can be up to eight characters and it doesnt have to be the same
name as the macro itself. Characters, numbers, and underscores are allowed but the
first character must be a number or letter.
164
Creating Reports
4 Press OK to save the macro under the path and file name you specified and to return
to the Macro Commands dialog box.
5 Press OK to close the Macro Commands dialog box.
Loading a macro
After you save a macro to a .MAC file you might want to edit its routine or bring it into
another report. You can do this by loading the file into the macro facility.
To load a macro:
2 Press the Load button. The Load Macro dialog box appears.
3 From the scroll box on the left, double-click the macro file you want. The macro you
select becomes the active macro in the Macro Commands dialog box.
4 Choose Edit to display the Edit Macro dialog box. Make a valid change in the Macro
Formula text box. Use the Test button to test for errors.
5 Press OK and press Save to update your macro file. Press OK to exit the dialog box.
Chapter 8, Macros
165
The following piece of code is an example. An apostrophe before a line (') indicates a
comment.
Sub ConfirmExit()
' This is the code to tell MsgBox the message and buttons you want.
x = MsgBox ("Do you really want to Exit ReportSmith",4)
' When used as a function MsgBox returns 7 if the user presses
' the NO button.
If x = 7 then
' This command will tell ReportSmith not to close if this macro is linked to the close
event.
ResumeEvent(0)
End if
End Sub
Using arguments
ReportSmith macros can accept arguments. An argument lets you pass information from
one macro to another and back again. When you insert an argument into a macro, it can
call another macro.
To insert an argument into a macro:
1 Select Tools|Macro. Place the macro in the Macro Name text box.
2 Choose Edit to display the Edit Macro dialog box. The code for the macro you
selected appears in the Macro Formula text box.
3 Enter the arguments you want to insert within the parentheses ( ) that follow the
macro name. Make sure you separate the argument variables with commas.
Now you must tell ReportSmith the default values these variables should take when
you run the macro.
4 Choose Set Default Arguments to display the Edit Macro Arguments dialog box.
5 In the Default Arguments text box, enter the default values (separated by commas)
for the argument variables in the same order as the variables appear in the macro
code. Press OK.
166
Creating Reports
6 Press OK in the Edit Macro Arguments dialog box, again on the Edit Macro dialog
box, and again on the Macro Commands dialog box.
Note
You can also use the RunMacro command to provide a string to specify the values for
the argument variables. If you specify a null string, ReportSmith uses the default
arguments.
The following two macros show you how to pass arguments. In this case, you only
have to place the argument in the called macro. If you are going to pass it back again,
you need to place it in the calling macro as well.
Sub calling()
' This variable allows you to pass along the double quotes and the value of the
variable.
q$=chr$(34)
var1$=q$+ "It is Monday"+q$
RunMacro "called",var1$
End Sub
Sub called(var1$)
msgbox "Hey!"+var1$
End sub
Note
For this macro make sure that you press the Set Default Arguments button in the Edit
Macro dialog box. For string arguments, you must place it in double quotes. This
gives it a value when it is first being compiled.
1 Select your macro. In the Macro Links dialog box, choose Links.
2 Use the Previous Link and Next Link buttons to display the event for which you
want to specify argument variables.
3 Press the Set Arguments button to display the Edit Macro Arguments dialog box.
4 In the Default Arguments text box, enter the values (separated by commas) for the
argument variables in the same order as the variables appears in the macro code.
Press OK to return to the Macro Links dialog box. When you run the macro using the
event you highlighted in Step 4, ReportSmith will replace the default argument
values with the values you specified here.
5 To exit the macro facility, press OK in the Macro Links dialog box. Press OK in the
Macro Commands dialog box.
Chapter 8, Macros
167
The RunMacro command takes two strings. The first string is the name of the macro you
want to run. The second string is the list of arguments whose values you want to replace
in that macro. If your argument list contains strings, youll need to use chr$(34) to place
the double quotes character within that second string.
Variables can be passed only to a macro BY VALUE when using the RunMacro
command, so the called macro cannot modify the variable value. You must use the
variable to generate the string. For example, to call a macro named TestMacro that takes
a number and a string as arguments, with the number contained in a variable
(NUMVAR%), and the string contained in a variable (STRVAR$), you can call the macro
with the following code:
q$=chr$(34)
Arglist$=str$(NUMVAR%)+","+q$+STRVAL$+q$
Status=RunMacro("TestMacro",arglist$)
Note that we used the STR$ command to convert the numeric value to a string. Also
note that we embedded quotes around the string variable that we passed. When
executing this code through DDE, you must add carriage return and line feed characters
between each line of code, or alternatively you can use two vertical bar characters (||) .
168
Creating Reports
To use DDE to execute an active global macro called TEST_ARGS and pass two string
arguments, ReportSmith expects the following string to be sent to its COMMAND topic:
q$=chr$(34)||RunMacro "Test_ARGS",
q$+"Test String One"+q$+","+
q$+"Test String Two"+q$
A ! indicates a comment.
Pushbutton: pb1
Message Actions
On SAM_Create
Set dfService ='ReportSmith'
Set dfTopic ='COMMAND'
Set dfItem =' '
Set dfStatus ='Not Started'
Set dfSendit = 'DIM DS as Dataset'|| '||' || 'DS.CONNECT
Chapter 8, Macros
169
170
Creating Reports
ResumeEvent 0 cancels creation of the C17 footer object, but only when linked to
the Group Footer object Creation event.
5 Test your macro and after you receive a success message, press OK to return to the
Macro Commands dialog box. Press Save and give the macro a name.
6 To link the macro to your report, choose the CUST_ID field from the Data Fields list,
the Creation event from the Events list and the Group Footer from the Object Type
list. Choose Links button, then press OK to return to the Macro Command dialog
box. Press Save to give the macro a name.
7 Press Run to execute the macro in your report. ReportSmith runs the macro and
suppresses the Group footer for the C17 field.
Modular scope
If you want all subroutines in a macro to be able to use your control, place the Dim
statement outside of all subroutines. A macro declared in this way has modular scope
and is destroyed when the macro ends.
Chapter 8, Macros
171
Local scope
If you just want to use the control in a single function, place the Dim statement inside
that function. This gives the control local scope. It is created when the function is
called and destroyed when the function is complete.
This code fragment shows a function which uses a DataSet control to close the active
report and to remove its connection:
Sub CloseActiveReport()
' Make a local DataSet object for the report to be removed.
DIM DoomedData as DataSet
' Associate this DataSet with the Active report
Trouble=DoomedData.SetFromActive()
If Trouble Then
' Let the user know if there is a problem like no active report.
Msgbox DoomedData.Error$
Else
' Otherwise close the report.
CloseReport 1
' And Remove the Connection.
Trouble = DoomedData.DisConnect()
End If
End Sub
Global Scope
You can use the Global statement to create a DataSet control that is known to all macros
in ReportSmith. The Global statement must appear in all modules which refer to the
global DataSet. Before the object is used, the global statement should appear on the first
line of your macro before any subroutines or functions. These two macros, SetName and
GetName, both use a common DataSet control.
Note
Even though the control has the same name in both macro commands, they both must
include the global statement in order to refer to the same Global control.
' Declare a Global Dataset
Global GDS as DataSet
Sub SetName()
GDS.Name$="Global Control"
End Sub
Or,
' Declare a Global Dataset
Global GDS as DataSet
Sub GetName()
MsgBox GDS.Name$
End Sub
172
Creating Reports
have any of the Basic variable types. You can access the properties of a control by using
the name of the control, followed by a period and the name of the property.
One property of the DataSet control is Selection$. It is a string variable that defines the
SQL text following the WHERE clause in an SQL statement. You can use this property to
set the selection criteria for a DataSet as in the example below.
' Display the Old Selection Criteria.
Msgbox MyData.Selection$
' Set the New Selection Criteria.
MyData.Selection$ = "SALARY > 40000"
You can access these variables in the same way as you access object methods by using
the object name followed by a . and the property name. You use this just like any other
variable. Some properties are read-only while others can be both read and written.
The following table lists some examples of how properties are used.
Use command
msgbox MyData.name$
Use it in an expression
total_recs=data1.recordcount+data2.recordcount
Assign values to
Methods
Methods are functions or statements that perform actions on the control. The
SetFromActive method associates the DataSet control with the currently active report.
The Save method can be used to store a DataSet control in a DOS file.
Sample macros
ReportSmith provides sample macros in the Video subdirectory. The sample macros
show how you can use the macro language to perform sophisticated menu tasks, like
conditional formatting, creating derived fields, menu customizing, printing and loading
a series of reports.
You can create macros to produce more detailed tasks, such as calculating a percent of
total. Or, you can use macros as wizards to perform commonly requested functions,
like filling list boxes with .RPT files in a given directory, allowing users to run and print
them from the dialog box.
This section documents the actual code for several of the available sample macros. These
samples show you how to:
Chapter 8, Macros
173
Each sample includes comments to help familiarize you with the macro process. For
detailed information on the other sample macros, see the README.TXT file.
Note
The first two sample macros are report macros that use the EX_MAC01.RPT sample
report. It displays a list of film titles, the film type, and the price of each film. Before you
review the sample macros, open EX_MAC01.RPT so you can see the effect the sample
macros have on that report.
FieldFont "",0,-1,Color,-1
End Sub
174
Creating Reports
specified by the user. Using the scenario from the previous example, suppose you
created a report variable that prompts the user to choose a film type to display in a
report. ReportSmith uses the report variable in the selection criteria to determine the
correct records to display in the report. For example, if the user specifies the foreign
film type, the report displays foreign film types.
In addition, suppose the user wants to display all classic films. To do that, the user
changes the value of the report variable from foreign to classic. In this case,
automating the process of changing the film type is desirable.
You can automate this by creating the following macro and linking it to the Before Report
Load event. This way, you can prompt the user to set all the report variables before
ReportSmith runs the report.
' Asks you what type of movies to include in the report each time you load the report.
Sub Choose_Type()
' Define the dialog box that this macro uses to determine what film types to include in
the report.
Begin Dialog ChooseTypes 120, 130
Caption "Choose Film Types"
CheckBox 15,8,99,12,"Action", .Action
CheckBox 15,20,99,12, "Cartoons", .Cartoons
CheckBox 15,32,99,12,"Clasics", .Classics
CheckBox 15,44,99,12,"Drama", .Drama
CheckBox 15,56,99,12,"Foreign", .Foreign
CheckBox 15,68,99,12,"Musical",.Musical
CheckBox 15,80,99,12,"Science Fiction",.SciFi
OkButton 30,100,60,18
End Dialog
' Create an instance of the ChooseTypes dialog box and call it MovieTypes.
Dim MovieTypes as ChooseTypes
' Execute the MovieTypes dialog box.
DIALOG MovieTypes
' Set the Report Variables for each film type according to
' the state of the checkboxes when the dialog is done.
If MovieTypes.Action Then SetRepVar "Type1"," 'Action' "
else SetRepVar "Type1"," 'Not Included' "
If MovieTypes.Cartoons Then SetRepVar "Type2"," 'Cartoons' "
else SetRepVar "Type2"," 'Not Included' "
If MovieTypes.Clasics Then SetRepVar "Type3"," 'Classics' "
else SetRepVar "Type3"," 'Not Included' "
If MovieTypes.Drama Then SetRepVar "Type4"," 'Drama' "
else SetRepVar "Type4"," 'Not Included' "
If MovieTypes.Foreign Then SetRepVar "Type5"," 'Foreign' "
else SetRepVar "Type5"," 'Not Included' "
If MovieTypes.Musical Then SetRepVar "Type6"," 'Musical' "
else SetRepVar "Type 6"," 'Not Included' "
If MovieTypes.SciFi Then SetRepVar "Type7"," 'Science Fiction' "
else SetRepVar "Type7"," 'Not Included' "
End Sub
Chapter 8, Macros
175
176
Creating Reports
Sub Greeting()
' Use the Environ function to get the user name and store it in a string variable.
UserName$ = Environ$("USER")
' If the USER environment variable is not defined a null string will be returned.
If UserName$ = "" then
MsgBox " Welcome to the Sample Macro Report ",0," Macro Greeting "
else
MsgBox "Hello" + UserName$ + ", Welcome to the Sample Macro Report ",0,"Personal Macro
Greeting "
End If
1 Enter the name for the percent of total derived field youre creating in the Derived
Field Name box in the Derived Fields dialog box. Turn on the Defined by a Macro
option.
2 Choose Add.
3 Enter a name for the macro in the Macro Name text box and an optional description
of it in the Description box.
4 Choose Edit. The Edit Macro dialog box appears.
5 Enter the macro code in the Macro Formula window:
Sub PerOfTot()
' Calculate the percentage of the total quantity of this
' employee's sales that the current record's quantity of sales represents.
' The Field$ function gets the QUANTITY record as a string.
' The Val( ) function converts it to a number which is stored in the variable
"Quantity".
Quantity = Val(SumField$("SUBTOTAL","c:\rptsmith\samples\invoices.dbf",2,"Sum"))
' The Next line gets the total quantity for the current employee group and assigns it
to a variable. The number 1
Chapter 8, Macros
177
' refers to group level 1 which in this case is the employee group.
' 0 would indicate the sum for all groups.
TotalQuantity = Val(SumField$("SUBTOTAL","c:\rptsmith\samples\invoices.dbf",1,"Sum"))
' Because the above functions may fail, test for a zero value before doing division.
' A divide by zero error will halt macro execution.
If TotalQuantity > 0 then
PercentOfTotal = Quantity/TotalQuantity
' The Derived Field statement sets the derived field value and is only valid in
' macros used to define Derived Fields.
' It takes a string value, so the Str$ Function is used to convert the Number to a
string.
DerivedField Str$(PercentOfTotal)
End If
End Sub
6 Choose OK. The Create a Macro dialog box appears. Choose OK to exit the dialog
box, then press the OK button again to exit the Derived Fields dialog box.
7 Choose Insert|Field to drop the derived field as a column of data in the report.
Our example report shows percent of total sales for William Blake for each of his
customers. We want to show that percentage in the customer group footer next to the
sum of sales for each customer.
8 Select and delete the column for the percent of total derived field and then insert it
into the customer group footer.
9 Use the Percent button on the ribbon to format the derived field.
The following are examples of macro derived fields that sum the values of another
macro derived field. In the examples, substitute the field name of the macro derived
field to be summarized in place of MDF. Also, substitute the name of the field that the
data is grouped on, in place of GROUP, if you are working with grouped data. If the
report is grouped on more than one field and you want a summary for each group,
create a macro derived field for each group.
178
Creating Reports
Chapter 8, Macros
179
180
Creating Reports
Chapter
Printing a report
Chapter 9
This chapter explains how to print an entire report, a range of report pages, and the
report page displayed in your report window at the time of printing. The printer you
use influences how ReportSmith shows and prints your report.
With ReportSmith, you can decide what data, headers, or footers to display and print in
a report. This is useful when you want to create summary reports. You can also
determine where page breaks occur in a report.
In this chapter, youll learn how to set up the printer and print a report.
181
1 Choose the printer youll use from the Installed Printers list box.
2 Press OK. The dialog box for the printer you choose appears. Available options
depend on the printer youve selected, but typically you set paper source and paper
size.
3 Select a paper source option. The following options typically appear for most
printers:
Default Tray
Tells the printer to use the default printer tray when printing the
first page of the report.
Upper Tray
Tells the printer to use the upper tray when printing the first page
of the report.
Lower Tray
Tells the printer to use the lower tray when printing the first page of
the report.
Manual Feed
Tells the printer that you want to manually feed each page when
printing the report.
Envelope Feed
4 Choose the paper size you want to use from the drop-down list.
Note
Depending on the printer you use, you may have to set other options.
Printing a report
You can print
The current page appearing in a report window
A range of pages from a report
An entire report
Use the Presentation command on the View menu to see how your report looks before
you print it. Before printing, always remember to save your report.
To print the current page :
182
Creating Reports
183
184
Creating Reports
Chapter
10
Customizing ReportSmith
Chapter 10
You can customize the ReportSmith environment to suit your needs using the Options
dialog box. Specify whether to load data locally to the client memory or disk, keep it on
the server, or let ReportSmith determine the best method for your report. Additionally,
you can specify units options, tell ReportSmith where to find datasource connections,
and more. This chapter shows you how to set ReportSmiths options, customize
ReportSmiths menu and toolbar, and run a report from an icon.
185
Setting options
To customize ReportSmith options:
Program Start-up
Units
List Fields Alphabetically Check this option to see all items in dialog boxes listed in
alphabetical order.
Font Types Listed
186
Creating Reports
Connection File
Description
Client Memory
Click this option if you always want the data loaded into client (meaning your local
machines) memory.
Click this option if you always want the data loaded onto disk. Specify the data path
for the disk in the RPTSMITH.INI file
Click this option and ReportSmith leaves all the records on the server except the
number of records specified in the Buffer option
Click this option to have ReportSmith evaluate where to place the data. Automatic is
the default option. Youll see the following settings when you click this option:
Minimize Report Data Memory Usage Evaluates available disk space and keeps the
data on the server if there isnt enough room on the disk.
Limit Report Data Usage to Percentage of Memory Limits memory usage to 50% by
default. ReportSmith estimates the memory requirements for data storage. If the data
requires more than 50% of the available memory, ReportSmith looks at the available
disk space. If the disk space is insufficient, the data stays on the server. You can
increase or decrease this setting by entering the percentage you want to use.
Limit Report Data Memory Usage to Kilobytes ReportSmith estimates memory
requirements for data storage using the number of kilobytes (KB) you enter for this
option instead of a percentage limit. Enter the number of KB in the text box for this
option.
Buffer Records Controls the size of the buffer when ReportSmith accesses data left
on a server.
Client Disk
On server
Automatic
Description
Open Report
Click this option and ReportSmith automatically displays the Open Report dialog
box when the application opens.
Click this option and ReportSmith automatically displays the Create A New Report
dialog box for you to choose a table and create a new report.
Click this option and ReportSmith opens to the ReportSmith workplace, with no
dialog boxes displayed. You can then select the command you want.
New Report
None
187
Selecting measurements
Use the Units option to set the default measurement system to inches or centimeters.
Option
Description
Inches
Click in this option if you want ReportSmith rulers displayed in inches as the scale of
measurement. This is the default setting.
Click in this option if you want ReportSmith rulers displayed in centimeters as the
scale of measurement.
The Granularity setting determines the finest resolution for placing objects in a
report. Higher granularity gives a finer resolution on the placement of objects in the
report, but limits the maximum size of the page and workspace in the report.
ReportSmith strongly recommends using a granularity of at least 300 for inches, 118
for centimeters. Using a higher granularity is acceptable, but if you use a lower
granularity, its likely to cause problems. You would only use a lower granularity if
you need to display extremely wide or tall pages.
If your report was created with different units options than specified in the Options
dialog box, choose this option to have ReportSmith convert your report to use the
options you specify. (See Granularity, above, for further information.)
Cm
Granularity
Update Units
During File Open
Description
Screen
Click this option to select screen fonts each time you use ReportSmith. (When you
choose this option, ReportSmith includes TrueType fonts.)
Click this option to select only fonts that are installed on your printer each time you
use ReportSmith.
Click this option to select both screen and printer fonts each time you use
ReportSmith. (When you choose this option, ReportSmith includes TrueType fonts.)
Click this option to use TrueType fonts (scalable fonts that you can change and that
appear exactly as theyll print) each time you use ReportSmith.
Printer
Screen and Printer
True Type
Storing connections
The Connection File option stores the connections you create through File|Connections.
This option sets the location and name of your connection file.
The default Connection file name is RPTSMITH.CON. ReportSmith stores this file in
your Windows directory. If your Windows working directory is on a local area network
(LAN), give the connection file for each workstation a unique file name, with a three-
188
Creating Reports
character .CON file extension. To change this option, place the text cursor in the text box
to enter the drive, directory, and file name for the connection file.
Function
AddMenu
EnableMenu
EnableIcon
IsMenuChecked
IsMenuEnabled
KillMenu
In the following exercises, well show you how to write a macro that disables the New
command and the New Report button. Then, well show you how to add your own
menu item that automatically loads a report that you use often.
Disabling File|New
Suppose you dont want a user to be able to create a new report (you only want the user
to be able to open existing reports). You can disable the File|New command and the
New Report button on the toolbar. Well show you how to disable these options in the
following example. In it, well create a global macro, CUSTOM_MENU that is linked to
the Application Startup. Each time you start ReportSmith, it runs the CUSTOM_MENU
macro, disabling the New command and toolbar button.
To disable the New command and the New Report button:
1 Open a report and choose Tools|Macro. The Macro Commands dialog box appears.
189
2 In the Macro Name text box, enter a name for your macro. In our example, we named
our macro CUSTOM_MENU.
3 Turn on the Global Macros option.
4 Press the New button. The Edit Macro dialog box appears.
Notice that ReportSmith has placed the first and last lines of your formula into the
text window for you. You do not need to enter them again.
5 Enter the following formula into the Macro Formula text box:
Sub custom_menu()
EnableMenu "File|New",0
EnableIcon 1,1,0
End Sub
6 After youve entered your formula, press OK to return to the Macro Commands
dialog box.
Now, youll link the macro to an event.
7 Press the Links button to open the Macro Links dialog box.
You can link your macro to a variety of events including a keystroke, before printing
a report, or after opening the report. For this example, youll link the macro to the
Application Start Up event.
8 Under Object Type, choose Report. Under Event, choose Before Report Open and
choose Link. ReportSmith displays 1 of 1 in the Link Number text box, indicating
that you have created one link and you have a total of one link. Press OK.
190
Creating Reports
5 Enter the following formula into the Macro Formula text box:
Sub bring_up_report()
AddMenu "My Report","load_mac","File|New","This loads my report"
End Sub
Your formula tells ReportSmith to add a menu item called My Report after the
New command on the File menu.
Note
1 In the Windows Program Manager, File|New to open the New Program Object
dialog box.
2 Choose the Program Item option and press OK. The Program Item Properties dialog
box appears.
191
3 In the Description text entry box, type text youd like to appear for your icon. For
example, you could place the name of your report here.
4 Under Command Line, enter the RPTSMITH.EXE, followed by a space and the
location of your report.
For example, you might type the following to run a report called Sales from your
MYRPTS directory:
RPTSMITH.EXE C:\MYRPTS\SALES.RPT
This command automatically starts the ReportSmith application with the sales report
loaded in it.
5 Under Working Directory, enter the directory where the ReportSmith executable is
located.
For example, you might type the following:
C:\RPTSMITH
6 Press OK and your icon appears. You can double-click on it whenever you want to
run your report. When you select the icon it runs the ReportSmith program, so you
should select the icon when ReportSmith is not running.
192
Creating Reports
Chapter
11
Runtime Viewer
Chapter 11
The Runtime Viewer lets an unlimited number of users use ReportSmith without
owning the full product. Users can execute, view, and print reports, but they cannot
create or modify reports. The Runtime Viewer supports all functions that ReportSmith
performs through Dynamic Data Exchange (DDE) and ReportBasic, so you can create
dynamic reports that change according to your users needs.
The Runtime Viewer allows you to:
Set up dialog boxes containing options that end users can fill in to customize their
reports, such as sorting, selections, and range of records, and pass this information to
the Runtime.
Set up multiple buttons in your front-end application, such as a Print Summary
Report button or a Print Sales Report button to automatically print frequently
used reports.
Prompt for report variables, display user-defined dialog boxes, and respond to DDE
messages.
Overview
Follow these steps to set up the Runtime Viewer for your end users.
Install Runtime.
Setup necessary drivers. For Runtime to operate you need to set up the users
environment similar to the environment in which the reports were created in,
including data source names, named connections, Dynamic Data Access options and
global macros.
To make system administration easier and to ensure that Runtime operates smoothly
for the end user, set up ReportSmiths configuration files so they are compatible with
your reports.
193
Before installation, we recommend that you create backup copies of disks and that you
install Runtime using these backup copies.
To install Runtime,
The menus and toolbar contain commands that you can use to open, view, and print
reports. In the Runtime Viewer, you can:
Open multiple reports at one time.
Scroll and page through a report.
Use the Zoom buttons to view reports.
194
Creating Reports
Use the Save button to export data to different file formats such as Excel, Lotus, and
ASCII text.
Set Options for the Runtime Viewer. See the following section.
Exporting data
With the Save As feature, you can export data for use in other applications. However,
you cannot save changes to the report format using the Runtime Viewer. To modify a
report, use the full ReportSmith product. To export data, use the Save button, or the
File|Save As command. Choose a file type from the List Files of Type drop-down list.
Choose a location and name for your file and choose OK.
Setting options
The Runtime Viewer allows you to set Dynamic Data Access (DDA) parameters using
the File|Options command. The Options dialog box is shown below.
The options you specify here are saved in the RS_RUN.INI file in your Windows
directory.
195
Viewer. The following code fragment shows you how to drive Runtime using a
VisualBasic application. This code is executed when the end user presses the button
Command 1. It loads and prints MyReport.
Note
196
Creating Reports
Chapter
12
Creating and using a data dictionary
Chapter 12
The ReportSmith Data Dictionary allows you to present users with a simplified view of
data. You can filter your data by defining subsets of databases, connection information,
table and field aliases, headings, and groups of functionally related tables.
For example, an end user might typically use data from several SQL Server and dBASE
databases in one working session. You can create a dictionary that stores connection
information, tables and fields, aliases, defined groups, and headings for these databases.
A data dictionary allows you to:
Rename tables and fields with easily recognizable names.
Present users with a subset of the total set of tables and fields within a database to
simplify their interactions.
Present users with defined groups, so they can view various groupings of
functionally related tables.
A data dictionary can contain information about any supported data sources. However,
the data dictionary information must be stored in one of five data sources: ORACLE,
SQL Server, dBASE, SQLBase, or InterBase.
197
You can create a data dictionary that presents each department with a customized view
of the data.
Data Source A
Data Source B
Data Source C
DATA DICTIONARY
View 1 View 2 View 3
Purchasing
Marketing
Accounting
Overview
To create a data dictionary, you can:
Select File|New from the administration tool and enter a name, connection type, and
location for your dictionary.
Create a view and associate a view parent.
Choose tables and fields to include in the view.
Group related tables in the view.
Create aliases for tables and fields.
Create headings to appear on the report surface.
In ReportSmith, choose Tools|Data Dictionaries and establish a dictionary in
ReportSmith.
The items listed above are described in detail in the following sections.
198
Creating Reports
Since directory information is stored in the data dictionary for local connections, make
sure the tables you add to the data dictionary are in the same place as they will be when
you use them in your production environment.
Creating a view
A view controls what the end user sees. For example, the SALES dictionary can contain
two views, East Coast and West Coast, each containing regional data. A dictionary
can contain numerous views, and you can grant access to more than one view per
department or group.
When creating a view, use the Views dialog box to perform these tasks:
Type a name for your view.
Choose a view parent.
199
in ReportSmith. This is less efficient in terms of data dictionary space usage than
Source Databases described below.
Source Databases: When you select Source Databases as the view parent, you get, by
default, all the tables and fields that are normally part of a connection. This option is
the most efficient in terms of data dictionary database usage, since entries are not
made in the data dictionary for each table or field when you want a table or field to be
visible in ReportSmith. All tables and fields are visible in ReportSmith by default,
including new tables and fields that are added at a later time. Records only get
entered into the data dictionary when tables or fields are excluded, aliased, or field
headings defined.
The illustration below shows the Views dialog box.
Enter a name
Choose a
view parent
Options in the Views dialog box are described in the following table:
Option
Description
200
Creating Reports
Dialog boxes contain extended selection list boxes so you can drag the mouse to select
more than one item in a list. To select separate items in a list, use Ctrl+click. When
scrolling through a list, associated list boxes scroll in tandem with you.
Options in the Tables dialog box using the Data Source option are described in the
following table:
Option
Description
Source Database
Delete Source
Add Source Database to View
201
Option
Description
Server Connect
Files
Directories
Type
Drives
Connections
Tables
Fields
Include
Exclude
Include All
Exclude All
Table Defaults
Default All Tables
Right mouse button menus are generally available over the list boxes, and are a
convenient alternative to the push buttons.
The Tables dialog box that appears using the None option is shown below:
Choose an
option to display
tables or fields
202
Creating Reports
Options in the dialog box are the same as those described in the previous table and
include the following options:
Option
Description
This causes all the tables in the Files or Tables list box to be added to the
view. It also adds the fields in the tables to the view. Added tables and
fields are displayed in black. If you just want to add the tables but not the
fields to the view, select Include All Tables.
Displays the list of table owners for this connection.
This causes the selected tables in the Files or Tables list box to be added to
the view. It also adds the fields in the tables to the view. Added fields are
displayed in black. If you just want to add the tables but not the fields to
the view, select Include Tables.
This is a list of the servers found in the ReportSmith connection file. When
making a connection to a remote server, selecting the Type, then the
Server, and then clicking on the Server Connect button causes a
connection to be made. It is more efficient, however, to set up a named
connection with all this information. The named connection will then be
listed in the Connections combo box.
This is a list of the available databases for this connection.
Table Owners
Add Selected Tables to View
Servers
Databases
Creating groups
Use the Groups to group related tables together. This filters what appears in the Table
Open dialog box in ReportSmith. The Groups dialog box is shown below:
203
Options that appear in the Groups dialog box are described in the following table:
Option
Description
Group
Groups List
Add
Enter a name for the group into this text entry box.
Groups you create appear in this list.
Enter a name for the group into the text entry box and choose Add to place it into the
Groups list.
Select a group to delete and choose Remove.
Select tables by which to group and choose Include to include them in a group.
Select one or more tables and choose Exclude to exclude it from a group.
Choose Include All to include all available tables in a group.
Choose Exclude All to exclude all tables from a group.
Remove
Include
Exclude
Include All
Exclude All
Assigning aliases
You can change the field or table name to display a name that pertains to a specific view.
An alias is another name for a field or table, usually one that is easily recognizable by the
department using the view. For example, the Purchasing Department might use the
Vendors table aliased as Sellers, while the Production Department might use the same
with the alias Suppliers.
To assign aliases, choose the Aliasing button to use the Aliasing dialog box, shown
below.
Dialog boxes contain extended selection list boxes so you can drag the mouse to select
more than one item in a list. To select separate items in a list, Ctrl+click. When scrolling
through a list, associated list boxes scroll in tandem with you.
204
Creating Reports
Options that appear in the Tables dialog box are described in the following table:
Option
Description
Tables
Table Aliases
Fields
Disable List box
Field Aliases
Remove Aliases
Assign Aliases
This dialog is designed with the touch typist in mind. When a single table or field is
selected, the input focus is moved to the alias edit window. Then, after the alias is
defined, press Enter to assign it to the field and to select the next item in the list. Also, if
you have a long list of tables or fields, when you get near the bottom of the list, the list
boxes start scrolling automatically.
Creating headings
A heading consists of text that appears at the top of a column as the column label.
Choose the Headings button to create a heading. Headings appear in place of aliases or
field names. You may use spaces.
For example, suppose you have a field, CSTMR_ID, that you would like to appear on
the report surface as Customer ID. You would assign this heading in the Headings
dialog box, shown below.
205
Options in the Headings dialog box are described in the following table:
Option
Description
Tables
Fields
Select a table which contains fields to which you want to assign headings.
A list of fields and/or their aliases associated with the selected table appears in
this list.
The heading assigned to a field appears beside it in this list.
Select a heading and press Remove Heading to delete it from the list.
Select a field and type a heading for it into the text entry box. Choose Assign
Heading to add it to the Headings list, or just press Enter.
Heading
Remove Heading
Assign Heading
Copying a view
The amount of work involved in setting up a view can be considerable. It is possible that
every table and field will need to be renamed and redefined. In addition, when setting
up additional users, it is likely that a view will vary only slightly from an existing view.
For this reason, the data dictionary supports the ability to copy views.
To copy a view,
206
Creating Reports
Tools|Data Dictionaries command from ReportSmith on each machine for which they
wish to enable data dictionary usage.
In the Data Dictionary Location dialog box, choose the type and navigate to the
location in which you want to place the data dictionary. This defines the location of
the data dictionary tables. Choose OK.
In the Views dialog box, type Purchasing in the text entry box. This is the name of
your view.
While you are still in the Views dialog box, choose the Source Databases option.
207
Press Add to place the view name into the Defined Views list box.
In the Tables dialog box, press the Add Source Database to View button and type a
name for the data source into the Database Source Name box. This is a connection
that you have declared to be a part of the data dictionary. The name can reflect the
connection and directory which the data source points to. Type dBASE - VIDEO
into the text entry box and press OK to return to the Tables dialog box.
208
Creating Reports
Select the Tables or Fields option in the lower right portion of the dialog box. Choose
tables and fields to display in your view by selecting tables or fields, right-clicking the
mouse, and choosing an option from the pop-up menu, or by pressing the Include
button.
In the Groups dialog box, type a name that pertains to your group into the text entry
box, Purchasing, and press Add. Choose one or more tables from the Tables list
box to include in the group, as shown above. Choose Include Tables.
In the Aliasing dialog box you can create table and field aliases that are easily
recognizable to a particular department. Select a table or field and type an alias
(without spaces) into the text entry box, as shown in the following illustration. An
alias appears in ReportSmith in place of the field or table name. If you do not enter an
alias, the table or field name appears. To assign an alias, select a field or table, type an
alias into the text entry box and press Enter or choose the Assign Alias button.
Use the Headings dialog box to create headings that appear on the report surface.
You may use spaces in heading names, as shown in the following illustration. If you
do not enter a heading for a field, the alias or field name appears in place of the
column label on your report.
After you have created the dictionary, exit the Data Dictionary and open
ReportSmith. You can not open ReportSmith and a Data Dictionary at the same time.
In ReportSmith, choose Tools|Data Dictionaries to see the Data Dictionaries dialog
box.
Select the Data Dictionary you created (SALES-Purchasing) and press the
Associate button. Associating a data dictionary means that whenever the end user
uses a certain connection, for example, dBASE, ReportSmith uses the information
specified in the Data Dictionary.
Select a connection to which you want to associate the Data Dictionary. In this
example we selected the dBASE (ODBC) connection named SALES. It points to the
C:\RPTSMITH\VIDEO directory.
After you have chosen a connection, press OK. Establish the dictionary in
ReportSmith using the Tools|Data Dictionaries command.
209
You are now set up to use the SALES dictionary each time you choose the SALES
connection in ReportSmith.
210
Creating Reports
Appendix
A
Using ReportSmith with
other applications
Appendix A
You can use ReportSmith with other Windows applications, combining your work from
several products into one application. ReportSmith supports this function through
Dynamic Data Exchange (DDE) and Object Linking and Embedding (OLE). DDE lets
you call ReportSmith from another application, and vice versa. OLE lets you include
objects from other applications in your ReportSmith reports.
This appendix describes both methods (OLE and DDE), and presents examples for each,
including the following topics:
Using DDE
Using DDE
Dynamic Data Exchange (DDE) allows two Windows applications to communicate by
sending and receiving data and commands.
ReportSmith can be either a DDE client or a DDE server. A client application makes
requests of another Windows application. In turn, a server application responds to
requests from another application. Requests can be commands or requests for specific
data.
211
With ReportSmith, you can execute menu commands by Dynamic Data Exchange
(DDE) command from another Microsoft Windows application. DDE is a protocol for
Microsoft Windows that enables two applications to talk to each other. For example,
using DDE, an application can tell ReportSmith to open and print a report, leaving
ReportSmith minimized. This allows another application to present its user interface for
printing previously built reports.
Server
Applications
Every Windows-based application that can participate in DDE conversations has a
unique application (or app) name. The table below shows the app names for some
common Windows applications:
212
Application
App name
ReportSmith
Microsoft Access
Microsoft Excel
ReportSmith
MSAccess
Excel
Creating Reports
Application
App name
Program Manager
Word for Windows
ReportSmith Runtime
Progman
WinWord
RS_Runtime
Topics
A topic defines the subject of the DDE conversation and represents some unit of data
meaningful to the DDE server application. ReportSmith supports the System topic and
the Command topic, as well as user-defined topics.
Items
An item is a reference to a piece of data or, in ReportSmiths case, a command to execute.
For example, an item could be a menu command such as File|Open or a ReportBasic
command such as LoadReport.
Note
Strings used for the application name, topic, or item in a DDE conversation arent casesensitive.
Calling ReportSmith
To start ReportSmith from another application:
1 First you must start ReportSmith from within another application. For example, the
following Delphi code starts ReportSmith(minimized and without focus):
x = Shell("c:\rptsmith\rptsmith.exe", 6)
Description
DdeExecute
DdePoke
DdeRequest
Refer to the online Help for details on the commands used to call other applications.
213
view|zoom ( )
Menu name
Command name
You can also specify the option you want to use in the DDE command. For example, if
you want your application to magnify the object in its window up to 150%, you enter the
DDE command as follows:
view|zoom(150)
File|Open(BASIC.RPT)
File|Close
File|Print
View|Zoom(150)
You can send a command to ReportSmith using the following Delphi code examples.
DDE synchronization
The following code is an example of utilizing DDE synchronization to set up a
conversation between Delphi and ReportSmith to tell ReportSmith to display a message.
unit DDEtest;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DDEMan;
type
TForm1 = class(TForm)
DDEClientConv1: TDDEClientConv;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: Tobject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
214
Creating Reports
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
Var
DDECommand
:PChar;
Success
:Boolean;
RS_Window_Handle
:HWND;
LoadReportDone
:Boolean;
begin
{* Set up DDE Client conversation *}
DDEClientConv1.DDEService := RS_RunTime;
DDEClientConv1.DDETopic
:= Command;
DDEClientConv1.ServiceApplication := RS_RUN;
{* allocate enough space for null-terminated DDE Command string * }
DDECommand
:= StrAlloc(256);
{* Copy command from Pascal string into DDE Command buffer *}
StrPCopy(DDECommand, MsgBox Hello); }
{* Execute DDE command to cause ReportSmith to bring up a message box *}
Success
:= DDEClientConv1.ExecuteMacro(DDECommand, TRUE);
end;
procedure TForm1.FormCreate(Sender:
TObject);
begin
{* change caption of the form and button *}
Caption
:= Delphi - ReportSmith DDE Example;
Button1.Caption := Execute DDE command;
end;
end
215
displays the Microsoft Word icon on the report. When you double-click on the icon, the
Word document appears.
Double-click the
icon to open the
associated file
The main difference between linking and embedding an object is where you store the
data. When you embed an object in a report you are inserting information into that
report. Embedded objects become a part of the report itself. When you link an object
to your report, the report stores just the location of the object and displays a
representation of the linked data such as an icon. Linked objects are stored in a source
file and retain a connection to the original Windows application.
Use embedding to include information that becomes a part of the report and is always
available, even if the original source file is absent or moved. You can also use
embedding to include a file that may not always be available, such as a file residing on a
network.
Use linking to include data in your report that is maintained in a separate file and to
save space. The ReportSmith report will reflect any changes made to the source file and
always displays the last-saved version. Also, you can use linking to include a very large
file such as a video or sound object in your report.
216
Creating Reports
handles until you can see the entire object within the header or footer boundaries,
then release the mouse button.
To create an object and embed it in a report:
2 Double-click the application you want to use to create the object from the Object Type
list box. Alternatively, select the application you want to use and click the OK button.
The Object cursor appears.
3 With the mouse, position the Object cursor within the header or footer where you
want to place the object.
4 Left-click the mouse. The application opens so you can create the object youll embed
in the report. Since we chose Microsoft Graph, Microsoft Graph opens.
5 Create the object.
6 Select the applications Update or Return command from the File menu. ReportSmith
places the object where you click in the report. Click to select the header or footer if
the object exceeds its boundaries. Click and drag one of the four-corner handles until
you can see the entire object within the header or footer boundaries, then release the
mouse button.
1 Double-click the object and ReportSmith opens the application so you can see the
object you want to edit, or single-click the object to select it.
217
2 Select Edit|Object.
Note
The application name appears on the Edit menu, along with the Object command.
For example, Edit Microsoft Graph Object appears as the command name if the object
you select was created in Microsoft Graph. ReportSmith opens the application and
displays the selected object you want to edit.
Dont close the application from which youre copying the object until youve selected
the Paste Link command. If you close it before, Paste Link command wont be available
on the Edit menu.
218
Creating Reports
1 From the Edit menu choose Edit Links. The Links dialog box appears. The Edit Links
command is available only if youve created links. If you havent, the command is
dimmed on the Edit menu.
2 Click the link you want to cancel in the Links list box.
3 Press the Cancel Link button. ReportSmith cancels the link and the Links options for
that link are dimmed.
To change the location of a link:
1 Select the Edit Links command from the Edit menu. The Links dialog box appears.
The Edit Links command is available only if youve created links. If you havent, the
command is dimmed on the Edit menu.
2 Click the link you moved to a new location.
3 Press the Change Link button. The Change Link dialog box appears.
4 Type in the new path for the linked object. ReportSmith changes the link so it can
continue to update the object if any changes are made.
219
220
Creating Reports
Appendix
B
Macro reference
Appendix B
You link macros to events and objects using the Macro Links dialog box.
Basic conventions
When evaluating expressions, ReportBasic gives precedence to operators. To override
the default precedence you can use parentheses. The following table describes each
221
operator. The operators are listed in order of precedence; the first operator is the first to
be evaluated.
Expression
Description
()
.
Array element.
Record memberthe left operand must be a record variable, and the right operand
must be the name of a field.
Implicationoperands can be Integer or Long. The operation is performed bitwise.
(A Imp B) is the same as ((Not A) OR B ().
Equivalenceoperands can be Integer or Long. The operation is performed bitwise.
(A Eqv B) is the same as (Not (A X or B)).
Exclusive Oroperands can be Integer or Long. The operation is performed bitwise.
Inclusive Oroperands can be Integer or Long. The operation is performed bitwise.
Andoperands can be Integer or Long. The operation is performed bitwise.
Unary Notoperand can be Integer or Long. The operation is performed bitwise
(ones complement).
sequence used by the language specified by the user using the Windows Control
Panel. The result is 0 for FALSE and 1 for TRUE.
Numeric addition and subtraction. The + operator is also used for string
concatenation.
Modulus or Remainder. The operands can be Integer or Long.
Integer division. The operands can be Integer or Long.
Numeric multiplication or division. For division, the result is a Double.
Unary minus and plus.
Exponentiation.
Imp
Eqv
Xor
Or
And
Not
>, <, =, <=, >=, <>
, +
Mod
\
*, /
,+
^
222
Creating Reports
Numbers
The four numeric types are:
Type
Range
Integer
Long
Single
Double
Example
NumberVar = 5
Strings
Basic strings can be either fixed or dynamic. Fixed strings have a length specified when
they are defined. The length cannot be changed. Fixed strings cannot be 0 length.
Dynamic strings have no specified length. Any string can vary in length from 0 to 32,767
characters. There are no restrictions on the characters which can be included in a string.
For example, the character whose ANSI value is 0 can be embedded in strings. Local
string variable names require a $ at the end of the name of the variable.
Example
Records
Record variables are declared by using an As clause and a typeName which has
previously been defined using the Type statement.
The syntax for Records looks like this:
Dim variableName As typeName
Records are made up of a collection of data elements called fields. These fields can be of
any numeric, string, or previously-defined record type.
For details on accessing fields within a record see Type statement on page 354.
Arrays
Arrays are created by specifying one or more subscripts at declaration or Redim time.
Subscripts specifies the beginning and ending index for each dimension. If only an
223
ending index is specified, the properties of the beginning index are based on the Option
Base setting. Array elements are referenced by enclosing the proper number of index
values in parentheses after the array name, for example, arrayname(i,j,k).
The syntax for Arrays can be either of the following:
Dim variable( [ subscriptRange, ... ] ) As typeName
Dim variable_with_suffix([ subscriptRange, ... ])
Example
Dim DS as DataSet 'Declare a DataSet
Dim A(5,2) 'Declare an array
Dim A as Integer 'Declare a variable
Conversions
Basic automatically converts data between any two numeric types. When converting
from a larger type to a smaller type (for example, Long to Integer), a runtime numeric
overflow can occur. This indicates that the number of the larger type is too large for the
target data type. Loss of precision is not a runtime error (for example, when converting
from Double to Single, or from either float type to either integer type.)
Basic also automatically converts between fixed strings and dynamic strings. When
converting a fixed string to dynamic, a dynamic string which has the same length and
contents as the fixed string is created. When converting from a dynamic string to a fixed
string, some adjustment can be required. If the dynamic string is shorter than the fixed
string, the resulting fixed string is extended with spaces. If the dynamic string is longer
than the fixed string, the resulting fixed string is a truncated version of the dynamic
string. No runtime errors are caused by string conversions.
224
Creating Reports
No other implicit conversions are supported. In particular, Basic does not automatically
convert between numeric and string data. Use the functions Val and Str$ for such
conversions.
Trappable errors
This table lists the runtime errors which the macro language returns.
These errors can be trapped by the On Error statement on page 337. The Err
function on page 313 can be used to query the error code, and the Error$ function on
page 314 can be used to query the error text.
Error
code
Error text
Error
code
Error text
5
6
7
9
10
11
14
19
20
28
35
48
52
53
54
55
58
61
62
63
64
68
71
74
75
76
102
901
902
903
904
905
906
907
908
910
Application events
You can link a macro to an action, such as the keystroke event, Ctrl+R, or to an event that
coincides with report loading. You cannot link application macros to report events. For
information on how to link events to specific reports, refer to Report Events on
page 230.
The following sections describe each application event and provide specific scenarios
for real-world applications.
225
KeyStroke
When you link a macro to the KeyStroke event, it can be tied to any key or key
combination on your keyboard. A macro linked to the KeyStroke event runs when you
press the key or key combination you specify.
For example, suppose you want to link a macro to the keystroke, Ctrl+R, so that whenever
you press Ctrl+R, ReportSmith loads a report that you work on often.
If the active report has a report macro linked to the same keystroke, then that report
macro is executed first (see KeyStroke on page 226).
Application start up
A macro linked to this event runs immediately after you click the ReportSmith icon to
open the application and after ReportSmith displays its splash screen. You can link a
macro to this event to change the default ReportSmith environment or perform other
tasks before you open ReportSmith.
For example, you can add new menu items, disable or remove existing menu items, load
the reports you use on a daily basis, or execute a menu command, such as New or Open
on the File menu.
You can also launch other Windows applications simultaneously, such as Visual Basic,
Excel, and PowerBuilder.
226
Creating Reports
You can retrieve the last SQL statement using the GetSQL function.
In rare cases, you might find it necessary to modify the ReportSmith SQL statement. To
do this, you can use the macro command, SetSQL, to replace the string generated by
ReportSmith.
Note
Do not modify the query in the Before Executing SQL event. Instead, use the DataSet
Control methods (such as SetUserSQL, AddTable, and IncludeFields). Changes made
during the Before Executing SQL event are lost the next time you generate a SQL
statement. Use the SetSQL command with caution. Use it to make small changes to the
SQL statement to support servers which have unusual or non-standard SQL
requirements.
227
Or suppose you want to keep track of all report files opened by a given user. A macro
linked to this event can identify the title of each report and write its title and the time it
was opened in an ASCII file.
On SQL Error
Each time a SQL execution error occurs, the On SQL Error event is triggered. A macro
linked to this event can execute the LastError function to retrieve error text (usually
from an ODBC driver). It can attempt to fix the error by changing the report query from
which it originated. If that macro executes a ResumeEvent command with an argument
of 0, the FixReport dialog box will not appear and the SQL re-executes.
228
Creating Reports
Note
If the macro does not correct the error in FixReport, this event is called again. Use
caution when using ResumeEvent 0 to avoid being caught in an endless loop.
Creation Events
Creation Events can be linked to two objects: Group Header and Group Footer. When
you link a macro to the Header/Footer creation event, you must choose the grouping
level of the header or footer to which you want to link.
A macro linked to these events can call the ResumeEvent command with an argument
of 0 to suppress the creation of an individual group header or footer based on the data in
the report.
229
Report Events
A report macro is linked to a specific report and becomes a part of that report. You link
report macros to report events.
Note
KeyStroke
A macro linked to the KeyStroke event runs when you press the key or key combination
you specify, and the report to which the macro is also linked is the active report.
Note
If the active report has a report macro linked to the same keystroke, the report macro is
executed first. If the report macro is intended to replace the application macro (linked to
the same keystroke), the report macro should call the ResumeEvent command passing a
value of zero (false). In effect, the ResumeEvent code tells ReportSmith it should not
execute other processes normally tied to that event.
A KeyStroke event linked to a report macro overrides one that is linked to a global
macro.
For more detailed information and for examples of how you can use the KeyStroke
event, refer to KeyStroke on page 226.
230
Creating Reports
You can also use this event if you want a specific report to appear in a different display
mode than all other reports in your company. For example, suppose all reports are set
up to appear in presentation mode when you first open them, and you want a specific
report to appear in draft mode instead. You can create a report macro and link it to this
event so that only the specific report appears in draft mode every time you open it.
Before print
A macro linked to this event runs after you select File|Print, but before ReportSmith
actually prints the specific report to which the macro is also linked. Suppose you have a
specific report that is particularly large and you dont want to tie up the departments
printer. You can link a macro to this event to automatically send that report to another
printer, which is not used as often.
You can also use this event to warn the users that the specific report is particularly large,
and that printing it will be a time-consuming process. Then you can give them the
opportunity to cancel the print operation.
231
On SQL error
Each time a SQL execution error occurs, the On SQL Error event is triggered. A macro
linked to this event can execute the LastError function to retrieve error text (usually
from an ODBC driver). It can attempt to fix the error by changing the report query from
which it originated. If that macro executes a ResumeEvent command with an argument
of 0, the FixReport dialog box will not appear, and the SQL will re-execute.
This event applies only to the report to which the macro is linked.
Note
IF the macro does not correct the error in FixReport, this event is called again. Use
caution when using ResumeEvent 0, to avoid being caught in an endless loop.
Header/Footer events
Macros can be linked to the Group Header or Group Footer objects. These objects
currently have one event, the Creation event.
When you link a macro to the Header/Footer event, you must choose the grouping
level of the header or footer to which you want to link. In the Items list box of the Macro
Links dialog box, you can view a list of the groups in the active report. For a macro to
execute each time you create a department group footer, select the Group Footer object,
and the Department group, and press the Link button.
232
Creating Reports
A macro linked to the Header/Footer event can call ResumeEvent, passing an argument
of 0 (FALSE) to suppress the creation of an individual group header or footer based on
the data in the report. The current record in the report is set to the first record of the
group when the macro is called. The current record of the dataset is the first record of
the specified group. For example, if you group by department and want to know what
department header or footer is being called, execute Field$(Dept) to retrieve the
department name.
Command reference
You can use four types of commands when you create a macro: ReportBasic, DataSet
Control commands, Report Control commands written for ReportSmith, and core Basic
commands common to the Basic language.
Example
Global my_var as Number
Sub My_macro()
End Sub
Example
Sub My_macro()
Number_var = 55
String_var$ = 'MYNAME'
End Sub
233
Description
ActiveTitle$() function
AddMenu
CloseReport
CloseRS
Connect
CreateDDEItem statement
CreateDDETopic statement
Current
CurrentPage function
Date2Str
DateField
DDEExecute
DDEPoke
DDERequest
DerivedField
DoEvents
EnableIcon
EnableMenu
EnableRMenu
ExecuteMenu
ExecSQL
Field$
FieldFont
FieldText
GetAllFields$ method
GetDataSources$ method
GetDDEItem function
GetFieldName$ function
GetIncludePath$
GetNext
GetPrevious
GetRandom
GetRecordLimit function
234
Creating Reports
ActiveTitle$ function
Command
Description
GetRepVar
GetSQL()
hWin_Active() function
hWin_RS() function
IsMenuChecked
IsMenuEnabled
KillMenu
LastLoaded$() function
LoadReport
PrintReport
Recalc statement
RecordCount
ResumeEvent
Rgb
RunMacro
SetDataFilter statement
SetRepVar
SetDDEItem statement
SetIncludePath
SetRecordLimit statement
SetSQL
ShowRS
Str2Date command
SelectReport statement
SumField
TotalPages function
ActiveTitle$ function
Gets the window title of the currently active report.
Syntax ActiveTitle$
Comments For saved reports, the title contains the path name and file name of the
reports .RPT file.
Example
ActiveReport$=ActiveTitle$
Msgbox "Your report is called" + ActiveReport$
235
AddMenu
AddMenu
Allows you to add your own commands to ReportSmiths Main Menu to execute a
macro when the command is chosen.
HelpText$
A string that specifies the text of a help line on the status bar.
Comments You can have ReportSmith execute an active report macro or global macro
by specifying a macro name. (The name that appears in the active macro list in the
macro dialog box.) You can also have ReportSmith execute a .MAC file by passing a
string with a path and file name of the .MAC file you wish to run.
Note
If one of these commands was entered in a global macro that was tied to the Startup of
the application, then the menu would be customized each time ReportSmith is brought
up.
This command can be used to check the state of the menu that is used for new reports by
default by placing an exclamation point (!) before the menu name. This can be done
whether the menu item is specified by command or relative location.
Examples
AddMenu "Open Sales Reports", "LoadSales", "!File|Open"
Or,
AddMenu "Open Sales Reports",
"C:\RPTSMITH\MACROS\LSALES.MAC","File|Open"
CloseReport
Closes the active report.
236
Creating Reports
CloseRS
Parameters
Conditional% If the integer argument is FALSE (zero), the report closes unconditionally.
Returns Returns 0 if the active report was closed successfully. It returns 1 if there is no
active report, or 1 if the user canceled a conditional close.
Comments When you use this command as a function (rather than a statement), you
must enclose its arguments within parentheses. For more information on the differences
between functions and statements, refer to Introduction to macros on page 159.
Example
CloseReport 1
CloseRS
Closes ReportSmith.
brings up dialog boxes prompting the user to do certain tasks, such as save
unsaved files. If the argument is FALSE (zero), then ReportSmith closes
without bringing up dialog boxes or allowing the user to cancel the
process.
Connect
Opens a connection to a database server.
237
CreateDDEItem statement
Parameters
Type
Server$
UserId$
Password$
Database$
A number that identifies the type of database to which you are connecting:
0 Named Connection
1 Reserved
2 DBASE
3 EXCEL
4 PARADOX
5 ASCII
6 SQLSRVR
7 ORACLE
8 DB2
10 SYBASE
11 BTRIEVE
12 GUPTA
13 INGRES
16 TERADATA
17 DB2/GUPTA
19 UNIFY
40 DBASE (via ODBC)
41 EXCEL (via ODBC)
42 PARADOX (via ODBC)
48 BTRIEVE (via ODBC)
55 Generic ODBC driver (use this for most ODBC connections)
61 PARADOX (via IDAPI)
62 DBASE (via IDAPI)
67 INTERBASE (via IDAPI)
Identifies the server that will be used to make the connection.
Identifies the user making the connection.
The password of the user making the connection.
The name of the database to connect to or the file name of a local database.
Comments For local databases (such as dBASE), Server$, UserId, Password$, and
Database$ should be set to an empty string. If any of these parameters are not valid for
your connection type, use a null string.
Example
Connect 6, "sqlsvr","myuser","mypassword","mydb"
CreateDDEItem statement
Creates a new Dynamic Data Exchange item in ReportSmiths DDE server.
238
Creating Reports
CreateDDETopic statement
Parameters
TopicName$
ItemName$
RequestMacro$
Pokemacro$
Comments User options include specifying the name of a macro to execute before data
is requested from this item and specifying another name of a macro to be executed after
data is poked into this item. Those macros could use other commands to retrieve or
change the data in the DDE item. In order for this function to execute successfully, a
Topic must exist that matches the TopicName$ parameter.
This function enables you to create duplicate item names. In this case, only the first item
of a given name can be accessed. At this time, a DDE item remains in effect as long as
ReportSmith is executing. Eventually, functions are added to get a list of available DDE
items and to remove existing items.
Example
CreateDDETopic statement
Allows you to create a new Dynamic Data Exchange topic in ReportSmiths DDE server.
After a topic is created, DDE items can be added to it.
Comments This function allows you to create duplicate topic names. In this case, only
the first topic of a given name can be accessed. At this time a DDE topic remains in effect
as long as ReportSmith is executing. Eventually, functions will be added to get a list of
available DDE topics and to remove existing topics.
Example CreateDDETopic "MyTopic"
Current
Returns the record number to which the data set (belonging to the active report) is
pointing. In other words, it tells you what record number the Field$ function returns
when executed.
Syntax Current
239
CurrentPage function
Returns This function returns the record number to which the data set of the currently
active report is pointing.
Example
If Current = 1 then
MsgBox "At the beginning"
EndIf
CurrentPage function
Returns the page number that is displayed in the currently active report.
Syntax CurrentPage
Returns Returns the displayed page number.
Comments This function is useful in changing the active report for functions that work
on the currently active report.
Example MsgBox "The active report is on page: " + str$(CurrentPage)
Date2Str
Converts date from a Julian date code to a date string.
Example
Suppose you want to generate a date string for three days before the current
date taking into account Leap Year and month boundaries. You could accomplish this
the following way:
Today$ = Date$
Note
240
Creating Reports
DateField
DateField
Gives you date values.
DDEExecute
The DDEExecute command lets you send a DDE execute command to a DDE client
application.
Topic$
Command$
A string that specifies the DDE service to which you send the Execute
command. (This is usually the name of the application that receives the
command.)
A string that identifies the DDE topic to which you send the command.
(Most applications accept DDE Execute messages that are sent to their
SYSTEM topics.)
A string that identifies the DDE command itself. See the documentation of
the application to which youre sending the DDE command for details of
the DDE Execute commands it accepts.
241
DDEPoke
Comments When you use this command as a function (rather than a statement), you
must enclose its arguments within parentheses. For more information on the differences
between functions and statements, refer to Creating and working with macros on
page 162.
Example The following line of code will send a DDE Execute command causing Excel
to beep.
Success = DDEExecute("Excel","System","[Beep(0)]")
DDEPoke
Lets you poke a string to a DDE client application.
Item$
Data$
A string that specifies the DDE service to which youre going to poke. (This
is usually the name of the application receiving the command.)
A string that identifies the DDE topic to which you send the command.
(Most applications use the topic to identify the document into which you
want to poke the data.)
A string that identifies the DDE item into which you want to poke data.
A string, which is actually the data poked into the other application. See the
documentation of the application to which youre sending the DDE poke
command for details on the accepted DDE poke commands.
The following line of code puts the string My Data in the first cell of a
default Excel spreadsheet.
Success = DDEPoke("Excel","Sheet1","R1C1","My Data")
DDERequest
Gets data from a DDE server application as a string.
242
Creating Reports
DerivedField
Parameters
Service$
Topic$
Item$
A string that specifies the DDE service to which youre going to request.
(This is usually the name of the application that receives the command.)
A string that identifies the DDE topic to which youre going to send the
command. (Most applications use the topic to identify the document into
which you want to retrieve the data.
A string that identifies the DDE item into which you want to retrieve data.
Returns A string that has the requested data, or the string <ERROR> if the
operation is not performed successfully.
Comments See the documentation of the application to which youre sending the DDE
poke command for details on the accepted DDE poke commands.
Example The following line of code puts the data in the first cell of a default Excel
spreadsheet into a string variable called Data$.
Data$ = DDERequest( "Excel","Sheet1","R1C1" )
DerivedField
Sets the value of a Derived Field.
Comments The DerivedField command only has an effect in macros you use as
derived fields. It takes a string that is used for the derived field. If the value for the
derived field is a number, convert it to a string using the STR$ function.
Example
DoEvents
Allows other Windows applications to process messages.
Syntax DoEvents
Comments Use this function when you want your Basic code to yield processor time
to allow other applications to process messages.
Example
DoEvents
243
EnableIcon
EnableIcon
Enables and disables icons and combo boxes on the Toolbar and Ribbon.
Index of the icon group to which the icon or combo box belongs.
Index of the item within the group.
0 is to disable, 1 is to enable.
Example The command below disables the Italic button so that it is not available:
EnableIcon 14,2,0
EnableMenu
Enables or disables a menu command.
Returns Zero if a menu was removed successfully and 1 if a menu of the given name
was not found when used as a function.
Comments This command takes a string that specifies a menu item or a submenu
item. The string uses this format:
"MenuName|SubMenuName"
The names must match our menu commands, not including keyboard accelerators and
ellipsis (...) characters. If you omit the pipe and submenu name, the routine assumes
youre working with a top-level menu. If a top-level menu is disabled, all of its submenu
items are also disabled.
When you use this command as a function (rather than a statement) you must enclose
its arguments within parentheses. For more information on the differences between
functions and statements, refer to Creating and working with macros on page 162.
Example The following line of code disables the ReportSmith File|New menu item.
Success = EnableMenu( "File|New", 0 )
244
Creating Reports
EnableRMenu
EnableRMenu
Enables or disables right-mouse menus by object type.
EnableFlag
A code that specifies the object type to disable right mouse menu
items for.
1
Character
2
Border
3
Field Format
4
Text Alignment
5
Display As Picture
6
Column Width
7
Field Height
8
Selection Criteria
9
Translate
0
Disables the menu
Non-zero enables the menu
Comments This command used to check the state of the menu that is used for new
reports by default by placing an exclamation point (!) before the menu name. This can be
done whether the menu item is specified by command or relative location.
Example The following example will disable the right mouse abilities for text fields.
EnableRMenu 1,0
ExecuteMenu
Simulates a user clicking one of the ReportSmith menu items.
The menu name, submenu name, or both that you want to execute.
Returns Zero if a menu was executed successfully, and 1 if a menu of the given name
wasnt found.
Comments This command takes a string that specifies a menu item or a sum menu
item. The string uses this format:
"MenuName|SubMenuName"
245
ExecSQL
The names must match our menu commands, not including keyboard accelerators and
ellipsis (...) characters. If you omit the pipe and submenu name, the routine assumes
youre working with a top level menu.
When you use this command as a function (rather than a statement), you must enclose
its arguments within parentheses. For more information on the differences between
functions and statements, refer to Creating and working with macros on page 162.
Note
This command can be used to check the state of the menu that will be used for new
reports by default by placing an exclamation point (!) before the menu name. This can be
done whether the menu item is specified by command or relative location.
Example
ExecSQL
Executes stored procedures and other SQL strings that dont return a result set.
Server$
UserID$
Password$
Database$
Comments For local databases (such as dBASE), Server$, UserID$, and Password$
should be set to an empty string.
246
Creating Reports
ExecuteMenu
Example
ExecuteMenu
Syntax ExecuteMenu Menu$
Definition The ExecuteMenu command lets you simulate a user clicking a
ReportSmith menu item.
Parameters
Menu$
The menu name and/or submenu name that you want to execute.
Returns This function returns 0 if the menu was executed successfully, and -1 if a
menu of the given name wasnt found.
Comments It takes a string that specifies a menu item or a sum menu item. The string
uses this format:
MenuName | SubMenuName
The names must match our menu commands, not including keyboard accelerators and
ellipses. If you omit the pipe and submenu name, the routine assumes you are working
with a top level menu.
When you use this command as a function (instead of a statement), it requires the return
value, and you must enclose its arguments within parentheses.
Field$
Retrieves the value of the specified field for the record number to which the data set of
the currently active report is pointing. This statement is always used as a function.
Returns The value of the specified field as a string regardless of the retrieved fields
data type. If the specified field is not found, returns N\A or <ERROR>.
Comments The name of the field should exactly match the database column name.
You can link two tables together that have one or more column names in common. In
this case, its necessary to use the fully-qualified field name to insure that youre getting
the correct field. The fully-qualified field name includes the table name followed by a
period (.) followed by the field name. You can also use a field or table alias. The best way
247
FieldFont
to get the fully-qualified field name is to drag the field you want from the list box that
appears on the left of the Edit Macro dialog box into the Formula box.
FieldFont
Changes the font type, style attribute, point size, or color of a field in your report. This
command is usually used in a macro that is linked to the display event of a field.
ForColor
BackColor
Comments Add the style codes to combine attributes. For example, a 3 designates
bold italic. (Using the codes on the previous page, 1 + 2 = 3). For the fourth and fifth
arguments, use a color value for the last two color arguments.
You can specify one of 16 million colors using the Rgb command. Windows substitutes
the closest color to the one you select.
Note
If you do not want to change the attribute, point size, or color, use 1 (negative one).
Example The following example changes the font to red, italic, 14 point Arial:
Field Font "Arial", 14, 2, RGB(255,0,0), 1
FieldText
Applies to macro fields that are linked to the text event of a data field object. It changes
the display of the field.
248
Creating Reports
GetAllFields$ method
Parameters
Text$
Example If you have a field that contains a persons first name, but would prefer to use
their nickname, use a FieldText command similar to this one:
If field$("FirstName")="James" then
FieldText "Jim"
End If
GetAllFields$ method
Gets a list, separated by commas, of the fields available for a given table.
First a connection must be made and the table added to the data set before its field list
can be retrieved.
Parameters
Table$
Database$
The name of the table for which youre getting the list of fields.
The name of the tables database. This applies to tables with databases.
Returns A list of all fields that are available in the given table.
Comments The Table$ parameter is the path and file name for local databases. For
database servers, it takes the form Owner.TableName. For local databases or servers
that dont require that a database be specified the dBASE parameter should be left
blank.
Example MsgBox GetAllField$ ("dbo.emp","Indigo")
GetDataSources$ method
Gets the available data sources, separated by commas, as a string list.
Syntax [object.]GetDataSources
Returns A list of all of the data sources available to ReportSmith, including ODBC
Sources, separated by commas.
Example
249
GetDDEItem function
GetDDEItem function
Retrieves the data that a DDE client application would receive in response to a DDE
request to the ReportSmith item.
GetFieldName$ function
This function is a global filter, returning the column name of the data field for which the
filter or conditional formatting macro is being called.
Syntax GetFieldName$()
Returns Returns the column name of the data field.
Comments See also SetDataFilter statement on page 260.
Example CurrentValue$=Field$(GetFieldName$())
GetIncludePath$ command
Gets the default directory for macro include files.
Syntax GetIncludePath$()
Returns A string that is the default path for macro include fields.
Example MsgBox"Looking for include files in"+GetIncludePath$()
GetNext
Causes the data set in an active report to point to the record that comes immediately
after the record to which it is currently pointing.
250
Creating Reports
GetPrevious
Syntax GetNext
Example This example steps through the entire report counting the employees with
the first name John.
Get Random (1)
For x = 1 to RecordCount()
If Field$("First_Name")="John" then
Count=Count+1
Get Next
Next X
GetPrevious
Causes the data set in an active report to point to the record that comes immediately
before the record to which it is currently pointing.
Syntax GetPrevious
Comments The GetPrevious command can be used to change the current record of a
data set. The current record determines what data the Field$, SumField$ and DateField$
functions retrieve. This function could be used in a macro-defined summary field. When
a macro defined summary field is dropped in a group footer the current record is the
last record in that group. For this reason, a macro derived field can step backwards
through the group performing custom summary operations. See also GetNext on
page 250, GetRandom on page 251, Field$ on page 247, Current on page 239.
Example
'Position to the 3rd record
GetRandom 3
'Now go to 2
GetPrevious
GetRandom
Causes the data set in an active report to point to the record specified by the
RecordNumber% argument, if that record number exists.
The number of the record in the data you want to navigate to.
Comments See also GetPrevious on page 251, GetNext on page 250, Field$ on
page 247, SumField on page 264, DateField on page 241, Current on page 239,
and TotalPages function on page 265.
251
GetRecordLimit function
Example
'Point to the 23rd record in a set of data
GetRandom 23
GetRecordLimit function
Gets the total number of records that ReportSmith will download for any loaded or
created report.
Syntax GetRecordLimit
Comments This limit is set with the function SetRecordLimit.
Example TheLimit=GetRecordLimit
GetRepVar
Retrieves the value of a report variable in the active report. This command is only used
as a function.
Returns The value of the specified report variable as a string. This function returns
<ERROR> if a report variable of the specified name cannot be found in the active
report.
Comments GetRepVar takes a string argument that specifies the name of the report
variable being retrieved. See also SetRepVar on page 260, Val function on page 355,
and Str2Date on page 263.
Example
Var_name$=GetRepVar("Rep_var_name")
GetSQL
Returns a string that is the text of the last SQL statement that ReportSmith executed.
Syntax GetSQL
Comments This function can be used along with the SetSQL statement in a macro that
is linked to the Before SQL is Executed to change the SQL string On the Fly.
Example
The following stores the last generated SQL statement in a variable called
The_SQL$.
The_SQL$ = GetSQL$
252
Creating Reports
hWin_Active() function
hWin_Active() function
Gets the window handle of the currently active report.
Syntax hWin_Active()
Comments This function can be used along with Windows API functions. You make
the API functions available to ReportBasic through the use of the declare function.
Example
'Force the active report to an Icon
Result=ShowWindow(hWin_Active(),2)
Declare Function ShowWindow Lib "User"(ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
hWin_RS() function
Gets the ReportSmith main window handle.
Syntax hWin_RS()
Comments You can use this function along with Windows API functions. You make
the API functions available to ReportBasic through the use of the declare function.
Example RS_Handle=hWin_RS()
IsMenuChecked
Determines if a given menu item has a check mark next to it. This command is only used
as a function.
The menu name and/or submenu name that you are interested in.
Returns Returns 1 if the menu is checked, 0 if it isnt checked, and 1 if a menu of the
given name was not found.
Comments This function takes a string that specifies a menu item or a sum menu item.
The string is of the form MenuName|SubMenuName. The names must match our
menu commands, not including keyboard accelerators and ellipsis (...) characters. If you
omit the pipe and submenu names, the routine assumes youre working with a top level
menu.
This function does not correctly return the state of a menu item if it is called before the
menu is visible as in the case of a macro linked to the Application Startup event.
253
IsMenuEnabled
Note
This command can be used to check the state of the menu that is used for new reports by
default by placing an exclamation point (!) before the menu name. This can be done
whether the menu item is specified by command or relative location. Refer to the second
example. Also, refer to EnableMenu on page 244, KillMenu on page 255,
AddMenu on page 236, ExecuteMenu on page 245 and IsMenuEnabled on
page 254.
Example
Success = IsMenuChecked ("View|Boundaries")
Or,
If IsMenuChecked ("!View|Boundaries") = 1 Then
ExecuteMenu "View|Boundaries"
End if
IsMenuEnabled
Determines if a given menu item is enabled or grayed. This command is used only as a
function.
The menu name and/or submenu name that you are interested in.
Returns 1 if the menu is enabled, 0 if it is disabled, and 1 if a menu of the given name
was not found.
Comments It takes a string that specifies a menu item or a submenu item. The string
uses this format:
"MenuName|SubMenuName"
The names must match ReportSmith menu commands, not including keyboard
accelerators and ellipsis (...) characters. If you omit the pipe and submenu name, then
the routine assumes youre working with a top level menu.
Note
This command can be used to check the state of the menu that will be used for new
reports by default by placing an exclamation point (!) before the menu name. This can be
done whether the menu item is specified by command or relative location. Refer to the
second example. Also, refer to IsMenuChecked on page 253, EnableMenu on
page 244, KillMenu on page 255, AddMenu on page 236 and ExecuteMenu on
page 245.
Example
Success = IsMenuEnabled ("Edit|Cut")
Or,
254
Creating Reports
KillMenu
KillMenu
Removes one of the ReportSmith menu items.
The menu name and submenu name, or both, that you are interested in.
Returns 0 if a menu was removed successfully, and 1 if a menu of the given name
was not found.
Comments It takes a string that specifies a menu item or a submenu item. The string
uses this format:
"MenuName|SubMenuName"
The names must match ReportSmith menu commands, not including keyboard
accelerators and ... characters. If you omit the pipe and submenu name, the routine
assumes youre working with a top-level menu.
This command can be used to change the state of the menu that will be used for new
reports by default by placing an exclamation mark (!) before the menu name. This can be
done whether the menu item is specified by command or relative location. (!) removes
the menu item for all future reports for this session of ReportSmith, instead of just the
active report.
When you use this command as a function (rather than a statement), you must enclose
its arguments within parentheses. For more information on the differences between
functions and statements, refer to Creating and working with macros on page 162.
Example
The following code fragment will remove the File|New menu Item from
ReportSmith.
Success = KillMenu( "File|New" )
LastLoaded$ function
Gets the filename and path of the last .rpt field that was loaded into ReportSmith.
Syntax LastLoaded$
Example MsgBox"The last report Loaded was:"+LastLoaded$
255
List RepVar
List RepVar
Syntax ListRepVar$( Index% )
Definition ListRepVar returns the name of the report variable at the specified index in
the active report. If no report variable exists at the given index, then the command
returns a NULL string. If this command is executed in a macro linked to the Before
Report Open event of the Report Object, or the After Data Read event of the application
object, the command will return the report variable names for the loading report.
ListRepVar can be used to get the list of variables in a report and initialize them before
they are prompted.
Parameters
Index%
Example
Put the names of the report variables in an array
dim Variables$(20 )
Allow for a maximum of 20 report variables
while ListRepVar( CurrentVar )<>""
Variables$( CurrentVar ) = ListRepVar( CurrentVar )
CurrentVar = CurrentVar + 1
wend
LoadReport
Loads a report.
The directory path and name of the report (.rpt file) you would like to run.
You can use the InitString argument to set report variables before SQL is
executed. Report variables set in this manner will not prompt the user to
enter their values.
This is the format for the InitString argument:
@Report_Variable1=<Value1>,@ReportVariable2=<Value2>, ...
Specify the report variables you would like to set in the report.
256
Creating Reports
PrintReport
When you use this command as a function (rather than a statement), you must enclose
its arguments within parentheses. For more information on the differences between
functions and statements, refer to Creating and working with macros on page 162.
PrintReport
Prints the specified pages of the active report to the specified printer. This init string
cannot be used to initialize variables that belong to the detail section in master/detail
reports. All arguments are optional.
The number of the page of the report you would like to start printing.
The number of the page you would like to stop printing.
The name of the printer to which you would like to print the report.
The correct port specification.
The correct driver specification.
The number of copies to print.
When you specify the printer, driver and port, use the same text you see in the WIN.INI
file.
When you use this command as a function (rather than a statement), you must enclose
its arguments within parentheses. For more information on the differences between
functions and statements, refer to Creating and working with macros on page 162.
Recalc statement
Re-executes the currently active report so that the report surface will reflect changes
made to report variables or changes made with an associated dataset control object.
Syntax Recalc
257
RecordCount
Example The following example sets the starting date report variable to today and
recalculates.
SetRepVar("StartDate",Date$)
Recalc
RecordCount
Gets the total number of records in the data set that belongs to the currently active
report.
Syntax RecordCount
Returns The number of records in the currently active report or 0 if no active report
exists.
Comments Its useful when writing macros that step through the data in a report.
Example
The following code fragment counts all of the customers from the city of
Palo Alto in a customer database and displays the result.
GetRandom 1
For X = 1 to RecordCount
If Field$("CITY") = "Palo Alto" then Count = Count + 1
GetNext
Next X
MsgBox "The total number of customers located in Palo Alto are: "+ Str$(Count)
ResumeEvent
Lets a macro which is linked to an event determine if the event should be executed or
aborted.
Comments This only applies to certain events. For most events, 0 means abort and 1
means proceed. Some events recognize more codes. See the individual event for more
information.
Example
ResumeEvent 0
258
Creating Reports
Rgb
Rgb
Returns a value for the color that the FieldFont command uses for its color assignment.
Use the Custom Color option in the Windows Control Panel to select a color. Take note
of the Rgb settings for the color you select. Then use these values in the Rgb function to
get the color you need.
RunMacro
Executes a macro from another macro.
259
SetDataFilter statement
Examples
RunMacro "c:\rptsmith\macros\greeting.mac",""
RunMacro "two_arguments","1.2"
SetDataFilter statement
Executes before any data field column value is calculated. The specified macro can then
use the FieldText and FieldFont functions to change either the text or the appearance of
the data.
The path and file name of a .MAC file or name of an actual global macro to
be used as the macro data filter.
SelectReport statement
Sets the input focus to the report that has the indicated title.
Comments This statement is useful in changing the active report for functions that
work on the currently active report.
Example SelectReport "c:\rptsmith\sales.rpt"
SetRepVar
Stores a value in a report variable in the active report.
260
Creating Reports
SetDDEItem statement
Parameters
ReportVariable$ A string argument that specifies the name of the report variable being set.
Value$
A string argument that specifies what value to set the report value to.
SetDDEItem statement
Sets or changes the data in one of ReportSmiths DDE items. This could be done in
response to a DDE request to the specified item.
Comments A macro that is named as the request response macro for a user-defined
DDE item can use this function to set the data that a DDE client receives in response to a
DDE request. This technique could be used to create a DDE item that would report the
name of the currently active report or other information that might be useful to a DDE
client application.
Example SetDDEItem "MyTopic","MyItem","Mydata"
SetIncludePath command
Sets to default directory for macro include files.
261
SetRecordLimit statement
Comments The macro compiler first looks in this directory for include files, then it
looks in the standard search path. The beginning value is the default macro path in the
RPTSMITH.INI file.
Example SetIncludePath "c:\macros\include"
SetRecordLimit statement
Sets the total number of records that ReportSmith downloads for any loaded or created
report. A value of 0 allows an unlimited number of records to be downloaded.
Parameters
Limit
The maximum number of records that ReportSmith will download for a single
report.
Comments This statement is helpful for implementing a draft mode where you can
work with a subset of a large report until you are ready to work with the entire report.
Some operations continue to work against the entire result set, such as selections,
sorting, and summary fields, so that for these operations performance does not change.
Example SetRecordLimit 100
SetSQL
Replaces the SQL string that would normally be generated by ReportSmith.
Comments The SetSQL statement is only valid in a macro that is linked to the Before
SQL is Executed event. Care should be used when executing this function as the string
is not verified before it is executed. This statement can be used along with the GetSQL
function in a macro that is linked to the Before SQL is Executed event to change the
SQL string On the Fly.
Example SetSQL "Select ENAME, EMP_ID from SCOTT.EMP"
ShowRS
Hides, shows, minimizes, or maximizes ReportSmith.
262
Creating Reports
Str2Date
Comments You minimize ReportSmith after it opens a modal dialog box, ReportSmith
cannot be used until its brought back to normal size. This may only be possible by
sending another ShowRS command from DDE.
You cannot switch to it or execute any of its commands except through macros and
DDE. ReportSmith can still bring up dialog boxes and do any other activity, but because
its not visible, these actions can only be started by DDE commands or macros which are
already running.
Example
'Force ReportSmith to be an icon
ShowRS 2
Str2Date
Allows you to convert from a date string to a Julian date code.
Syntax Str2Date$(Date$,Type%)
263
SumField
Parameters
Date$
Type%
The date to convert as a string. The date can be provided in one of the following
formats:
MM-DD-YYYY
MM-DD-YY
MM\DD\YYYY
MM\DD\YY
Specifies the data information to be returned:
1 Gets the number of days since the date field (based on a Julian date).
2 Gets the month of the date as a number.
3 Gets the day of the month.
4 Gets the year.
5 Gets the day of the week.
6 Gets the day of the year out of 365 days.
SumField
Gives you the value of a summary field.
Comments You can drag and drop this command from the list box. The best way to
use it is to choose Summary Fields from the first Listbox and then double click on your
Summary Field. ReportSmith uses the SumField$ command and fills in the Parameters
for you.
264
Creating Reports
TotalPages function
TotalPages function
Returns the number of pages in the currently active report.
Syntax TotalPages
Comments This function is useful in changing the active report for functions that work
on the currently active report.
Example MsgBox "There are" + str$(Totalpages)+"in the current report"
Description
AddGroup
AddSort
AddSummary
AddTable
Connect
Disconnect
Field$
GetAllFields$
GetColumnAlias$
GetDataSources$
GetFieldList$
GetGroup$
GetSort$
GetSummary$
GetSQL$
GetTable$
GetTableAlias$
GetTableLink$
IncludeFields$
Load
Recalc
RemoveGroup
265
AddGroup
Method
Description
RemoveSort
RemoveSummary
RemoveTable
RemoveTableLink
ReplaceTable
Save
SetColumnAlias
SetFromActive
SetFromLoading
SetTableAlias
SetTableLink
SetUserSQL
TestSelection$
AddGroup
Adds grouping criteria at the specified level.
266
Creating Reports
AddSort
Parameters
Table$,
DataBase$,Field$ Table$, DataBase$ and Field$ serve to identify the field to be grouped
Level
upon.
The level argument specifies the grouping level that you want
information about. If an invalid level is specified, a null string is
returned and the error$ property is set to indicate the error.
The level argument specifies the grouping level that you want
information about where 0 is the entire report group, 1 is the primary
grouping criteria, 2 is the secondary grouping criteria, and so forth.
Type
NumRecs
Same value
Every n records (n is the NumRecs argument)
Daily
Monthly
Weekly
Annually
Quarterly
Hourly
Every minute
Every second
Second/10
Second/100
Second/100
Types 212 are only valid for date and /or time fields.
When grouping by every n records, this specifies how many records
per group. This is only used with a Type of 1.
AddSort
Adds a sorting criteria to the current dataset at the specified level.
267
AddSummary
Defines a string of the form: Owner. TableName or for local databases like
dBASE, the Table$ parameter is the file name of the local data base file.
For local databases or servers that dont require that a database be
specified, the Database$ parameter should be set to a null string.
The field that is being sorted.
Set to zero to sort from smallest to largest, non-zero to sort from largest to
smallest.
Indicates its priority among other sorting criteria for this dataset. Valid
values for this argument are 1 to the number of current sorting criteria +1.
Returns If an invalid index is specified the function fails and returns an error. This
function returns a 0 on success, a non-zero on error.
AddSummary
Adds a summary field to the specified grouping level and index.
268
Creating Reports
AddTable
Parameters
Table$,
DataBase$,Field$
Level
Type
Sum
Daily
Count
Minimum
Maximum
Average
First
Last
Standard Deviation
Variance
Returns Non-zero value for an error and the Error$ property is set to indicate the
error.
AddTable
Adds a table to a data set control object.
Note
Defines a string of the form: Owner. TableName or for local databases like
dBASE, the Table$ parameter is the file name of the local database file.
The dBASE$ parameter is for data servers that require databases. (For servers
that dont require a database, it should be set to a NULL string.)
In 2.0 + this argument can now take the path to a local database file or both path and file
name can be combined in Table$ as before.
269
Connect
Example
'Add the EMP table from the PUBS database with 'the outer dbo
MyDataSet.AddTable "dbo.emp","PUBS"
Connect
Replaces any previous connection information in a DataSet control with the supplied
connection information.
Server$
UserId$
Pswrd$
dBASE$
Returns 0 on success. If it is not zero, the Error$ property contains text that describes
the error.
Comments Note that for Oracle and other connections without databases, the dBASE$
should be set to a Null String.
Using the Connect method clears any previously defined tables or table columns,
sorting and grouping information, and so forth.
270
Creating Reports
Disconnect
Example ErrorCode=MyDataSet.Connect(6,"SQLSRVR","John_Doe","PW","")
Disconnect
Allows you to remove a connection that was previously set with the Connect method.
Syntax [object.]Disconnect
Returns Error if an active report is using the connection. The return code for this
function should be 0 on success. If it is not zero, then the Error$ property contains text
that describes the error.
Comments This function executes successfully only if there are no other DataSet
controls or reports using the same connection.
This command returns an error if any other report or active DataSet object is using the
connection that this object is trying to disconnect.
In the following example, we are assuming that we have a server called X:ORASRV, a user
called SCOTT with a password of TIGER.
Sub MakeAReport()
Dim NewData as DataSet
NewData.Connect 7, "X:ORASRV","SCOTT","TIGER"," "
'Add a Table (DataBase is NULL for Oracle)
NewData.AddTable "SCOTT.DEPARTMENT"," "
'Create the Report Object
NewData.Commit
PrintReport 0,0,"",""
CloseReport 0
NewData.Disconnect
End Sub
Field$
Returns the value of the specified data field for the current data set record. You can set
the current record with the data set record property.
Syntax [object].Field$(FieldName$)
271
GetAllFields$
Parameters
The name of the field to return data from.
FieldName$
Returns The value of the specified data field for the current dataset record.
Comments Before data can be retrieved from a data set object a connection must be
made; links must be set and a commit or recalc must be successfully performed.
Example
MyData.record = 5
Salary = val(MyData.Field$("SALARY"))
GetAllFields$
Lists all fields that are available in the given table.
Syntax [object].GetAllFields$(Table$,DBase$)
Parameters
Table$
dBASE$
The Table$ parameter is the path and file name for local databases.
The database that contains the table for connections that have databases.
Comments A connection must first be made and the table added to the dataset before
its field list can be retrieved.
For database servers Table$ takes the form:
Owner.TableName
For local databases or servers that dont require that a database be specified, the dBASE$
parameter should be left blank.
See the GetField$ function on page 319 to get an individual field out of the list of
fields.
GetColumnAlias$
Gets the alias for the specified field in the specified table.
272
Creating Reports
GetDataSources$
Parameters
Defines a string of the form: Owner. TableName or for Local DataBases like
dBASE, this parameter is the file name of the local database file.
The name of the database that contains the table for connections that have
databases.
The column for which to set an alias.
Table$
Database$
Column$
Returns The alias for the specified field in the specified table.
Comments For database servers Table$ takes the form:
Owner.TableName
For local databases or servers that dont require that a database be specified, the
Database$ parameter should be set to a null string.
Example
ColumnAlias$=MyData.GetColumnAlias$("dbo.emp",
"hr","DEPT_ID")
GetDataSources$
Lists all of the data sources available to ReportSmith, including ODBC Sources,
separated by commas.
Syntax [objet.]GetDataSources$
Returns Returns a list of all of the data sources available to ReportSmith.
Example DataSourcesAvailable$=MyData.GetDataSources$
GetFieldList$
Lists all fields that have been included in the given table.
Syntax [object.]GetFieldList$(Table$,DBase$)
Parameters
Table$
dBASE$
Returns A list of all fields that have been included in the given table.
273
GetGroup$
Comments A connection must be made first and the table added to the data set before
its field list can be retrieved.
For database servers, Table$ takes the form:
Owner.TableName.
For local databases or servers that dont require that a database be specified, the dBASE$
parameter should be left blank.
GetGroup$
Gets a string that provides information about grouping at the specified level.
Syntax [objet].GetGroup$(Level)
Parameters
Level
Specifies the grouping level that you want information about where 0 is the
entire report group, 1 is the primary grouping criteria, 2 is the secondary
grouping criteria, and so forth.
Returns A string that provides information about grouping at the specified level.
Comments If an invalid index is specified, a null string is returned and the Error$
property is set to indicate the error. Valid values for levels are zero to the number of
groups defined.
Example PrimaryGroup$=MyData.GetGroup(1)
GetSort$
Gets a string that indicates the sorting criteria at the given level if one exists.
Syntax [object].GetSort$(Level)
Parameters
Level
Specifies the sorting level that you want information about where 1 is the
primary sorting criteria, 2 is the secondary sorting criteria, and so forth.
Returns A string that indicates the sorting criteria at the given level if one exists.
Comments Valid values for the level argument are 1 to the number of current sorting
criteria. If an invalid index is specified, a null string is returned and the Error$ property
is set to Invalid Index.
Example PrimarySort$=MyData.GetSort$(1)
274
Creating Reports
GetSummary$
GetSummary$
Gets a string that provides information about a summary field at the specified grouping
level and index.
Index
Specifies the grouping level that you want information about where 0 is the
entire report group, 1 is the primary grouping criteria, 2 is the secondary
grouping criteria, and so forth.
Matches the order in which the tables are originally added.
Returns If an invalid index or level is specified a null string is returned and the Error$
property is set to indicate the error.
Example SecondSummary$=MyData.GetSummary(1,2)
GetSQL$
Gets the last SQL statement that was executed for this data set control object.
Syntax [object].GetSQL$
Returns The last SQL statement that was executed for this data set control object.
Example MySQL$=MyData.GetSQL$
GetTable$
Gets a string that describes the table at the specified index if possible.
Syntax [object].GetTable$(Index)
Parameters
Index
Returns A string that describes the table at the specified index if possible.
Comments If an invalid index is given, this function returns a null string and the
Error$ property is set to an appropriate error message.
Example SecondTable$=MyData.GetTable$(2)
275
GetTableAlias$
GetTableAlias$
Gets the alias for the specified table.
Table$
dBASE$
GetTableLink$
Gets a string that provides information about the table link at the given index if one
exists.
Syntax [object].GetTableLink$(Index)
Parameters
Index
Returns A string that provides information about the table link at the given index if
one exists.
Comments If an invalid index is specified, a null string is returned and the Error$
property is set to indicate the error.
Example SecondTableLink$ = MyData.GetTableLink(2)
IncludeFields$
Adds columns from a table to your data set.
276
Creating Reports
Load
Parameters
Defines a string of the form: Owner. TableName or for local databases like
dBASE, this parameter is the file name of the local database file.
dBASE$
Contains the table for connections that have databases.
IncludeList$ A list of fields in a table to include as part of a table.
Table$
Comments The field list should be one string with the names of the included fields
separated by commas. The names should be provided exactly as they appear in our
dialog boxes. It is case-sensitive.
Example MyData.IncludeFields "dbo.emp","Pubs","First_Name, Last_Name, Dept, Emp_Id"
Load
Replaces any previous connection information in a DataSet control with information
from the file that is specified by the Filename$ parameter.
The name of a file that the data set control object should be read from.
Returns 0 on success. If it is not zero, then the Error$ property contains text that
describes the error.
Comments The file must be created with the Save method and can have any extension.
Example MyData.Load("c:\RPTSMITH\MyData.DSC")
Recalc
Re-executes the SQL for this DataSet Control Object.
Syntax [object].Recalc
Comments Because this command is associated with a dataset control, any changes to
the result are not reflected in associated reports until a report level recalc is performed.
This command is generally used with dataset control functions as stand-alone queries
that do not have associated reports.
Example MyData.Recalc
RemoveGroup
Removes a grouping criteria from a report.
277
RemoveSort
Specifies the grouping level that you want to remove where 0 is the entire
report group, 1 is the primary grouping criteria, 2 is the secondary grouping
criteria, and so forth.
RemoveSort
Removes the sorting criteria at the given level if one exists.
Specifies the grouping level that you want to remove where 0 is the entire
report group, 1 is the primary grouping criteria, 2 is the secondary grouping
criteria, and so forth.
Example
MyData.RemoveSort 1
RemoveSummary
Returns a summary field from a report.
278
Creating Reports
RemoveTable
Parameters
Level
Index
Specifies the grouping level that you want information about where 0 is the
entire report group, 1 is the primary grouping criteria, 2 is the secondary
grouping criteria, and so forth.
Matches the order in which the tables were originally added.
Returns If an invalid index is specified a null string is returned and the Error$
property is set to indicate the error.
RemoveTable
Removes the table at the specified index if possible.
Example MyData.RemoveTable 2
RemoveTableLink
Removes the table link for the specified index from the dataset control object.
Index
Specifies the grouping level that the summary is operating on where 0 is the
entire report group, 1 is the primary grouping criteria, 2 is the secondary
grouping criteria, and so forth.
The index of the link for which to retrieve information.
Comments If an invalid index is specified, a null string is returned and the Error$
property is set to indicate the error.
Example MyData.RemoveSummary 1,2
279
ReplaceTable
ReplaceTable
Replaces one table in a report with another.
Database$
For local databases or servers that dont require that a database be specified, the
Database$ parameter should be set to a null string.
Save
Replaces any previous connection information in a DataSet control with information
from the file that is specified by the Filename$ parameter.
Returns 0 on success. If it is not zero, then the Error$ property contains text that
describes the error.
Example
MyData.Save "c:\MyData.Dat"
SetColumnAlias
Sets or changes the Alias for a column in a reports table.
280
Creating Reports
SetFromActive
Parameters
The path and file name for local databases.
The database that contains the table.
The name of the field for which to set an alias.
The new alias for the field.
Table$
Database$
Column$
Alias$
Returns
Comments
Owner.TableName.
For local databases or servers that dont require that a database be specified the
Database$ parameter should be set to a null string.
SetFromActive
Replaces any previous connection information in a DataSet control with a reference to
the data description for the currently active report.
Syntax [object.]SetFromActive
Comments Use this method to change a currently active report. It can also be used to
save DataSet information for a report that can then be reloaded, changed and used to
create other reports.
Example
The following example uses the SetFromActive method along with the
Selection$ property to change the selection criteria for the active report.
Sub ChangeActiveSelection()
'Create a DataSet named DS
dim DS as DataSet
DS.SetFromActive
DS.Selection$ = " Department = 'Accounting' "
'Cause the report to update to reflect the change
Recalc
End Sub
SetFromLoading
Associates the dataset control object with a report that is being loaded (before the SQL is
executed for this report).
Syntax [object].SetFromLoading
Returns 0 on success, a non-zero on error.
281
SetTableAlias
Comments This function is only valid when used in the Before report is opened
event.
Example MyData.SetFromLoading
SetTableAlias
Sets or changes the alias for a table in a report.
For local databases or servers that dont require that a database be specified the
Database$ parameter should be set to a null string.
SetTableLink
Defines a link between two tables.
282
Creating Reports
SetUserSQL
Parameters
The first table to link.
The database that contains Table1.
The field to link on from the first table.
The second table to link.
The database that contains Table2.
The field to link on from the second table.
The relation between the linked fields. It can have one of the following
values:
Table1$
DBase1$
Field1$
Table2$
DBase2$
Field2$
Operation
0 Field 1 = Field 2
1 Field 1 < Field 2
2 Field 1 <= Field 2
3 Field 1 > Field 2
4 Field 1 >= Field 2
The type of link. It can have one of the following values:
JoinType
0
1
2
3
Inner join
Left outer join
Right outer join
Full outer join
Comments Before a table link can be defined, both tables must be added to the DataSet
control using the AddTable function.
Example This example links the emp table to the dept table by the department id
excluding all unmatched records.
'The following needs to be one line in Basic"
SetTableLink "dbo.emp","Indigo","Dept_Id","dbo.dept","Indigo","Dept_Id",0,0
SetUserSQL
Places the DataSet control object into user entered SQL mode with the provided SQL.
283
TestSelection$
Example
MyData.SetUserSQL"SELECT dbo.emp.First_Name,
dbo.emp.Last_Name FROM dbo.emp"
TestSelection$
Returns a string that tells how many records would be selected or an error message
about the selection criteria.
Syntax [object].TestSelection$
Comments In order to set and test a selection criteria, you must have a connection and
at least one table.
Example
MyData.Selection$="Salary>40000"
Msgbox MyData.TestSelection$()
Description
AllDataBases$
AllOwners$
AllTables$
DataBases$
Error$
Id
Link Macro
Name$
Owner$
Record
RecordCount
Selection$
Table$
AllDataBases$
Returns all the databases available under the current connection, separated by commas.
284
Creating Reports
AllOwners$
Syntax [object].AllDataBases$
Comments A connection must be made before the list of all databases can be retrieved
from a DataSet object.
Example ListofDataBases$=AllDataBases$
AllOwners$
Returns all owners available under the current connection, separated by commas.
Syntax [object].AllOwners$
Comments Before the list of all owners can be retrieved from a DataSet object, a
connection must be made.
Example OwnerList$ = MyData.AllOwners$
AllTables$
Returns a list of all tables, separated by commas, for a connection.
DataBase$
Returns the current database for the current connection.
Syntax [object].DataBase$
Comments Before a current database can be retrieved from a DataSet object, a
connection that has databases must be made.
Example CurrentDataBase$=MyData.DataBase$
Error$
Contains a string that describes the error that occurred in the last dataset control method
executed.
285
Id
Example
X=DS.ADDTABLE("INVALID.TABLE","BOGUS")
If x<>0 then msgbox DS.ERROR$
End If
Id
Stores an integer value.
Name$
Returns the current name for the current situation.
Owner$
Returns the current owner for the current situation.
Syntax [object].Owner$
Comments Before the current owner can be retrieved from a DataSet object, a
connection that has owners must be made.
Example CurrentOwner$=MyData.Owner$
Record
Returns the current record in the dataset.
Syntax [object].Record
Comments Before the number of records can be retrieved from a DataSet object a
connection must be made, links must be set, and a commit or recalc must be performed
successfully.
286
Creating Reports
RecordCount
RecordCount
Returns the total number of records in the dataset.
Syntax [object].RecordCount$
Comments Before the number of records can be retrieved from a DataSet object a
connection must be made, links must be set, and a commit or recalc must be successfully
performed.
Example TotalRecords=MyData.RecordCount$
Selection$
Gets or sets the selection criteria for a DataSet Control Object.
Syntax [object.]Selection$
Comments A table must be added to the data set before the selection criteria can be
written or read. A change in Selection$ does not change the data until a commit method
or a recalc command is executed. This property is read/write at run time.
You can get the individual tables from the list by using the GetField$ function.
Example MyData.Selection$="Salary>40000"
Table$
Returns a list of tables included in a report, separated by commas.
Syntax [object].Table$
Comments By using the GetField$ function you can get the individual tables from the
list.
Example SecondTable$=GetField$(MyData.Table$,2,",")
287
Name$
Id
Page
TotalPages
Error$
SetFromActive
Recalc
For information on how to use Help, press F1 or choose Using Help from the Help
menu.
Command
Description
Abs
Asc
Assert
Atn
Beep
Begin Dialog... End Dialog
Button
ButtonGroup
Call
CancelButton
Caption
CDbl
ChDir
ChDrive
CheckBox
Chr$
CInt
288
Creating Reports
Command
Description
CLng
Close
ComboBox
Command$
Const
Cos
CSng
$CStrings
CurDir$
Date$
Declare
Deftype
Dialog
Dim
Dir$
Do...Loop
Do...While
Environ$
Eof
Erl
Err function
Err statement
Error
Error$ function
Exit
Exp
FileAttr
Fix
For...Next
FreeFile
Function ... End Function statement
GetCurValues
GetField$
Global
GoTo
GroupBox
Hex$
If ... Then ... Else
$Include
Input$ function
Input # statement
InputBox$ function
289
Command
Description
InStr
Int
Kill
LBound
LCase$
Left$
Len
Let (assignment statement)
Line Input #
ListBox statement
Lof
Log
LTrim$
Mid$ statement
Mid$ function
MkDir
MsgBox function
MsgBox statement
Name
$NoCStrings
Oct$
OkButton
On Error
Open
Option Base
OptionButton
OptionGroup
Print
Randomize
ReDim
Rem
Reset
Resume
Right$
RmDir
Rnd
RTrim$
Seek
Seek
Select Case
SetField$
Sgn
Shell
290
Creating Reports
Abs function
Command
Description
Sin
Space$
Sqr
Stop
Str$
String$
Sub ... End Sub
Tan
Text
TextBox
Time$
Timer
Type
UBound
UCase$
Val
While ... Wend
Write
Abs function
Returns the absolute value of a specified numeric expression.
Returns Matches the type of numeric expression. This includes variant expressions
that return a result of the same vartype as input, except vartype 8 (string) is returned as
vartype 5 (double) and vartype 0 (empty) is returned as vartype 3 (long).
Asc function
Converts the first character in a string from character code to an ASCII code number.
291
Assert statement
Parameters
string_expression$
Returns An integer corresponding to the ANSI code of the first character in the
specified numeric expression. The return value is single-precision for an integer,
currency or single-precision numeric expression, double-precision for a long, variant, or
double-precision numeric expression.
Assert statement
Declares a condition that must be true for continued macro execution.
Atn function
Calculates the arctangent of a numeric expression that indicates a ratio. This can be used
only as a function.
Returns Returns the angle (in radians) corresponding to the arctangent of the specified
numeric expression.
Comments The return value is single-precision for an integer, currency or singleprecision numeric expression, double-precision for a long, variant or double-precision
numeric expression.
292
Creating Reports
Beep statement
Example x=Atn(0.33)
Beep statement
The Beep statement produces a short beeping tone that can be used to alert a user.
Syntax Beep
Comments The Beep statement produces a single short beeping tone through the
computer speaker.
Example
If Value>Limit then
Beep
MsgBox "The value was greater than allowed"
End If
Syntax
Begin Dialog dialogName [x, y,] dx, dy
[dialog box definition statements]
End Dialog
Parameters
[x, y,]
dx, dy
The x and y arguments give the coordinates that position the dialog box. These
coordinates designate the position of the upper left corner of the dialog box,
relative to the upper left corner of the client area of the parent window. The x
argument is measured in units that are 1/4 the average width of the system
font. The y argument is measured in units 1/8 the height of the system font.
(For example, to position a dialog box 20 characters in, and 15 characters down
from the upper left hand corner, enter 80, 120 as the x, y coordinates.) If these
arguments are omitted, the dialog box is centered in the client area of the
parent window.
The dx and dy arguments specify the width and height of the dialog box
(relative to the x and y coordinates). The dx argument is measured in 1/4
system-font character-width units. The dy argument is measured in 1/8
system-font character-width units (i.e., to create a dialog box 80 characters
wide, and 15 characters in height, enter 320, 120 as the dx, dy coordinates).
Comments The Begin Dialog statement assumes that if only two arguments are given,
they are the dx (width) and dy (height) arguments. Unless the Begin Dialog statement is
293
Button statement
followed by at least one other dialog box definition statement and the End Dialog
statement, an error results.
The other definition statement must include an OkButton or CancelButton or Button
statement. If this statement is left out, there is no way to close the dialog box, and the
procedure is unable to continue executing.
To display the dialog box, you create a dialog record variable with the Dim statement,
and then display the dialog box using the Dialog statement. In the Dim statement,
dialogName is used to identify the dialog definition.
Example
Begin Dialog MyDialog 120,130
Caption "This is My Dialog"
End Dialog
Button statement
Defines a custom push button. (This allows the use of push buttons other than OK and
CANCEL.) It is used in conjunction with the ButtonGroup statement.
Syntax
Parameters
x, y
dx, dy
text$
The x and y arguments set the position of the button relative to the upper left
corner of the dialog box.
dx and dy set the width and height of the button. A dy value of 14 typically
accommodates text in the system font.
Contains a message that is contained in the push button. If the width of this
string is greater than dx, trailing characters are truncated.
Comments The Button statement can be used only between a Begin Dialog and an
End Dialog statement. A dy value of 14 typically accommodates text in the system font.
Example
ButtonGroup statement
Begins definition of the buttons when custom buttons are to be used.
294
Creating Reports
Call statement
Parameters
.field
A variable that contains the number of the button in the group that was
selected. Buttons are numbered by the order they are entered in the dialog
definition.
Comments ButtonGroup establishes the dialog-record field that contains the users
selection. If ButtonGroup is used, it must appear before any Button statement which
creates a pushbutton. Only one ButtonGroup statement is allowed within a dialog box
definition.
The ButtonGroup statement can be used only between a Begin Dialog and an End
Dialog statement.
Example
Begin Dialog MyDialog 360,260
ButtonGroup.Pressed
Button 20, 130, 150, 30, "Load Report"
Button 20, 130, 150, 30, "Print Report"
End Dialog
'Execute dialog in this code
MyDialog.Pressed
'This will have the value of 1 if load report is pressed and 2 if print report if pressed.
Call statement
Transfers control to a subprogram procedure or application-defined dialog box.
Syntax A
Syntax B
Subprogram_name argumentlist
Syntax C
Syntax D
295
CancelButton statement
When a variable is passed to a procedure which expects its argument by reference, the
variable must match the exact type of the formal parameter of the function. (This
restriction does not apply to expressions.)
Similarly to subprogram invocation, functions associated with application-defined
dialog boxes can be invoked using Call syntaxes listed as C and D above. In Syntax C,
the name inside the parentheses must be a variable previously Dimmed as an
application-defined dialog record. In Syntax D, the dialog box name can be followed by
either a dialog record variable or a comma-separated list of dialog box fields settings, for
example:
SearchFind .SearchFor="abc", .Forward=1
When calling an external DLL procedure, arguments can be passed by value rather than
by reference. This is specified either in the Declare statement, the Call itself, or both,
using the ByVal keyword. If ByVal is specified in the declaration, then the ByVal
keyword is optional in the call; if present, it must precede the value. If ByVal was not
specified in the declaration, it is illegal in the call unless the datatype specified in the
declaration was Any. Specifying ByVal causes the parameters value to be placed on the
stack, rather than a far reference to it.
Example
Sub Callable (Argument$)
End Sub
Sub Macro
Call Callable "My Argument"
CancelButton statement
The CancelButton statement determines the position and size of a cancel button.
The x and y arguments set the position of the cancel button relative to the
upper left corner of the dialog box.
dx and dy set the width and height of the button. A dy value of 14 can usually
accommodate text in the system font.
Comments The CancelButton statement can be used only between a Begin Dialog and
an End Dialog statement.
The x and y arguments set the position of the cancel button relative to the upper left
corner of the dialog box. dx and dy set the width and height of the button. A dy value of
14 can usually accommodate text in the system font.
If the CancelButton is pushed at runtime, the dialog box is removed from the screen and
an Error 102 is triggered.
296
Creating Reports
Caption statement
Caption statement
Defines the text to be used as the title of a dialog box.
Comments The Caption statement can be used only between a Begin Dialog and an
End Dialog statement.
If no Caption statement is specified for the dialog box, a default caption is used.
CDbl function
The CDbl function converts an expression to double-precision floating point. This can be
used only as a function.
Syntax
CDbl ( numeric_expression )
Parameters
numeric_expression
Example Cdbl("Table.Numberfield1"+"Table.Numberfield2")
ChDir statement
Changes the default directory for the specified drive.
297
ChDrive statement
Parameters
Pathname$ is a string expression identifying the new default directory.
pathname$
Comments The ChDir statement changes the default directory for the specified drive.
It does not change the default drive. (To change the default drive, use ChDrive).
The syntax for pathname$ is:
[drive:] [\] directory [\directory]
The drive argument is optional. If omitted, ChDir changes the default directory on the
current drive.
ChDrive statement
Changes the default drive.
Syntax
ChDrive drivename$
Parameters
drivename$
Comments If a null argument () is supplied, the default drive remains the same. If
the drivename$ argument is a string, ChDrive uses the first letter only. If the argument
is omitted, an error message is produced. (To change the current directory on a drive,
use ChDir.)
Example ChDrive "g:"
CheckBox statement
The CheckBox statement places a checkbox within a dialog box.
298
Creating Reports
CInt function
Parameters
x, y
dx
dy
text$
.field
The x and y arguments give the coordinates that position the check box. These
coordinates designate the position of the upper left corner of the check box,
relative to the upper left corner of the dialog box. The x argument is measured
in 1/4 system-font character-width units. The y argument is measured in 1/8
system-font character-height units. (See Begin Dialog ... End Dialog
statement on page 293.)
The dx argument is the combined width of the check box and the text$ field.
Because proportional spacing is used, the width varies with the characters
used. To approximate the width, multiply the number of characters in the
text$ field (including blanks and punctuation) by 4 and add 12 for the
checkbox.
The dy argument is the height of the text$ field. A dy value of 12is standard,
and should cover typical default fonts. If larger fonts are used, the value
should be increased. As the dy number grows, the checkbox and the
accompanying text moves downward within the dialog box.
The text$ field contains the title shown to the right of the check box. If the
width of this string is greater than dx, trailing characters are truncated. If you
wish to include underlined characters so that the check box selection can be
made from the keyboard, the character must be preceded with an ampersand
(&).
The .field argument is the name of the dialog-record field that holds the
current check box setting. If its value is 0, the box is unchecked; if its value
is 1 the box appears grayed; if its value is 1, the box is checked. The macro
language treats any other value of .field the same as a 1.
Comments The CheckBox statement can be used only between a Begin Dialog and an
End Dialog statement.
Example CheckBox 10,10,14,14,"My statement", .check_value-holder
CInt function
Converts the value of expression to an integer by rounding.
Comments Clnt accepts any type of expression. After rounding, the resulting number
must be within the range of 32767 to 32767, or an error occurs.
Strings that cannot be converted to an integer results in a Type Mismatch error.
Variants containing nulls results in an Illegal Use of Null error. To convert a numeric
299
CLng function
expression to a different data type, see the CDbl function on page 297, CLng
function on page 300 and CSng function on page 302.
Example Clnt("table.Decimalfield")
CLng function
The CLng function converts the value of expression to a long by rounding.
Syntax
CLng (numeric_expression)
Parameters
(numeric_expression)
Example Clng("Table.Numfield"*10000)
Close statement
Closes a file, concluding input/output to that file.
300
Creating Reports
ComboBox statement
Example
'Close file number 1
close number 1
ComboBox statement
The ComboBox statement is used to create a combination text box and list box.
dx,dy
text$
.field
The x and y arguments give the coordinates that position the upper left corner
of the list box, relative to the upper left corner of the dialog box. The x
argument is measured in 1/4 system-font character-width units. The y
argument is measured in 1/8 system-font character-width units. (See Begin
Dialog ... End Dialog statement on page 293.)
The dx and dy arguments specify the width and height of the combo box in
which the user enters or selects text.
The text$ field specifies the name of the string containing the list variables.
The .field argument is the name of the dialog-record field that holds the text
string entered in the text box or chosen from the list box. The string in the text
box is recorded in the field designated by the .field argument when the OK
button (or any pushbutton other than CANCEL) is pushed.
Comments The ComboBox statement can be used only between a Begin Dialog and
an End Dialog statement.
Example ComboBox 10,10,14,14,"My Statement",.text_entered_holder
Const statement
You use the Const statement to declare symbolic constants for use in a Basic program.
Comments Basic is a strongly typed language. The available data types for constants
are numbers and strings.
301
Cos function
The type of the constant can be specified by using a type character as a suffix to the
constantName. If no type character is specified, the type of the constantName is derived
from the type of the expression.
If Global is specified, the constant is validated at module load time; if the constant has
already been added to the runtime global area, the constants type and value are
compared to the previous definition, and the load fails if a mismatch is found. This is
useful as a mechanism for detecting version mismatches between modules.
Cos function
Declares symbolic constants for use in a Basic program.
Returns The Cos function returns the cosine of an angle. The return value is between
1 and 1. The return value is single-precision if the angle is an integer or singleprecision value, double precision for a long or double-precision value.
Comments The angle is specified in radians, and can be either positive or negative.
Example
'Calculate the cos of 450
Pi radians = 1800
The_cos = cos(45x3.1415/180)
Note
CSng function
The CSng function converts the value of expression to a single-precision floating point.
302
Creating Reports
$CStrings metacommand
Example S=Csng(1/3)
$CStrings metacommand
The $CStrings metacommand tells the compiler to treat a backslash character inside a
string (\) as an escape character. This treatment is based on the C language.
Syntax $CSTRINGS
Comments The supported special characters are:
Newline (Linefeed) \n
Formfeed
\f
Horizontal Tab
\t
Backslash
\\
Vertical Tab
\v
Single Quote
\'
Backspace
\b
Double Quote
\"
Carriage Return
\r
Null Character
\0
For both hexadecimal and octal, fewer than 3 characters can be used to specify the code
as long as the subsequent character is not a valid (hex or octal) character.
To tell the compiler to return to the default string processing mode, where the backslash
character has no special meaning, use the $NoCStrings metacommand.
Example '$CStrings
CurDir$ function
This function determines the current directory of the specified drive.
303
Date$ function
Parameters
[ (drivename$) ] Drivename$ is a string expression identifying the drive to return the
default directory of. This drive must exist, and must be within the range
specified in the CONFIG.SYS file. If a null argument () is supplied, or
if no drivename is indicated, the path for the default drive is returned.
Returns The path (including the drive letter) that is current default directory for the
specified drive. The dollar sign, $, in the function name is optional. If specified the
return type is string. If omitted the function returns a variant of vartype 8 (string).
Comments To change the current drive, use ChDrive; to change the current directory,
use ChDir. command from the list box.
Example
'Get the current directory of Drive C
CurrentDir$=CurDir$("C")
Date$ function
Retrieves the system date as a string.
Syntax Date$
Returns A string representing the current date. The dollar sign, $, in the function
name is optional. If specified the return type is string. If omitted the function returns a
variant of vartype 8 (string).
Declare statement
The Declare statement has two usesforward declaration of a procedure whose
definition is to be found later in this module, and declaration of a procedure which is to
be found in an external Windows DLL or external Basic module.
Syntax A
Syntax B
304
Creating Reports
Declare statement
Array parameters are indicated by using empty parentheses after the parameter. Array
dimensions are not specified in the Declare statement.
External DLL procedures are called with the PASCAL calling convention (the actual
arguments are pushed on the stack from left to right). By default, the actual arguments
are passed by far reference. For external DLL procedures, there are two additional
keywords, ByVal and Any, that can be used in the parameter list.
When ByVal is used, it must be specified before the parameter it modifies. When
applied to numeric data types, ByVal indicates that the parameter is passed by value,
not by reference. When applied to string parameters, ByVal indicates that the string is
passed by far pointer to the string data. By default, strings are passed by far pointer to a
string descriptor.
Any can be used as a type specification, and permits a call to the procedure to pass a
value of any datatype. When Any is used, type checking on the actual argument used in
calls to the procedure is disabled (although other arguments not declared as type Any
are fully type-safe). The actual argument is passed by far reference, unless ByVal is
specified, in which case the actual value is placed on the stack (or a pointer to the string
in the case of string data). ByVal can also be used in the call. It is the external DLL
procedures responsibility to determine the type and size of the passed-in value.
Returns A Sub procedure does not return a value. Function returns a value, and can be
used in an expression. Function names must end with a type character.
This specifies the return value of the function. The name argument names the Sub or
Function being declared.
the procedure is to be found in another Basic module named libName. In this case, the
other module is loaded on demand whenever the procedure is called. The macro
language will not automatically unload modules that are loaded in this fashion. The
macro language detects errors of mis-declaration with very high (but not perfect)
reliability.
If the libSpecification is of the format:
Lib libName [ Alias ordinal ]
the procedure is to be found in a Dynamic Link Library (DLL) named libName. The
ordinal argument specifies the ordinal number of the procedure within the external
DLL. If the ordinal is not specified, the DLL function is accessed by name, which can
cause the module to load more slowly. It is recommended that the ordinal be used
whenever possible.
The Softbridge language supports two different behaviors when an empty string () is
passed ByVal to an external procedure. The implementor of the macro language can
specify which behavior by using the macro language API function SetInstanceFlags. In
any specific implementation which uses the macro language, one of these two behaviors
should be used consistently. We recommend the second behavior, which is compatible
with Microsofts VB Language. The following two paragraphs describe the two possible
behaviors.
305
Deftype statement
Example
Declare Function ShowWindow Lib
"User" (ByVal hwnd as Integer,
ByVal hwnd CardShow as Integer)as Integer
Deftype statement
Specifies the default data type of a variable specified in varTypeLetters.
Syntax
DefInt varTypeLetters
DefLng varTypeLetters
DefSng varTypeLetters
DefDbl varTypeLetters
DefStr varTypeLetters
Parameters
varTypeLetters
The name of the variable in which you would like to define the
data type.
Example
DefInt MyInt1, Another Int, LastInt
DefStr Name, Caption
306
Creating Reports
Dialog
Dialog
Displays a dialog box.
The name of a user defined dialog box created with the dim statement.
Comments The data for the controls of the dialog box comes from the dialog box
record recordName.
The dialog box recordName must have been declared using the Dim statement. If the
user exits the dialog box by pushing the Cancel button, a runtime error is triggered
which can be trapped using On Error.
The Dialog statement does not return until the dialog box is closed.
Example
Dim The_Diag as UserDiag
Dialog The_Diag
Dim statement
Declares variables for use in a Basic program.
Syntax Dim [ Shared ] variableName [As type] [,variableName [As type]] ...
Comments Basic is a strongly typed language. The available data types are: numbers,
strings, records, arrays, dialog boxes and Application Data Types (ADTs).
If the As clause is not used, the type of the variable can be specified by using a type
character as a suffix to the variableName. The two different type-specification methods
can be intermixed in a single Dim statement (although not on the same variable).
Names
Variable names must begin with a letter and contain only letters, numbers and
underscores. Variable names can also be delimited by brackets, except for other
brackets, any character can be used inside the brackets.
Dim my_1st_variable As String
Dim [one long and strange! variable name] As String
Numbers
Numeric variables can be declared using the As clause and one of the following numeric
types: Currency, Integer, Long, Single, Double. Numeric variables can also be declared
by including a type character as a suffix to the name.
307
Dim statement
Strings
Basic supports two types of strings, fixed-length and dynamic. Fixed-length strings are
declared with a specific length (between 1 and 32767) and cannot be changed later. Use
the following syntax to declare a fixed-length string:
Dim variableName As String* length
Dynamic strings have no declared length, and can vary in length from 0 to 32767. The
initial length for a dynamic string is 0. Use the following syntax to declare a dynamic
string:
Dim variableName$
Or,
Dim variableName As String
Records
Record variables are declared by using an As clause and a typeName which has
previously been defined using the Type statement. The syntax to use is:
Dim variableName As typeName
Records are made up of a collection of data elements called fields. These fields can be of
any numeric, string, variant, or previously-defined record type. See Type for details on
accessing fields within a record.
You can also use the Dim statement to declare a dialog record. In this case type is
specified as:
[ Dialog ] dialogName
where dialogName matches a dialog box name previously defined using Begin Dialog.
The dialog record variable can then be used in a Dialog statement.
Dialog records have the same behavior as regular recordsthey differ only in the way
they are defined. Some applications may provide a number of pre-defined dialog boxes.
Objects
Object variables are declared by using an As clause and a typeName of a class. Object
variables can be Set to refer to an object, and then used to access members and methods
of the object using dot notation.
Dim Ole2 As Object
Set Ole2 = CreateObject("spoly.cpoly")
Ole2.reset
An object may be declared as new for some classes. In such instances, the object variable
does not need to be Set , a new object is allocated when the variable is used.
Note
308
Creating Reports
Dir$ function
Arrays
The available data types for arrays are: numbers, strings, variants, objects and records.
Arrays of arrays, dialog box records, and ADTs are not supported.
Array variables are declared by including a subscript list as part of the variableName.
The syntax to use for variableName is:
Dim variable( [ subscriptRange, ... ] ) As typeName
Or,
Dim variable_with_suffix( [ subscriptRange, ... ] )
If startSubscript is not specified, 0 is used as the default. The Option Base statement can
be used to change the default.
Both the startSubscript and the endSubscript are valid subscripts for the array. The
maximum number of subscripts which can be specified in an array definition is 60. The
maximum total size for an array is only limited by the amount of memory available.
If no subscriptRange is specified for an array, the array is declared as a dynamic array.
In this case, the ReDim statement must be used to specify the dimensions of the array
before the array can be used. A variable declared inside of a procedure has scope local to
that procedure. A variable declared outside of a procedure has scope local to the
module. It is permissible for a procedure to declare a variable with a name that matches
a module variable. When this happens, the module variable is not accessible by the
procedure.
Variables can be shared across modules. See the Global statement for details.
The Shared keyword is included for backward compatibility with older versions of
Basic. It is not allowed in Dim statements inside of a procedure. It has no effect. Basic
allows a variable to be automatically declared, without the use of a Dim statement. If a
variable is first used with a type character as a suffix to its name, the variable is
automatically declared to be a local variable of the specified type. If no type character is
specified, the variable is automatically declared to be a local variable of type Variant. It
is considered good programming practice to declare all variables, and not make use of
this feature. To force all variables to be explicitly declared use the Option Explicit
statement. It is also recommended that you place all procedure-level Dim statements at
the beginning of the procedure. Regardless of what mechanism you used to declare a
variable, you can choose to use or omit the type character when referring to the variable
in the rest of your program. The type suffix is not considered part of the variable name.
Example
Dir$ function
Returns a file that matches the given directory and/or wild card. Can be used only as a
function.
309
Do...While statement
Attrib%
include a drive specification. It may also include wildcard characters (?) and
(*).
An integer expression specifying the file names that need to be added to the
list. The default value for attrib% is 0.
Returns The Dir$ function returns a filename that matches the specified pattern. The
dollar sign ($) in the functions name is optional. If specified the return type is string. If
omitted the function returns a variant of vartype 8 (string).
Comments This argument can include a drive specification. It can also include the
wildcard characters ? and *. Dir$ returns the first filename that matches the
filespec$ argument. To retrieve additional filenames that match the filespec$, call the
Dir$ function again, omitting the filespec$ argument. If no file is found, an empty string
() is returned. For Attrib%, Dir$ returns only files without directory, hidden, system,
or volume label attributes set.
Here are the possible values for attrib%:
Value
Meaning
0
2
4
8
16
Example
'Count .rpt files in "c:s"
Count=1
A$=Dir$("C:\.rpt")
While Dir$<>""
Count=Count+1
Wend
Do...While statement
Repeats a block of statements while a condition is true or until a condition becomes true.
Syntax A
Do [ { While | Until } condition]
[ statementblock ]
[ Exit Do ]
310
Creating Reports
Environ$ function
[ statementblock ]
Loop
Syntax B
Do
[ statementblock ]
[ Exit Do ]
[ statementblock ]
Loop [ { While | Until } condition]
Parameters
condition Condition is any expression that Basic can determine to be TRUE (nonzero) or
FALSE (0).
Comments Basic repeats the program lines contained in the statementblock(s) as long
as a While condition is true or until an Until condition is FALSE.
When an Exit Do statement is executed, control is transferred to the statement which
follows the loop statement. When used within a nested loop, an Exit Do statement
moves control out of the immediately enclosing loop.
Example
'search to the end of the R&D Group
do GetNext
Loop While Field$("Dept") = "R&D"
Environ$ function
Retrieves strings from the operating systems environment table.
Syntax A Environ$(environment-string$)
Syntax B Environ$( n% )
Parameters
environment-string$ The name of a keyword in the operating system environment. If this
n%
311
Eof function
Eof function
Indicates if the end of a file has been reached.
filenumber%
Returns
Comments The Eof Function returns a (1) if the end-of-file condition is true for the
specified file.
Example The following fills a string-array from a file. (!= means not equal.)
While Eof(2)!=1
Input#2, A$(x)
x=x+1
Wend
Erl function
Gets the line number of the last trapped error. Can be used only as a function.
Syntax Erl
Returns The line number where an error was trapped.
Comments Using the Resume or On Error statements resets the Erl value to 0. If you
want to maintain the value of the line number returned by Erl, you should assign it to a
variable.
The value of the Erl function can be set indirectly through the Error statement.
312
Creating Reports
Err function
Err function
Determines the last run time error code. It can be used only as a function.
Syntax Err
Returns The runtime error code for the last error that was trapped.
Comments Using the Resume or On Error statements resets the Err value to 0. If you
want to maintain the value of the error code returned by Err, you should assign it to a
variable.
The value of the Err function can be set directly through the Err statement, and
indirectly through the Error statement. See Trappable errors on page 225.
Err statement
Sends error information between procedures.
Syntax Err = n%
Parameters
An integer that contains the code of the error.
n%
Comments The argument n% must be a 0 (indicating that no runtime error has been
trapped) or an integer expression indicating a runtime error code (having a value
between 1 and 32,767).
This statement can be used with Error$ to generate application specific errors.
Example
'Set to user error number 276
Err=276
Error statement
Error errorcode% simulates the occurrence of a macro language or user-defined error.
313
Error$ function
Parameters
Represents the error code, must be an integer between 1 and 32,767.
errorcode%
Comments If an errorcode% is one which the macro language already uses, the Error
statement simulates an occurrence of that error.
User-defined error codes should employ values greater than those used for standard
macro language error codes. To help ensure that non-macro language error codes are
chosen, user-defined codes should work down from 32,767.
If an Error statement is executed and there is no error-handling routine enabled, the
macro language produces an error message and halts program execution. If an Error
statement specified an error code not used by the macro language, the message Userdefined error is displayed.
Error$ function
Returns an error message for the given error code. Can be used only as a function.
Syntax
Error$ [(errorcode%)]
Parameters
errorcode%
Returns The error message that corresponds to the specified error code.
Comments If the errorcode% is omitted, Basic returns the error message for the
runtime error which has occurred most recently.
If no error message is found to match the errorcode null string() is returned. See
Trappable errors on page 225.
Exit statement
Allows the program flow to escape from a loop function or subroutine.
314
Creating Reports
Exp function
Parameters
Do | For
Function | Sub
Comments Exit Do can be used only within a Do...Loop statement. Exit For can be
used only within a For...Next statement. In both cases, control is transferred to the
statement which follows the loop statement. When used within a nested loop, an Exit
statement moves control out of the immediately enclosing loop.
The Exit Function and Exit Sub statements transfer control from the current procedure
back to the original calling procedure. Exit Function must be used in a function
procedure. Exit Sub can be used only to exit from a Sub procedure.
Example
'Wait until 11am
Do
If time$="11:00" then Exit Do
Loop
Exp function
Returns the value e raised to the numeric-expression power.
value = Exp(2.333)
FileAttr function
Returns information about an open file.
Syntax
315
Fix function
Parameters
The number used in the Open statement to open the file.
Either a 1 or 2. If attribute% is 2, FileAttr returns the operating system
handle for the file.
filenumber%
attribute%
Returns The FileAttr function returns information about an open file. Depending on
the attribute chosen, this information is either the file mode or the operating system
handle. The following table lists the return values and corresponding file modes if
attribute% is 1. See the following table.
Value
Mode
1
2
8
Input
Output
Append
Example
The following example gets the DOS file handle of the second open tile
report.
handle=FileAttr(2,2)
Fix function
Returns the integer part of a numeric expression.
Returns The integer part of a numeric-expression. The return type matches the type of
numeric expression. This includes variant expressions which return a result of the same
vartype as input. Except vartype 8 (string) is returned as vartype 5 (double) and vartype
0 (empty) is returned as vartype 3 (long).
Comments The argument given is any numeric expression. Fix removes the fractional
part of the expression and returns the integer part only for both positive and negative
numeric expressions. See the CInt function on page 299 and Int function on page
326.
Examples The following returns 6:
Fix (6.2)
316
Creating Reports
For...Next statement
For...Next statement
Repeats the statement block a fixed number of times, determined by the values of start,
end, and step.
Syntax
For counter = start TO end [STEP increment]
[ statementblock ]
[ Exit For ]
[ statementblock ]
Next [ counter ]
Parameters
start
end
increment
counter
statementblock
Comments In order for a For...Next loop to execute, the start and end values must be
consistent with increment. If end is greater than start, increment must be positive. If end
is less than start, increment must be negative. Basic compares the sign of (end-start) with
the sign of Step. If the signs are the same, and end does not equal start, the For...Next
loop is entered. If not, the loop is omitted in its entirety.
With a For...Next loop, the program lines following the For statement are executed until
the Next statement is encountered. At this point, the Step amount is added to the
counter and compared with the final value, end. If the beginning and ending values are
the same, the loop executes once, regardless of the Step value. Otherwise, the Step value
controls the loop as follows:
Step Value
Loop Execution
Positive
If counter is less than or equal to end, the Step value is added to counter. Control
returns to the statement after the For statement and the process repeats. If counter is
greater than end, the loop is exited; execution resumes with the statement following
the Next statement.
The loop repeats until counter is less than end.
The loop repeats indefinitely.
Negative
Zero
Within the loop, the value of the counter should not be changed, as changing the
counter makes programs more difficult to edit and debug.
For...Next loops can be nested within one another. Each nested loop should be given a
unique variable name as its counter. The Next statement for the inside loop must appear
before the Next statement for the outside loop. The Exit For statement can be used as an
alternative exit from For...Next loops.
317
FreeFile function
If the variable is left out of a Next statement, the Next statement matches the most recent
For statement. If a Next statement occurs prior to its corresponding For statement, Basic
returns an error message.
Multiple consecutive Next statements can be merged together. If this is done, the
counters must appear with the innermost counter first and the outermost counter last.
Example
For i = 1 To 10
[ statementblock ]
For j = 1 To 5
[ statementblock ]
Next j, i
FreeFile function
Used when you need to supply a file number, and want to make sure that you are not
choosing a file number which is already being used.
Syntax
FreeFile
Syntax
Function name [ ( parameter [ As type ] ... ) ]
name = expression
End Function
318
Creating Reports
GetField$ function
Returns You specify the return value by assigning it to the function name as if it were
a variable or parameter. If no such assignment occurs, the value returned is 0 for
numeric functions and the empty string () for string functions. The function returns to
the caller when the End Function statement is reached or when an Exit Function
statement is executed.
Example
Function = triangle(leg1 as double,leg2 as double)
Triangle = (leg1^2+leg2^2)^.5
End Function
GetField$ function
Returns a substring from a delimited string. Can be used only as a function.
Syntax
Parameters
The source string is considered to be divided into fields by separator
characters.
field_number%
The number of the substring to fetch.
separator_chars$ The character that is used to separate the fields. E.g., in a comma
delimited string it would be ,.
string$
Example
GetField$("value1, value2, value3,",2,",")
would return "value2"
319
Global statement
Global statement
Declares global variables for use in a Basic program.
Comments Basic is a strongly typed language. The available data types are: numbers,
strings, records, arrays, dialog boxes, and Application Data Types (ADTs).
Global data is shared across all loaded modules. If an attempt is made to load a module
which has a global variable declared that has a different data type than an existing
global variable of the same name, the module load fails.
If the As clause is not used, the type of the global variable can be specified by using a
type character as a suffix to the variableName. The two different type-specification
methods can be intermixed in a single Global statement (although not on the same
variable).
Regardless of which mechanism you use to declare a global variable, you can choose to
use or omit the type character when referring to the variable in the rest of your program.
The type suffix is not considered part of the variable name.
GoTo statement
Changes a program flow by branching to a label.
Syntax
GoTo Label
Parameters
Label
Comments GoTo sends control to a label. The macro language does not support the
use of line numbers.
A label has the same format as any other Basic name. To be recognized as a label, a name
must begin in the first column and be followed immediately by a colon (:). Reserved
words are not valid labels.
GoTo cannot be used to transfer control out of the current function or sub.
320
Creating Reports
GroupBox statement
Example
Start:
If Value>Limit then GoTo Done
value=value+somemore.
GoTo Start
Done:
GroupBox statement
Sets up a box that encloses sets of items, such as option boxes and check boxes that you
wish to group together in a dialog box.
The x and y arguments set the position of the group box relative to the upper
left corner of the dialog box.
dx and dy set the width and height of the box.
The text$ field contains a title that is embedded in the top border of the group
box.
Comments The GroupBox statement can be used only between a Begin Dialog and an
End Dialog statement.
In the text$ field, trailing characters are truncated if text$ is wider than dx. If the text$
argument is an empty string (), the top border of the group box will be a solid line.
Hex$ function
Converts from a decimal to a hex string.
321
Syntax A
If condition Then
then_statement [Else else_statement ]
Syntax B
If condition Then
statement_block
[ ElseIf expression Then
statement_block]...
[ Else
statement_block ]
End If
Note
The syntax in both formats above, including the placement and organization of items on
each line, must be followed exactly.
Comments The resulting action depends on the logical value of one or more
conditions expressed in the structure.
The condition can be any expression which is evaluated as TRUE (non-zero) or FALSE
(zero).
In the single-line version of the If statement, the then_statement and else_statement can
be any valid single statement. Multiple statements separated by colons (:) are not
allowed. When multiple statements are required in either the Then or Else clauses, use
the block version of the If statement.
In the block version of the If statement, the statement_blocks can be made up of zero or
more statements, separated by colons (:) or on different lines.
Example
If total>limit then
MsgBox "over limit"
Else
MsgBox "under limit"
322
Creating Reports
$Include metacommand
$Include metacommand
Tells the compiler to include statements from another file.
A file with Basic source code to compile along with the current source.
Input$ function
Reads a specified number of characters from a file. Can be used only as a function.
Input # statement
Reads data from a sequential file and assigns the data to variables.
323
InputBox$ function
Syntax
Input [#] filenumber%, variable, [variable]
Input [prompt$,] variable, [variable]
Parameters
filenumber%
prompt$
variable
An integer expression identifying the open file to read from. This is the
number used in the Open statement to open the file.
An optional string that can be used to prompt for keyboard input.
Lists the variables that are assigned the values read from the file. The list of
variables is separated by commas.
Comments If filenumber is not specified, the user is prompted for keyboard input
with a question mark ?, unless prompt$ is specified.
Examples Open "c:\MyFile.Txt" for input as 1
Or,
input #2, Name$, age, address$
InputBox$ function
Displays a dialog box containing a prompt.
324
Creating Reports
InStr function
Parameters
A string expression containing the text to be shown in the dialog box.
The length of prompt$ is restricted to 255 characters. This figure is
approximate and depends on the width of the characters used. Note that
a carriage return and a line-feed character must be included in prompt$
if a multiple-line prompt is used.
title$,default$ The caption that appears in the dialog boxs title bar. Default$ is the
string expression that is shown in the edit box as the default response. If
either of these arguments is omitted, nothing is displayed.
xpos%, ypos%
Numeric expressions, specified in dialog box units, that determine the
position of the dialog box. Xpos% determines the horizontal distance
between the left edge of the screen and the left border of the dialog box.
Ypos% determines the horizontal distance from the top of the screen to
the dialog boxs upper edge. If these arguments are not entered, the
dialog box is centered roughly one third of the way down the screen. A
horizontal dialog box unit is 1/4 of the average character width in the
system font; a vertical dialog box unit is 1/8 of the height of a character
in the system font.
prompt$
If you wish to specify the dialog boxs position, you must enter both of
these arguments. If you enter one without the other, the default
positioning is set.
Returns After the user presses Enter, or selects the OK button, InputBox$ returns the
text contained in the input box. If the user selects Cancel, the InputBox$ function returns
a null string.
Comments Once the user has entered text, or made the button choice being prompted
for, the contents of the box are returned.
Example The following example should appear in your code on one line.
Street$=InputBox$("Enter Street Name","MyTitle","Default Exp",15,15)
InStr function
Finds the occurrence of a substring in a string. The InStr function can be used only as a
function.
325
Int function
Parameters
position%
string$
substring$
Indicates the index of the character within string$ where the search should
start. If not specified, the search starts at the beginning of the string
(equivalent to a position% of 1).
The string being searched.
The string being looked for.
Example The following starts at the first character, searches for JR. in the field
Last_Name from the Employee table.
Instr(1,"Employee.Last_Name","JR.")
Int function
Returns the integer portion of a number. Can be used only as a function.
Kill statement
Deletes files from disk.
326
Creating Reports
LBound function
Parameters
A string expression that specifies a valid DOS file specification. This
specification can contain paths and wildcards.
filespec$
Comments Kill deletes files only, not directories. Use the RmDir function to delete
directories.
LBound function
Declares the number that represents the first element of an array. Can be used only as a
function.
Returns The lower bound of the subscript range for the specified dimension of the
arrayVariable.
Comments The dimensions of an array are numbered starting with 1. If the dimension
is not specified, 1 is used as a default.
LBound can be used with UBound to determine the length of an array.
Example
'Start employee array at element 5
LBound (Employee, 5)
LCase$ function
Converts the characters in a string to lower case. Can be used only as a function.
Returns A copy of the source string, with all upper-case letters converted to lower
case.
327
Left$ function
Comments The translation is based on the country specified in the Windows Control
Panel.
Left$ function
Returns the left n characters of a string. It can be used only as a function.
Returns A string of a specified length copied from the beginning of the source string.
The dollar sign ($) in the function name is optional. If specified the return type is string.
If omitted the function typically returns a variant of vartype 8 (string). If the value of
expression is null a variant of vartype 1 (null) is returned.
Comments If the length of string$ is less than length%, Left$ returns the whole string.
Left$ accepts expressions of type string and any type of expression including numeric
values and converts the input value to a string.
Len function
Returns the length of a string or the number of bytes used to store a non-string value.
Can be used only as a function.
Syntax
Len ( string$ )
Len ( non-string )
Parameters
string$,non-string If the argument is a string, the number of characters in the string is
returned; otherwise, the length of the built-in datatype or userdefined type is returned.
328
Creating Reports
Comments The argument can be of any type. If the argument is a string, the number of
characters in the string is returned. If the argument is a variant variable the number of
bytes required to represent its value as a string is returned. If not, the length of the builtin datatype or user-defined type is returned.
Example The following example returns a value of 8.
Length_Var = Len ("Thursday")
Used to assign to a numeric, string or record variable. You can also use the Let
statement to assign to a record field or to an element of an array.
Comments You can also use this statement to assign to a record field or to an element
of an array. When assigning a value to a numeric or string variable, standard conversion
rules apply.
Example
Let A =1
Let Name$ = "John"
Syntax
Line Input [#] filenumber%, variable$
Line Input [prompt$,] variables
329
ListBox statement
Parameters
Line Input [#]
filenumber%
prompt$
variable$
The Line Input # statement reads a line from a sequential file into a
string variable.
An integer expression identifying the open file from which to read. This
is the number used in the Open statement to open the file.
An optional string that can be used to prompt for keyboard input.
A string variables into which the line from the input file is read.
Comments If filenumber is not specified, the user is prompted for keyboard input
with a question mark (?) unless prompt$ is specified.
Example Line Input #1, A$
ListBox statement
Used to create a list of choices.
dx, dy
text$
.field
Give the coordinates that the upper left corner of the list box, relative to the
upper left corner of the dialog box. The x argument is measured in 1/4
system-font character-width units. The y argument is measured in 1/8
system-font character-width units. (See Begin Dialog ... End Dialog
statement on page 293.)
Specify the width and height of the list box.
A string containing the selections for the list box. This string must be defined,
using a Dim statement, before the Begin Dialog statement is executed.
The name of the dialog-record field that holds the selection made from the list
box. When the user selects OK (or selects the customized button created using
the Button statement), a number representing the selections position in the
text$ string is recorded in the field designated by the .field argument. The
numbers begin at 0. If no item is selected, it is 1.
Comments The ListBox statement can be used only between a Begin Dialog and an
End Dialog statement.
When syntax A is used, the text$ argument is a string containing the selections for the
list box. This string must be defined, using a Dim statement, before the Begin Dialog
statement is executed. Where dimname is the name of a String variable defined in a Dim
statement, listchoice is the text that appears as a selection in the list box, and Chr$(9) is
the function call that produces a tab character. Note that multiple selections can be
specified in text$ by separating the list choices with tab characters, as shown above.
330
Creating Reports
Lof function
Example
The arguments in the text$ string are entered as shown in the following
example.
dimname =
"listchoice"+Chr$(9)+"listchoice"+Chr$(9)
+"listchoice"+Chr$(9)... ,.Selection_Holder
Lof function
Determines the length of a file in bytes. It can be used only as a function.
An integer expression identifying the open file from which the file length
is read.
Log function
Determines the natural logarithm of an expression. Can be used only as a function.
LTrim$ function
Returns a copy of the source string with all leading characters removed.
Syntax
LTrim$ ( string$ )
331
Mid statement
Parameters
string$
Returns A copy of the source string, with all leading space characters removed. The
dollar sign ($) in the function name is optional. If specified the return type is string. If
omitted the function typically returns a variant of vartype 8 (string). If the value of
expression is null a variant of vartype 1 (null) is returned.
Comments LTrim$ accepts expressions of type string and any type of expression
including numeric values and converts the input value to a string.
Example The following example results in October 7.
LTrim$(" October 7")
Mid statement
Replaces part of a string with another string.
Example
A$ = "One rotten day"
Mid$ (A$, 5, 6) = "Happy"
Will leave A$ equal to "One happy day"
Mid$ function
Returns a substring of a specified length% from a source expression, starting with the
character at the specified position%. Can be used only as a function.
332
Creating Reports
MkDir
Returns A substring of a specified length% from a source string$, starting with the
character at the specified position%.
The dollar sign ($) in the function name is optional. If specified the return type is string.
If omitted the function typically returns a variant of vartype 8 (string). If the value of
expression is null a variant of vartype 1 (null) is returned.
Comments If the length% argument is left out, or if there are fewer characters in a
string than specified in length%, then Mid$ returns all the characters from the position%
to the end of the string. If position% is larger than the number of characters in the
indicated string$, then Mid$ returns a null string.
The index of the first character in a string is 1.
To modify a portion of a string value, see Mid statement on page 332.
Example
MkDir
Makes a new directory.
The drive argument is optional. If omitted, MkDir makes a new directory on the current
drive. The directory argument is a directory name.
Example The following example creates a directory called 2ndQrt under the
RptSmith directory.
MkDir "c:\RptSmith\2ndQrtr"
333
Msgbox function
Msgbox function
Displays a message in a dialog box. It can be used only as a function.
caption$
Group 3: Defaults
0
First button
256 Second button
512 Third button
Appears on the message dialog box. Caption% is a string expression that
appears in the dialog boxs title bar.
Retry
Cancel
Ignore
Abort
Yes
Comments The message displayed must be no more than 1024 characters long. A
message string greater than 255 characters without intervening spaces is truncated after
the 255th character. Once the user has selected a pushbutton, MsgBox returns a value
indicating the users choice.
334
Creating Reports
Msgbox statement
Msgbox statement
Displays a message in a dialog box.
Governs the icons and buttons that are displayed in the dialog box. This
argument is the sum of values describing the number and type of radio
buttons that will appear, the icon style, and the default button. One
selection should be made from each group. If type% is omitted, a single OK
button appears.
Group 1: Buttons
0 OK only
1 OK, Cancel
2 Abort, Retry, Ignore
3 Yes, No, Cancel
4 Yes, No
5 Retry, Cancel
Group 2: Icons
16 Critical Message (STOP)
32 Warning Query (?)
48 Warning Message (!)
64 Information Message (i)
caption$
Group 3: Defaults
0
First button
256 Second button
512 Third button
A string expression that appears in the dialog boxs title bar.
335
Name statement
Name statement
Renames a file. It can also be used to move a file from one directory to another.
Comments A path can be part of the filename$. If the paths are different, the file is
moved to the new directory.
If the file oldfilename$ is open, Basic generates an error message. A file must be closed
in order to be renamed. If the file newfilename$ already exists, Basic generates an error
message.
$NoCStrings metacommand
Tells the compiler to treat a backslash inside a string as a normal character. This is the
default.
Syntax
$NocStrings
Comments You can use the $CStrings metacommand to tell the compiler to treat a
backslash character inside of a string as an escape character.
Example '$NocStrings
Oct$ function
Returns an octal representation of a number. Can be used only as a function.
336
Creating Reports
OkButton statement
OkButton statement
Determines the position and size of an OK button.
Set the position of the OK button relative to the upper left corner of the dialog
box.
Set the width and height of the button.
An optional identifier used by the dialog statements that act on this. A dy
value of 14 typically accommodates text in the system font.
Comments The OkButton statement can be used only between a Begin Dialog and an
End Dialog statement.
Example OkButton 10,10,90,20
On Error statement
Enables an error-handling routine, specifying the location of that routine within
procedure.
Resume Next
GoTo 0
337
Open statement
Open statement
Enables I/O to a file or a device.
filenumber%
reclen
338
Creating Reports
OptionButton statement
The Option Base statement is not allowed inside a procedure, and must precede any use
of arrays in the module. Only one Option Base statement is allowed per module.
Example
'All arrays start at element
Option Base 5
OptionButton statement
Used to define the position and text associated with an option button. There must be at
least two Option Button statements. They are used in conjunction with the
OptionGroup statement.
Set the position of the button relative to the upper left corner of the dialog box.
Set the width and height of the button. A dy value of 12 typically
accommodates text in the system font.
Contains the caption that appears to the right of the option button icon. If the
width of this string is greater than dx, trailing characters are truncated.
Comments The OptionButton statements can be used only between a Begin Dialog
and an End Dialog statement.
If you want to include underlined characters so that the option selection can be made
from the keyboard, the character must be preceded with an ampersand (&).
OptionGroup statement
Used in conjunction with OptionButton statements to set up a series of related options.
Syntax
OptionGroup .field
Parameters
.field
The name of the dialog box field that contains the index of the selected options
button.
Comments The OptionGroup statement begins definition of the option buttons and
establishes the dialog-record field that contains the current option selection. .Field
contains a value 0 when the choice associated with the first OptionButton statement is
selected, a value of 1 when the choice associated with the second OptionButton
statement is chosen, and so on.
Appendix B, Macro reference
339
Print statement
The OptionGroup statement can be used only between a Begin Dialog and an End
Dialog statement.
Print statement
Outputs data to the specified filenumber%.
Randomize statement
Seeds the random number generator.
340
Creating Reports
ReDim statement
ReDim statement
Changes the upper and lower bounds of a dynamic arrays dimensions.
Syntax ReDim [Preserve] variableName ( subscriptRange, ... ) [As[ New] type] ,...
Parameters
variableName
subscriptRange
An array to re-dimension.
New dimensions.
Comments Memory for the dynamic array is reallocated to support the specified
dimensions, and the array elements are reinitialized. ReDim can not be used at the
module levelit must be used inside of a procedure.
The Preserve option is used to change the last dimension in the array while maintaining
its contents. If Preserve is not specified the contents of the array will be reinitialized.
Numbers are set to zero. String variants are set to empty.
A dynamic array is normally created by using Dim to declare an array without a
specified subscriptRange. The maximum number of dimensions for a dynamic array
created in this fashion is 8. If you need more than 8 dimensions, you can use the ReDim
statement inside of a procedure to declare an array which has not previously been
declared using Dim or Global. In this case, the maximum number of dimensions
allowed is 60.
The available data types for arrays are: numbers, strings, and records. Arrays of arrays,
dialog box records, and ADTs are not supported.
If the As clause is not used, the type of the variable can be specified by using a type
character as a suffix to the name. The two different type-specification methods can be
intermixed in a single ReDim statement (although not on the same variable).
The ReDim statement cannot be used to change the number of dimensions of a dynamic
array once the array has been given dimensions. It can change only the upper and lower
bounds of the dimensions of the array. The LBound and UBound functions can be used
to query the current bounds of an array variables dimensions.
Do not use the ReDim statement on an array in a procedure that has received a reference
to an element in the array in an argument. The result is unpredictable.
The subscriptRange is of the format:
[ startSubscript To ] endSubscript
If startSubscript is not specified, 0 is used as the default. The Option Base statement can
be used to change the default.
341
Rem statement
Example
'dimension to a 2x13 array
Redim DynaList (3 to 5, 7 to 20)
Rem statement
Inserts a comment in a Basic program. Everything from Rem to the end of the line is
ignored.
Reset statement
Closes all disk files that are open, and writes any data still remaining in the operating
system buffers to disk.
Syntax Reset
Example Reset
Resume statement
Halts an error-handling routine.
Syntax
Resume Next
Resume label
Resume [ 0 ]
342
Creating Reports
Right$ function
Parameters
When used, control is passed to the statement which immediately follows
the statement in which the error occurred.
Resume label When used, control is passed to the statement which immediately follows
the specified label.
Resume [ 0 ] When used, control is passed to the statement in which the error occurred.
Resume Next
Comments The location of the error handler which has caught the error determines
where execution resumes. If an error is trapped in the same procedure as the error
handler, program execution resumes with the statement that caused the error. If an error
is located in a different procedure from the error handler, program control reverts to the
statement that last called out the procedure containing the error handler.
Example The following example goes to the Reset Procedure after an error.
Resume Reset_Proc
Right$ function
Returns a string of a specified length.
Returns A string of a specified length copied from the right-most length characters
from the string$.
Comments If the length of string$ is less than length%, Right$ returns the whole
string.
Example
Return_Var$ = Right$("c:\RptSmith",8")
RmDir statement
Removes a directory.
343
Rnd function
Parameters
A string expression identifying the directory to remove.
pathname$
The drive argument is optional. The directory argument is a directory name. The
directory to be removed must be empty, except for the working ( . ) and parent (...)
directories.
Example
'Remove a temporary directory under ReportSmith
RmDir "c:\RptSmith\Temp"
Rnd function
Generates a random number between 0 and 1.
<0
>0
=0
Omitted
x = (RND*100) +1
RTrim$ function
Removes trailing spaces.
344
Creating Reports
Seek function
Parameters
string$
Returns A copy of the source string, with all trailing space characters removed.
Example
Seek function
Determines the current position in a file.
Returns The current file position for the file specified by filenumber%. For files
opened in Random mode, Seek returns the number of the next record to be read or
written. For all other modes, Seek returns the file offset for the next operation. The first
byte in the file is at offset 1, the second byte is at offset 2, and so on. The return value is a
Long.
Comments
Seek statement
Sets the position within a file for the next read or write.
Syntax
Parameters
filenumber%
position&
Comments If you write to a file after seeking beyond the end of the file, the file length
is extended. Basic returns an error message if a Seek operation is attempted which
specifies a negative or zero position.
Example The following example positions the cursor to Record 50.
Seek #1, 50
345
Syntax
Select Case testexpression
[Case expressionlist
[statement_block] ]
[Case expressionlist
[statement_block] ]
.
.
.
[Case Else
[statement_block] ]
End Select
Parameters
testexpression
Example
Select Case price
Case is > 100
MsgBox "Too expensive"
Case 50 to 99
MsgBox "Good price"
Case is < 50
MsgBox "Sale!"
End Select
346
Creating Reports
SetField$ function
SetField$ function
Sets a value in a list of values whose fields are all separated by the same character.
Returns A string created from a copy of the source string with a substring replaced.
Comments The source string is considered to be divided into fields by separator
characters. Multiple separator characters can be specified. The fields are numbered
starting with one.
If field_number is greater than the number of fields in the string, the returned string is
extended with separator characters to produce a string with the proper number of fields.
If more than one separator character was specified, the first one is used as the separator
character.
It is legal for the new field value to be a different size than the old field value.
Sgn function
Determines the sign of a number. Can be used only as a function.
Returns A value indicating the sign of the numeric expression. The value that the Sgn
function returns depends on the sign of the expression:
For numeric-expressions > 0, Sgn (numeric-expression) returns 1.
For numeric-expressions = 0, Sgn (numeric-expression) returns 0.
For numeric-expressions < 0, Sgn (numeric-expression) returns 1.
347
Shell function
Shell function
Runs an executable program.
Syntax
Parameters
commandstring$
windowstyle%
The name of the program to execute. It can be the name of any valid
.COM, .EXE., .BAT, or .PIF file. Arguments or command line switches
can also be included.
The style of the window in which the program is to be executed. It can
be one of the following:
1Normal window with focus
2Minimized with focus
3Maximized with focus
4Normal window without focus
5Minimized without focus
If windowstyle% is not specified, the default of windowstyle% = 1 is
assumed (normal window with focus).
Sin function
Calculates the sine of an angle specified in radians. Can be used only as a function.
Returns
The sine of an angle. The return value is between 1 and 1. The return value
is single-precision if the angle is an integer or single-precision value, double precision
for a long or double-precision value.
348
Creating Reports
Space$ function
Comments The angle is specified in radians, and can be either positive or negative.
Example The following calculates the sin of 60 degrees.
Value = sin ((60x3.1415)/180)
Space$ function
Generates a string with the given number of spaces. Can be used only as a function.
Syntax
Space$( numeric-expression )
Parameters
numeric-expression
Sqr function
Calculates the square root of a number. Can be used only as a function.
Stop statement
Halts program execution.
Syntax Stop
349
Str$ function
Str$ function
Converts a number to a string. Can be used only as a function.
String$ function
Creates a string of the given character repeated the given number of times. Can be used
only as a function.
Syntax
String$( numeric-expression, charcode% )
String$ (numeric-expression, string-expression$ )
Parameters
numeric-expression
charcode%
string-expression$
350
Creating Reports
Returns Returns to the caller when the End Sub statement is reached or when an Exit
Sub statement is executed.
Example
Sub Hello()
MsgBox "Hello"
End Sub
Tan function
Returns the tangent of an angle. Can be used only as a function.
Syntax
Tan( angle )
351
Text statement
Parameters
The angle, in radians, for which to calculate the tangent.
angle
Returns The tangent of an angle. The return value is single-precision if the angle is an
integer or single-precision value, or double precision for a long or double-precision
value. The angle is specified in radians, and can be either positive or negative.
Text statement
Sets up line(s) of text in a dialog box.
Set the position of the upper left hand corner of the text area relative to the
upper left corner of the dialog box.
Set the width and height of the text area.
Contains the text that appears to the right of the position designated by the x/
y coordinates. If the width of this string is greater than dx, the spillover
characters wrap to the next line. This continues as long as the height of the
text area established by dy is not exceeded. Excess characters are truncated.
Comments The Text statement can be used only between a Begin Dialog and an End
Dialog statement.
By preceding an underlined character in text$ with an ampersand (&), you enable a user
to press the underlined character on the keyboard and position the cursor in the combo
or text box defined in the statement immediately following the Text statement.
TextBox statement
Creates a box, used within a dialog box, in which the user can enter and edit text.
352
Creating Reports
Parameters
x, y
dx, dy
.field
Set the position of the upper left hand corner of the text box relative to the
upper left corner of the dialog box.
Set the width and height of the text area. A dy value of 12 will usually
accommodate text in the system font.
The name of the dialog record field that will hold the any text entered in the
text box. When the user selects the OK button, or any pushbutton other than
cancel, the text string entered in the text box is recorded in the field.
Comments The TextBox statement can only be used between a Begin Dialog and an
End Dialog statement.
Example Textbox 10,10,130,20 .MyData
Time$ function
Gets the current system time as a string. Can be used only as a function.
Syntax Time$
Returns A string representing the current time.
Comments
string is
"hh:mm:ss"
where hh is the hour, mm is the minutes, and ss is the seconds. The hour is specified in
military style and ranges from 0 to 23.
Timer function
Returns the number of seconds that have elapsed since midnight. Can be used only as a
function.
Syntax Timer
Returns The number of seconds that have elapsed since midnight.
Comments The Timer function can be used in conjunction with the Randomize
statement to seed the random number generator.
Example
Use the number of seconds since midnight to seed the random number
generator.
Randomize Timer
353
Type statement
Declares a user-defined type which can then be used in the DIM statement to declare a
record variable. Such a user-defined type is also sometimes referred to as a record type
or a structure type.
Syntax
Type userType
field1 As type1
field2 As type2
End Type
Parameters
Fieldn
Typen
Comments Between the Type and Type End you may define a number of elements
known as fields. Each field can be a string (either dynamic or fixed), number (integer,
long, single or double), or a previously-defined record type; it cannot be an array.
However, arrays of records are allowed.
The Type statement is not valid inside a procedure definition.
To access the fields of a record, use notation of the form:
recordName.fieldName.
Example
Type car
engine size as integer
number of cylinders as integer
color as string
make as string
model as string
End Type
Dim Honda as car
Honda.Color = "red"
UBound function
Determines the largest valid index for a particular dimension of an array. Can be used
only as a function.
354
Creating Reports
Returns The upper bound of the subscript range for the specified dimension of the
arrayVariable.
Comments The dimensions of an array are numbered starting with 1. If the dimension
is not specified, 1 is used as a default.
LBound can be used with UBound to determine the length of an array.
Example The following example sets the last element of this array to an end marker.
Data$ (1, UBound (Data,2)) = "*End"
UCase$ function
Converts the characters of a string to upper case. Can be used only as a function.
Returns A copy of the source string, with all lower case letters converted to upper
case. The translation is based on the country specified in the Windows Control Panel.
Val function
Converts a string to a number. Can be used only as a function.
Returns Returns a numeric value corresponding to the first number found in the
specified string. Spaces in the source string are ignored. If no number is found, 0 is
returned.
355
Example The following example turns a string into a number and sets the number
variable to that result.
Num_var = Val("123.4")
Syntax
While condition
statementblock
Wend
Comments The condition is tested, and if TRUE, the statement block is executed. This
process is repeated until the condition becomes FALSE.
The While statement is included in the macro language for compatibility with older
versions of Basic. The Do statement is a more general and powerful flow control
statement.
Example
While InputBox$ ("Type the secret word") <> "Secret"
MsgBox "That's not it"
Wend
Write statement
Writes data to a sequential file. The file must be opened in output or append mode.
356
Creating Reports
Index
A
Abs function 291
Access 12
ActiveTitle$() function 234
AddGroup method 266
AddMenu command 236
AddSort method 267
AddSummary method 268
AddTable method 269
aliases
column aliases 43
field aliases in crosstabs 152
aligning
Align Toolbox 111
characters 95
objects 110117
text 117118
AllDataBases$ property 284
AllOwners$ property 285
AllTables$ property 285
application events 225228
Asc function 291
Assert statement 292
assigning aliases 203
assigning column aliases 43
Atn function 292
Avery label styles 91
B
BASIC conventions
application data types 224
arrays 223
conversions 224
dialog box records 224
numbers 223
records 223
strings 223
trappable errors 225
Beep statement 293
Best Fit feature 96
bitmaps (.BMP files) 125
Btrieve 13
building a report
adding
graphs 127
tables 39
without using a join 41
choosing
columns 41
assigning aliases 43
visually 43
C
$CStrings metacommand 303
Call statement 295
calling applications from
ReportSmith 213
CancelButton statement 296
Caption statement 297
CDbl function 297
character sizing 94
ChDir statement 297
ChDrive statement 298
CheckBox statement 298
choosing
columns
for use in query only 43
value only 43
defined connections 39
parts of a report 85
records 59
CInt function 299
CLng function 300
Close statement 300
CloseReport command 236
CloseRS command 237
columns
adjusting width 96
choosing 41
357
D
data
bringing into a report 37
copying 219
grouping 53
manipulating in a report 51
sorting 52
data dictionary
adding tables 201
assigning aliases 203
creating a view 199
headings 205
overview 198
tutorial 207
using from ReportSmith 206
workplace 199
data sources
connecting to 9
diagram 9
PC through IDAPI 1112
PC through ODBC 1224
358
Creating Reports
macro-derived 68
sample macro derived
field 69
derived fields
creating 66
macro-derived fields 66
SQL-derived fields 66
uses for 67
DerivedField command 243
Dialog boxes
Macro Commands 162
Dialog statement 307
Dim statement 307
Dir$ function 309
Disconnect method 271
Do...While statement 310
DoEvents command 243
drawing objects 118
Dynamic Data Access
options 187
Dynamic Data Exchange
(DDE) 211
application names 212
conversations 212
items 213
synchronization 214
topics 213
E
EnableIcon command 244
EnableMenu command 244
EnableRMenu command 245
entering text 100
Environ$ function 311
Eof function 312
Erl function 312
Err function 313
Err statement 313
Error statement 313
Error$ function 314
Error$ property 285
Excel 17
ExecSQL command 246
ExecuteMenu command 245
Exit statement 314
Exp function 315
F
field labels 106
formatting 97
Field$ command 247
Field$ method 271
FieldFont command 248
fields
time formats 98
using
page setup 89
the grid 93
the ribbon 52
wallpaper 92
FoxPro 19
FreeFile function 318
Function...End Function
statement 318
G
GetAllField$ method 272
GetAllFields$ method 249
GetColumnAlias$ method 272
GetDataSources$ method 249,
273
GetDdeItem function 250
GetField$ function 319
GetFieldList$ method 273
GetFieldName$ function 250
GetGroup$ method 274
GetIncludePath$ command 250
GetNext command 250
GetPrevious command 251
GetRandom command 251
GetRecordLimit function 252
GetRepVar command 252
GetSort$ method 274
GetSQL command 252
GetSQL$ method 275
GetSummary$ method 275
GetTable$ method 275
GetTableAlias$ method 276
GetTableLink$ method 276
Global statement 320
GoTo statement 320
graphics
bitmaps (.BMP files) 125
pointing to files 189
graphs
converting a columnar
report 127
creating 127
deleting 128
modifying 128
positioning 128
grid 93
GroupBox statement 321
grouping 53
after loading data 53
crosstabs 148
database grouping 55
inserting a header or
footer 57
on the server 55
report grouping 53
suppressing fields 55
H
headers and footers
inserting 57
list of types 107
placing items in 107
headings, adding to data
dictionary 205
Hex$ function 321
hiding a report section 109
hWin_Active() function 253
hWin_RS() function 253
I
$Include metacommand 323
icons, running reports from 191
Id property 286
If...Then...Else statement 322
IncludeFields$ method 276
Informix 24
Ingres 25
Input # statement 323
Input$ function 323
InputBox$ function 324
installation
files installed 3
InStr function 325
Int function 326
InterBase 24
Introduction to macros 159
IsMenuChecked command 253
IsMenuEnabled command 254
J
joining tables 39
before loading into a
report 40
modifying links 40
removing a join 41
visually 39
K
Kill statement 326
KillMenu command 255
L
labels
Avery label codes 91
choosing a report type 32
Index
359
field 97
setting up 91
LastLoaded$() function 255
LBound function 327
LCase$ function 327
Left$ function 328
Len function 328
Let Assignment statement 329
Line Input # statement 329
linking
macros to events 163
objects to a report 218
removing a join 41
tables 39, 41
ListBox statement 330
Load method 277
LoadReport command 256
Lof function 331
Log function 331
LTrim$ function 331
M
Macro Commands dialog
box 162
Macro derived fields 68
sample creation of 69
Macros
creating (simple) 162
creating and working
with 162
introduction 159
refreshing a temporary
table 180
macros 221
advanced concepts 165173
application events 221, 225
228
arguments 166
command reference 233
DataSet control 171
functions and statements 166
linking to an event 163
loading 165
object reference 221
report events 230
sample macros 173180
saving as a .MAC file 164
scoping 160
uses for 160
using Dynamic Data
Exchange 169
margins
setting 89, 90
master/detail report 33
Menu commands
Tools|Derived Fields 69
360
Creating Reports
Tools|Macro 162
menus, customizing 189
Mid statement 332
Mid$ function 332
MkDir statement 333
modes
column 86
form 86
moving
columns 86, 96
column mode 96
data using the grid 93
objects 8588, 219
Msgbox function 334
Msgbox statement 335
N
$NoCStrings metacommand 336
Name statement 336
Name$ property 286
null values 99
number formats 97
O
objects
canceling links 218
creating 217
drawing 118
editing links 218
embedding 217
linking and embedding 215
linking to a report 218
moving 219
OLE 2.0 215
Oct$ function 336
OKButton statement 337
OLE objects 215
On Error statement 337
Open statement 338
Option Base statement 338
OptionButton statement 339
OptionGroup statement 339
options
choosing font lists 188
customizing 185
data access options 187
for columns 42
listing items
alphabetically 188
pointing to graphics 189
printer 182
selecting measurements 188
start-up options 187
storing connections 188
ORACLE 26
P
page numbers, inserting 110
page setup 89
paginating a report 110
repaginate button 108
paper size, setting 90
Paradox 12, 20
parts of a report 51
point size 94
Print statement 340
printing
canceling 183
choosing a printer 182
current page only 182
entire report 183
options 182
paginating a report 110
paper size 90
range of pages 183
setting up the printer 181
PrintReport command 257
R
Randomize statement 340
Recalc method 277
Recalc statement 257
Record property 286
RecordCount command 258
RecordCount property 287
records, choosing 59
ReDim statement 341
Refreshing a temporary
table 180
Rem statement 342
RemoveGroup method 277
RemoveSort method 278
RemoveSummary method 278
RemoveTable method 279
RemoveTableLink method 279
repaginate button 108
ReplaceTable method 280
report events 230
report query 37
Report Query dialog boxes 37
Report Query Files (.RQF) 83
report styles
applying 120
creating 121
default 121
deleting 123
extracting 123
modifying 122
using 120
report types
choosing 34
columnar 31
crosstabs 32
custom 33
form 32
labels 32
master/detail 33
summary-only 34
report variables
changing values 75
creating 72
data types used in 73
entry types used in 73
inserting 104
modifying 75
samples of 7578
ReportBasic
uses for 160
ReportBasic Macro options
in macro-derived fields 69
Reset statement 342
resizing
crosstab rows and
columns 148
field and record height 108
objects 88
Resume statement 342
ResumeEvent command 258
Rgb command 259
ribbon 52, 95
Right$ function 343
RmDir statement 343
Rnd function 344
rows
form mode 86
in crosstabs 142
inverting in crosstabs 151
selecting 87
RTrim$ function 344
rulers 188
RunMacro command 168, 259
running a report from an
icon 191
runtime
sample DDE code 195
runtime viewer
installing 194
setting up 193
uses for 193
S
sample data dictionary 207
Sample macros
refreshing a temporary
table 180
samples
locations 4
Save method 280
scoping macros 160
Seek function 345
Seek statement 345
Select Case statement 346
selecting
a printer 182
a report body 88
blocks of columns 42
field labels 85
headers and footers 88
multiple columns 87
rows 87
text 88
selection criteria 58
selection criteria, specifying 58
Selection$ property 287
SelectReport statement 260
sending menu commands 214
SetColumnAlias method 280
SetDataFilter statement 260
SetDdeItem statement 261
SetField$ function 347
SetFromActive method 281
SetFromLoading method 281
SetIncludePath command 261
SetRecordLimit statement 262
SetRepVar command 260
SetSQL command 262
SetTableAlias method 282
SetTableLink method 282
setting
margins 89
paper size 90
SetUserSQL method 283
Sgn function 347
Shell function 348
ShowRS command 262
Sin function 348
Softbridge Basic Language
(SBL) 159
sorting data
in crosstabs 150
in reports 52
Space$ function 349
SQL
browsing tables and
columns 48
clearing the Browser 49
converting to 46
definition of 45
entering formulas 48
T
Table$ property 287
table-driven values 78
tables
adding 39
adding to a data
dictionary 201
creating temporary tables 82
joining 39
number of links between 40
renaming 204
Tan function 351
temporary tables 8283
Teradata 29
TestSelection$ method 284
Text 22
text
editing 100
entering and formatting 100
selecting 88
Text statement 352
TextBox statement 352
time 98
Time$ function 353
Timer function 353
toolbar 52
customizing 189
displaying 52
Index
361
Tools|Derived Fields 69
Tools|Macro 162
topics in this guide 1
TotalPages function 265
Type statement 354
U
UBound function 354
UCase$ function 355
Unify 30
V
Val function 355
values in crosstabs 143
view
choosing a view parent 201
copying 206
creating 199
visual joins 39
W
While...Wend syntax 356
width, adjusting columns 96
Write statement 356
Z
zero values 99
362
Creating Reports
Creating Reports
VERSION 2.5
Borland
ReportSmith
Borland International, Inc., 100 Borland Way
P.O. Box 660001, Scotts Valley, CA 95067-0001
Redistributable files
You can redistribute the following files in accordance with the terms of Borlands No Nonsense License Statement:
RED110.DLL
DRVACCSS.HLP
BTRV110.DLL
DRVBTRV.HLP
RCS0.RST-RCS8.RST
RSCTSFMT.RST
DRVDBASE.HLP
XBS110.DLL
RS_DBLIB.DLL
XLSISAM.DLL
DRVEXCEL.HLP
DRVFOX.HLP
RS_GUP.DLL
IDAPI01.DLL
IDAPICFG.EXE
IDASCI01.DLL
IDBAT01.DLL
IDDBAS01.DLL
IDODBC01.DLL
IDPDX01.DLL
IDQRY01.DLL
IDR10009.DLL
ILD01.DLL
IDAPI.DNF
IDAPICFG.HLP
RS_INGR.DLL
B4RPT.MAC
DONDFMT.MAC
DATE.MAC
DISABLE.MAC
ENABLE.MAC
GREETING.MAC
ID2NAME.MAC
LOADREP.MAC
LOADREPS.MAC
RECNO.MAC
THETIME.MAC
CTL3D.DLL
MSJETDSP.DLL
ODBC.DLL
ODBCADM.EXE
ODBCINST.DLL
SIMADMIN.DLL
SIMBA.DLL
ODBCINST.HLP
COPOBJ.DLL
OLE2.DLL
OLE2CONV.DLL
OLE2DISP.DLL
OLE2NLS.DLL
OLE2PROX.DLL
STORAGE.DLL
TYPELIB.DLL
OLE2.REG
STDOLE.TLD
RS_ORA6.DLL
RS_ORA7.DLL
BIBAS04.DLL
BIFLT04.DLL
BIMDS04.DLL
BIUTL04.DL
ODBCCURS.DLL
PXENGCFG.EXE
PXENGWIN.DLL
BIPDX04.DLL
BIPDX04.HLP
QEBI.LIC
README.TXT
BC30RTL.DLL
DATALIB2.DLL
DLOLE2.DLL
IMAGEMAN.DLL
IMGPCX.DIL
IMGTIFF.DIL
RSSQLIF.TXT
RS_FMT.DLL
RS_IDABP.DLL
RS_ODBC.DLL
RS_OGLWL.DLL
RS_OLE2C.DLL
RS_OLE2U.DLL
RS_OWL31.DLL
RS_SIFUT.DLL
RS_SQLIF.DLL
RS_SYS.DLL
RS_SYS.DLL
RS_TBP1.DLL
RS_TBP2.DLL
RS_TCL31.DLL
RS_TKRIB.DLL
RS_DFWEN.DLL
RS_TKSTB.DLL
RS_TKTB.DLL
RS_UTIL.DLL
SSMRTHEAP.DLL
REPVAR.FRM
REPVAR.MAK
RSR_CTAB.DLL
RSR_DBAC.DLL
RSR_DBUI.DLL
RSR_MAIN.DLL
RSR_RPT.DLL
RSR_RUTL.DLL
RSR_XPRT.DLL
RSTEST.FRM
RSTEST.FRM
RS_RUN.EXE
RS_RUN.HLP
RUN_TEST.EXE
RS_SQLIF.INI
CTL3DV2.DLL
TXTISAM.DLL
DRVTEXT.HLP
Borland may have patents and/or pending patent applications covering subject matter in this document. The
furnishing of this document does not give you any license to these patents.
COPYRIGHT 1995 Borland International. All rights reserved. All Borland product names are trademarks or
registered trademarks of Borland International, Inc. Other brand and product names are trademarks or registered
trademarks of their respective holders.
Printed in the U.S.A.
1E0R195
9596979899-9 8 7 6 5 4 3 2 1
W1
Contents
Introduction
Who should use this guide . . . . . .
Topics covered in this guide. . . . . .
What you can do with ReportSmith .
Terms, techniques, and conventions .
.
.
.
.
The keyboard . . . . . . . . . . . . .
Text . . . . . . . . . . . . . . . . . . .
Procedures . . . . . . . . . . . . . . .
Installed files . . . . . . . . . . . . .
Directory locations for files . . . . .
Sample tables, reports, and macros
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.1
.1
.2
.3
.
.
.
.
.
.
.3
.3
.3
.3
.4
.4
.
.
.
.
.
.5
.5
.7
.9
.9
InterBase . . . . . . . . . . . . . . . . . . . . . . 24
Informix . . . . . . . . . . . . . . . . . . . . . . . 24
DB2. . . . . . . . . . . . . . . . . . . . . . .
Ingres . . . . . . . . . . . . . . . . . . . . .
Hardware and software requirements. .
ORACLE . . . . . . . . . . . . . . . . . . .
Hardware and software requirements. .
ORACLE connection issues . . . . . . . .
SQL Server/Sybase . . . . . . . . . . . . .
Hardware and software requirements. .
SQL Server/Sybase connection issues. .
SQLBase . . . . . . . . . . . . . . . . . . . .
Teradata . . . . . . . . . . . . . . . . . . . .
Unify. . . . . . . . . . . . . . . . . . . . . .
Chapter 1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
25
25
25
26
26
27
28
28
29
29
29
30
Chapter 2
31
. . . . . . . . . .9
. . . . . . . . . 10
. . . . . . . . . 10
. . . . . . . . . 10
Columnar .
Crosstab . .
Form . . . .
Labels . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
31
32
32
32
dBASE . . . . . . . . . . . . . . . . . . . . . . . . 11
Paradox. . . . . . . . . . . . . . . . . . . . . . . . 12
Chapter 3
Access . . . . . . . . . . . . . . . . . . . . . . . . 12
Hardware and software requirements . . . . 12
Access connection issues . . . . . . . . . . . . 13
Btrieve . . . . . . . . . . . . . . . . . . . . . . . . 13
Hardware and software requirements . . . . 14
Btrieve connection issues . . . . . . . . . . . . 15
dBASE/xBASE . . . . . . . . . . . . . . . . . . . 15
Hardware and software requirements . . . . 16
dBASE connection issues . . . . . . . . . . . . 17
Excel . . . . . . . . . . . . . . . . . . . . . . . . . 17
Hardware and software requirements . . . . 17
Excel connection issues . . . . . . . . . . . . . 18
FoxPro . . . . . . . . . . . . . . . . . . . . . . . . 19
Hardware and software requirements . . . . 19
FoxPro connection issues . . . . . . . . . . . . 20
Paradox. . . . . . . . . . . . . . . . . . . . . . . . 20
Hardware and software requirements . . . . 21
Paradox connection issues . . . . . . . . . . . 21
Text . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Hardware and software requirements . . . . 22
37
Choosing columns . . . . . . . . . . . . . . . . . 41
Using the Table Columns dialog box . . . .
Visually . . . . . . . . . . . . . . . . . . . . .
Assigning column aliases. . . . . . . . . . .
Using direct SQL entry . . . . . . . . . . . .
What is SQL? . . . . . . . . . . . . . . . . . .
Viewing SQL text . . . . . . . . . . . . . . .
Converting a report to SQL text entry . . .
Creating a report with direct SQL entry . .
Using the Table and Column Browser. . .
Using the SQL list boxes. . . . . . . . . . .
Restrictions for SQL text entry . . . . . . .
i
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
42
43
43
44
45
45
46
47
48
49
49
Chapter 4
Manipulating data
Parts of a report .
The toolbar. . . .
The ribbon . . . .
Sorting . . . . . .
Grouping . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
51
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Formatting techniques . . . . . . . . . . . . . . . 93
51
52
52
52
53
Characters. . . . . . . . . . . . . . . . . . . .
Fonts and point sizes. . . . . . . . . . . . .
Aligning characters in columns . . . . . . .
Positioning columns. . . . . . . . . . . . . .
Field labels . . . . . . . . . . . . . . . . . . .
Numbers and dates . . . . . . . . . . . . . .
Customizing numeric fields . . . . . . . . .
Leaving null values blank . . . . . . . . . .
Report grouping . . . . . . . . . . . . . . . . . . 53
Database grouping . . . . . . . . . . . . . . . . . 55
Inserting a header or footer . . . . . . . . . . . . 57
.
.
.
.
.
.
.
.
94
94
95
96
97
97
99
99
Data fields. . . . . . . . . . . . . . . .
Derived fields. . . . . . . . . . . . . .
Report variables . . . . . . . . . . . .
System fields . . . . . . . . . . . . . .
Summary fields . . . . . . . . . . . .
Inserting field labels . . . . . . . . . .
Placing items into a header or footer
Resizing field and record height. . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.103
.104
.104
.105
.105
.106
.107
.108
Saving a report . . . . . . . . . . . . . . . . . . . 81
Creating a temporary table . . . . . . . . . . . . 82
.
.
.
.
.
. 111
.117
.117
.118
.118
Drawing . . . . . . . . . . . . . . . . . . . . . . 118
The Drawing Toolbox . . . . . . . . . . . . . . .119
Chapter 5
Formatting
.
.
.
.
.
.
.
.
85
Applying a style . . . . .
Assigning a default style
Creating a style. . . . . .
Modifying a style . . . .
Deleting a style . . . . . .
Using the Style Extractor
Fields . . . . . . . . . . . . . . . . . . . . . . . . . 86
Rows . . . . . . . . . . . . . . . . . . . . . . . . . 87
Selecting a row . . . . . . . . . . . . . . . . . 87
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.120
.121
.121
.122
.123
.123
Chapter 6
Graphs
Resizing objects . . . . . . . . . . . . . . . . . . . 88
Using Page Setup settings . . . . . . . . . . . . . 89
127
Setting margins . . . . . . . . . . . . . . . . . . . 89
Default measurements . . . . . . . . . . . . 90
ii
Chapter 7
Crosstabs
131
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
132
133
133
133
134
135
135
135
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Modular scope . . . . .
Local scope . . . . . . .
Global Scope . . . . . .
Properties and methods .
Properties. . . . . . . .
Methods . . . . . . . .
142
143
144
145
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
149
150
151
151
152
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
155
155
156
156
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.166
.166
.167
.168
.168
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.171
.172
.172
.172
.172
.173
.
.
.
.
.
.
.
.
.
.
.174
.174
.176
.176
.176
.177
.177
.178
.179
.180
181
Chapter 10
159
.
.
.
.
.
.
.
.
.
Customizing ReportSmith
.
.
.
.
.
.
Printing a report
Chapter 8
Macros
.162
.163
.164
.165
Chapter 9
.
.
.
.
.
Grouping. . . . . . . . . . . . . . . . . . . . . . 148
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Rows . . . . . . . . . . .
Values. . . . . . . . . . .
Columns . . . . . . . . .
Crosstab report options
.
.
.
.
185
. . . . . . . 159
. . . . . . . 160
. . . . . . . 160
. . . . . . . . 161
iii
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
188
188
188
189
Appendix B
Macro reference
Basic conventions .
Variable data types.
Application events.
Creation Events . .
Report Events. . . .
Data field events . .
Chapter 11
Runtime Viewer
193
Overview. . . . . . . . . . . . . . . . . . . . . . 193
Installing the Runtime Viewer . . . . . . . . . 194
Using Runtime Viewer. . . . . . . . . . . . . . 194
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
197
198
199
199
.
.
.
.
.
.
.
201
203
204
205
206
206
207
Appendix A
211
Calling ReportSmith . . . . .
Calling another application .
Sending menu commands. .
DDE synchronization . . . .
Using OLE 2.0 . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
212
212
213
213
.
.
.
.
.
213
213
214
214
215
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
ActiveTitle$ function . . . . .
AddMenu . . . . . . . . . . .
CloseReport . . . . . . . . . .
CloseRS . . . . . . . . . . . . .
Connect . . . . . . . . . . . . .
CreateDDEItem statement. .
CreateDDETopic statement .
Current . . . . . . . . . . . . .
CurrentPage function. . . . .
Date2Str. . . . . . . . . . . . .
DateField . . . . . . . . . . . .
DDEExecute . . . . . . . . . .
DDEPoke . . . . . . . . . . . .
DDERequest . . . . . . . . . .
DerivedField . . . . . . . . . .
DoEvents . . . . . . . . . . . .
EnableIcon . . . . . . . . . . .
EnableMenu . . . . . . . . . .
EnableRMenu . . . . . . . . .
ExecuteMenu . . . . . . . . .
ExecSQL . . . . . . . . . . . .
ExecuteMenu . . . . . . . . .
Field$ . . . . . . . . . . . . . .
FieldFont . . . . . . . . . . . .
FieldText . . . . . . . . . . . .
GetAllFields$ method . . . .
GetDataSources$ method . .
GetDDEItem function . . . .
GetFieldName$ function. . .
GetIncludePath$ command .
GetNext . . . . . . . . . . . . .
GetPrevious . . . . . . . . . .
GetRandom . . . . . . . . . .
Chapter 12
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.221
.222
.225
.229
.230
.232
.
.
.
.
.
.
.
.
.
.
221
iv
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
235
236
236
237
237
238
239
239
240
240
241
241
242
242
243
243
244
244
245
245
246
247
247
248
248
249
249
250
250
250
250
251
251
GetRecordLimit function . . . . . .
GetRepVar . . . . . . . . . . . . . . .
GetSQL . . . . . . . . . . . . . . . . .
hWin_Active() function . . . . . . .
hWin_RS() function. . . . . . . . . .
IsMenuChecked. . . . . . . . . . . .
IsMenuEnabled . . . . . . . . . . . .
KillMenu . . . . . . . . . . . . . . . .
LastLoaded$ function . . . . . . . .
List RepVar. . . . . . . . . . . . . . .
LoadReport . . . . . . . . . . . . . .
PrintReport. . . . . . . . . . . . . . .
Recalc statement . . . . . . . . . . .
RecordCount. . . . . . . . . . . . . .
ResumeEvent . . . . . . . . . . . . .
Rgb . . . . . . . . . . . . . . . . . . .
RunMacro . . . . . . . . . . . . . . .
SetDataFilter statement . . . . . . .
SelectReport statement. . . . . . . .
SetRepVar . . . . . . . . . . . . . . .
SetDDEItem statement. . . . . . . .
SetIncludePath command . . . . . .
SetRecordLimit statement . . . . . .
SetSQL . . . . . . . . . . . . . . . . .
ShowRS. . . . . . . . . . . . . . . . .
Str2Date . . . . . . . . . . . . . . . .
SumField . . . . . . . . . . . . . . . .
TotalPages function. . . . . . . . . .
DataSet control methods summary
AddGroup . . . . . . . . . . . . . . .
AddSort . . . . . . . . . . . . . . . .
AddSummary . . . . . . . . . . . . .
AddTable . . . . . . . . . . . . . . . .
Connect. . . . . . . . . . . . . . . . .
Disconnect . . . . . . . . . . . . . . .
Field$ . . . . . . . . . . . . . . . . . .
GetAllFields$ . . . . . . . . . . . . .
GetColumnAlias$. . . . . . . . . . .
GetDataSources$ . . . . . . . . . . .
GetFieldList$. . . . . . . . . . . . . .
GetGroup$ . . . . . . . . . . . . . . .
GetSort$ . . . . . . . . . . . . . . . .
GetSummary$ . . . . . . . . . . . . .
GetSQL$ . . . . . . . . . . . . . . . .
GetTable$. . . . . . . . . . . . . . . .
GetTableAlias$ . . . . . . . . . . . .
GetTableLink$ . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
IncludeFields$ . . .
Load . . . . . . . . .
Recalc . . . . . . . .
RemoveGroup . . .
RemoveSort . . . .
RemoveSummary.
RemoveTable. . . .
RemoveTableLink .
ReplaceTable . . . .
Save . . . . . . . . .
SetColumnAlias . .
SetFromActive . . .
SetFromLoading. .
SetTableAlias. . . .
SetTableLink . . . .
SetUserSQL . . . .
TestSelection$ . . .
252
252
252
253
253
253
254
255
255
256
256
257
257
258
258
259
259
260
260
260
261
261
262
262
262
263
264
265
265
266
267
268
269
270
271
271
272
272
273
273
274
274
275
275
275
276
276
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
276
277
277
277
278
278
279
279
280
280
280
281
281
282
282
283
284
AllDataBases$ . . . . .
AllOwners$ . . . . . .
AllTables$. . . . . . . .
DataBase$ . . . . . . .
Error$ . . . . . . . . . .
Id. . . . . . . . . . . . .
Name$ . . . . . . . . .
Owner$ . . . . . . . . .
Record. . . . . . . . . .
RecordCount. . . . . .
Selection$ . . . . . . . .
Table$ . . . . . . . . . .
Report Control Object
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
284
285
285
285
285
286
286
286
286
287
287
287
287
Abs function . . . . . . . . . . . . . . . .
Asc function . . . . . . . . . . . . . . . .
Assert statement. . . . . . . . . . . . . .
Atn function . . . . . . . . . . . . . . . .
Beep statement. . . . . . . . . . . . . . .
Begin Dialog ... End Dialog statement .
Button statement . . . . . . . . . . . . .
ButtonGroup statement . . . . . . . . .
Call statement . . . . . . . . . . . . . . .
CancelButton statement . . . . . . . . .
Caption statement. . . . . . . . . . . . .
CDbl function . . . . . . . . . . . . . . .
ChDir statement . . . . . . . . . . . . . .
ChDrive statement . . . . . . . . . . . .
CheckBox statement . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
291
291
292
292
293
293
294
294
295
296
297
297
297
298
298
CInt function. . . . . . . . . . . . . . .
CLng function . . . . . . . . . . . . . .
Close statement . . . . . . . . . . . . .
ComboBox statement . . . . . . . . .
Const statement . . . . . . . . . . . . .
Cos function . . . . . . . . . . . . . . .
CSng function . . . . . . . . . . . . . .
$CStrings metacommand. . . . . . .
CurDir$ function . . . . . . . . . . . .
Date$ function. . . . . . . . . . . . . .
Declare statement . . . . . . . . . . . .
Deftype statement . . . . . . . . . . .
Dialog. . . . . . . . . . . . . . . . . . .
Dim statement. . . . . . . . . . . . . .
Dir$ function. . . . . . . . . . . . . . .
Do...While statement . . . . . . . . . .
Environ$ function. . . . . . . . . . . .
Eof function . . . . . . . . . . . . . . .
Erl function . . . . . . . . . . . . . . .
Err function . . . . . . . . . . . . . . .
Err statement . . . . . . . . . . . . . .
Error statement . . . . . . . . . . . . .
Error$ function . . . . . . . . . . . . .
Exit statement . . . . . . . . . . . . . .
Exp function . . . . . . . . . . . . . . .
FileAttr function. . . . . . . . . . . . .
Fix function . . . . . . . . . . . . . . .
For...Next statement . . . . . . . . . .
FreeFile function . . . . . . . . . . . .
Function ... End Function statement .
GetField$ function . . . . . . . . . . .
Global statement . . . . . . . . . . . .
GoTo statement . . . . . . . . . . . . .
GroupBox statement . . . . . . . . . .
Hex$ function . . . . . . . . . . . . . .
If ... Then ... Else . . . . . . . . . . . . .
$Include metacommand . . . . . . .
Input$ function . . . . . . . . . . . . .
Input # statement . . . . . . . . . . . .
InputBox$ function . . . . . . . . . . .
InStr function . . . . . . . . . . . . . .
Int function. . . . . . . . . . . . . . . .
Kill statement . . . . . . . . . . . . . .
LBound function . . . . . . . . . . . .
LCase$ function . . . . . . . . . . . . .
Left$ function . . . . . . . . . . . . . .
Len function . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
299
300
300
301
301
302
302
303
303
304
304
306
307
307
309
310
.311
312
312
313
313
313
314
314
315
315
316
317
318
318
319
320
320
321
321
322
323
323
323
324
325
326
326
327
327
328
328
vi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
329
329
330
331
331
331
332
332
333
334
335
336
336
336
337
337
338
338
339
339
340
340
341
342
342
342
343
343
344
344
345
345
346
347
347
348
348
349
349
349
350
350
351
351
352
352
353
Timer function. .
Type statement .
UBound function
UCase$ function.
Val function . . .
While ... Wend . .
Write statement .
Index
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
353
354
354
355
355
356
356
357
vii