You are on page 1of 455

ActiveReports 2.

0 Standard User's Guide | 1

ActiveReports 2.0 Standard User's Guide

ActiveReports 2.0 Standard User's Guide | 2

Table Of Contents
User's Guide Introduction Using ActiveReports' Documentation Document Conventions Documentation Overview ActiveReports 2.x Features ActiveReports 2.0 Architectural Overview Chapter 1 - Installation Installation Steps Sample Reports Client Distribution Chapter 2 - Using ActiveReports for the First Time Adding ActiveReports to Visual Basic Adding a Report to the Visual Basic Environment User Interface Toolbars Context Menus Report Explorer Fields List Adding Controls to Your Report Adding ActiveX controls and OLE objects Selecting Multiple Controls Moving and Sizing Controls Sizing Sections Control Alignment and Sizing Formatting Controls Quick Start -Creating Your First Report Using ActiveReports' Print Preview Using ActiveReports' Wizard Converting Version 1.0 Reports to Version 2.0 Converting Access Reports Converting Crystal Reports Chapter 3 - Printer and Page Settings Using the Page Setup Dialogue Using the Printer Settings Dialogue Changing Page and Printer Setting in Code 23 23 23 23-24 24 24-26 26-28 28 28 29-30 30 30-31 31 31-32 32 32-35 35-36 36 36 36 36-37 37-38 38 38-39 39-40 40-41 41-42 42-43 43-44 44 44-45 45 45-46 46 46-47 47-50

ActiveReports 2.0 Standard User's Guide | 3 Chapter 4 - Binding Reports to Data Controls RDO (Remote Data Objects) DAO (Data Access Objects) ADO (ActiveX Data Objects) XML Setting Recordset and Connection Properties Binding Controls to a Data Control Chapter 5 - Bound Reporting and Grouping Simple Table or List Report Using Parameters With Bound Reports Grouping Records Grouping on Calculated Expression Adding a Summary Field in Group Footer Conditional Summary Fields Using Formulas and Calculated Fields Page N of M in the Page Footer Page N of M in the Group Header Chapter 6 - Unbound Reporting and Grouping Unbound Reports Simple Unbound Reports Grouping With Unbound Reports Adding Summary Fields to Unbound Reports Unbound Reporting with Arrays Unbound Reporting with Collections Unbound Reporting with Text Files Chapter 7 - Using Subreports Subreports Bound Subreports Using Parameters with Subreports Embedded Subreports Shaped/Hierarchical Subreports Unbound Subreports Chapter 8 - Dynamic (Run-Time) Reporting Modifying and Formatting Controls at Run Time Creating Dynamic Reports Dynamic Reports Chapter 9 - Creating Reports from an XML Document Bound XML Data Reports 50 50-51 51 51-52 52-53 53 53-54 54 54-55 55-56 56-57 57 57-59 59-62 62-63 63-64 64-65 65 65 65-67 67 67-68 68-70 71-72 72-74 74 74-75 75-78 78 78-83 83-87 88-93 93 93 93-94 94-97 97 97-98

ActiveReports 2.0 Standard User's Guide | 4 XML Data Reports and Subreports XML Reports using LoadXML Chapter 10 - Additional Report Types Top n Reports Master Detail Reports Summary Reports Mail-Merge Reports Columnar Reports Creating Labels Conditional Printing Green-Bar Printout Reports Multi-Page Sections Charts Multiple Records Per Section Modifying the Pages Collection of a Processed Report Report Coding Tips Chapter 11 - Organizing Reports with the TOC and Frame Control Setting Up a Table of Contents Using the TOC with Subreports Using the TOC with Groups Working with the Frame Control Using the Frame Control for a Table Chapter 12 - Hyperlinking, CSS and ActiveReports Using Hyperlinks Using HTML links Using Hyperlinks for Drill-Down reports Using Hyperlinks with the TOC Using the MouseOver event with Hyperlinks Using CSS Creating Global Styles Using Special CSS Styles Chapter 13 - Saving and Loading Saving And Loading RDF Files Using ActiveReports' Export Filters Saving and Loading Canvas Files Saving and Loading Report Layouts Saving and Loading to a Byte Array Chapter 14 - Scripting 98-102 102 102-103 103 103 103-104 104 104 104-105 105 105 105 105-106 106 106 106-107 107 107-108 108-109 109-110 110 110-111 111-112 112 112-113 113-115 115-117 117-118 118 118-119 119 119-120 120-122 122-124 124 124-125 125 125

ActiveReports 2.0 Standard User's Guide | 5 What are Scripts for? How to Add Scripts Working With Scripts Using RPX Files Chapter 15 - Using ActiveReports' ActiveX Viewer Control ActiveReports' ActiveX Viewer Control Adding the Viewer Control to VB Creating a Custom Preview Screen Using Split Windows on the Viewer Control Adding Buttons to the Viewer Control Controlling Printing and Printer Setup on the Viewer Chapter 16 - ActiveReports on the Web Using the Viewer Control with Internet Explorer Using the Java Viewer Control Creating a ReportServer with ASP and ActiveReports Support and Licensing Production Registration Technical Support Web Site NewsGroups Product Upgrades Suggestions Disk Defects Policy License Agreement and Limited Warranty ActiveReports Error Codes Reference Constants ActiveReports' Architecture Report Sections Report Processing Events Reports Passes Printing Process Common Properties BackColor BackStyle DataField Font 125-126 126-127 127-129 129-130 130 130-131 131 131-132 132-133 133-136 136-137 137 137-138 138-139 139 142 142 142-143 143 143 143 143 143-144 144-145 145-147 148 148-156 156 156-157 158 158 158-159 159 159 159-160 160 160-161 161-162

ActiveReports 2.0 Standard User's Guide | 6 ForeColor Common Methods ZOrder ActiveReport ActiveReport Properties AllowSplitter Canvas DocumentName Fields LayoutAction MaxPages PageBorder PageNumber Pages Parameters ParentReport Printer PrintWidth RulerVisible Sections Script ScriptDebuggerEnabled ScriptLanguage ShowMessages ShowParameterUI Status TOC TOCEnabled TOCVisible TOCWidth ToolbarVisible UserData Version WaterMark WaterMarkAlignment WaterMarkPrintOnPages WaterMarkSizeMode Zoom 162 162 162-163 163 163-165 165 165-166 166 166-167 167-168 168 168-169 169 169-170 170-171 171 171-172 172 172-173 173 173-174 174-175 175 175-176 176 176-177 177 177-178 178 178 178-179 179 179 180 180-181 181 181-182 182

ActiveReports 2.0 Standard User's Guide | 7 ActiveReport Methods About AddCode AddControlLicense AddNamedItem Cancel Export LoadLayout Localize PageSetup PrintReport ResetScripts Restart Run SaveLayout Stop ActiveReport Events DataInitialize Error FetchData FindProgress HyperLink KeyDown KeyPress KeyUp MouseOver NoData PageEnd PageStart PrintAborted PrintProgress PromptDialogClosed ReportEnd ReportStart TOCClick TOCSelChange ToolbarClick ARViewer Control 182-183 183 183-184 184-185 185 185-186 186 186-187 187-188 188 188-189 189 189-190 190 190-191 191 191-192 192-193 193-194 194 194-195 195 195-196 196 196 196-197 197 197-198 198 198 198-199 199 199-200 200 200 200-201 201 201

ActiveReports 2.0 Standard User's Guide | 8 ARViewer Properties AllowSplitter BackColor BorderStyle DataPath Object Pages PaperColor Printer ReportSource RulerVisible Status TOC TOCEnabled TOCVisible TOCWidth ToolBar ToolbarVisible UseSourcePrinter Zoom ARViewer Methods CopyPageToClipboard Find Localize MultiplePage PrintReport Refresh SinglePage ARViewer Events DblClk Error FindProgress hyperLink KeyDown KeyPress KeyUp LoadCompleted MouseDown 201-202 202 202-203 203 203-204 204 204-205 205 205 206 206 206-207 207 207-208 208 208-209 209 209 209-210 210 210-211 211 211-212 212-213 213 213-214 214 214 215-216 216 216-217 217 218 218 218-219 219 219 219-220

ActiveReports 2.0 Standard User's Guide | 9 MouseMove MouseOver MouseUp PageModeChanged PrintAborted TOCClick TOCSelChange ToolbarClick ZoomChanged Border Properties BottomColor, LeftColor, RightColor, TopColor BottomStyle, LeftStyle, RightStyle, TopStyle Shadow Canvas Canvas Properties Alignment BackColor (Canvas) BackStyle (Canvas) Font (Canvas) ForeColor (Canvas) Height Orientation PenStyle PenWidth Tag TextAngle VerticalAlignment Width Canvas Methods Clear DrawEllipse DrawLine DrawPicture DrawPictureLink DrawRect DrawRoundRect DrawText DrawTextLink 220 220-221 221 221 221-222 222 222-223 223 223 223-224 224 224-225 225 225 225-226 226 226-227 227 227-228 228 228-229 229 229-230 230 230-231 231 231-232 232 232-234 234 234-235 235 235-236 236 236-237 237 238 238-239

ActiveReports 2.0 Standard User's Guide | 10 FillRect IntersectClipRect Load MeasureParagraphHeight MeasureText Overlay PopClipRect PushClipRect Save TextOut Controls Controls Methods Add Count Item Remove RemoveAll BarCode Control Properties Alignment BackColor BarWidth Caption CaptionPosition DataField Direction EnableCheckSum Font (BarCode) ForeColor (BarCode) Style Checkbox Properties Alignment BackColor (Checkbox) BackStyle (Checkbox) Caption Font (Checkbox) ForeColor (Checkbox) Style Value 239 239-240 240-241 241-242 242 242-243 243-244 244 244-245 245 245-246 246 246-247 247-248 248 248 248-249 249 249-250 250 250-251 251 251-252 252 252-253 253 253-254 254 254-256 256 256-257 257 257-258 258 258 259 259-260 260

ActiveReports 2.0 Standard User's Guide | 11 Field Control Properties Alignment BackColor (Field) BackStyle (Field) CanGrow CanShrink ClassName DataField (Field) DataValue Font (Field) ForeColor (Field) hyperLink Multiline OutputFormat Style SummaryDistinctField SummaryDistinctValue SummaryFunc SummaryGroup SummaryRunning SummaryType Text VerticalAlignment WordWrap ZOrder (Field) Frames and Panes Frame Control Properties BackColor CanGrow CanShrink CloseBorder Panes ZOrder (Frame) Panes Pane Properties BackColor BackStyle Border 260-261 261-262 262 262-263 263 263-264 264 264-265 265 265-266 266 266-267 267 267-268 268 268-269 269 269-270 270 270-271 271-272 272 272-273 273 273-274 274 274 274-275 275 275-276 276 276-277 277-278 278 278 278 278-279 279

ActiveReports 2.0 Standard User's Guide | 12 CloseBorder Controls Pane Methods Add Count Item Remove Image Properties BackColor (Image) BackStyle (Image) ForeColor (Image) hyperLink LineColor LineStyle LineWeight Picture PictureAlignment SizeMode ZOrder (Image) Label Control Properties Alignment Angle BackColor (Label) BackStyle (Label) Caption ClassName Font (Label) ForeColor (Label) hyperLink Multiline Style VerticalAlignment WordWrap ZOrder (Label) Line Properties LineColor LineStyle LineWeight 279-280 280 280 280-281 281-282 282 282 282-283 283 284 284-285 285 285 285-286 286 287 287 287-288 288-289 289-290 290 290-291 291 291-292 292 292 292-293 293 294 294 294-295 295 295-296 296-297 297 297-298 298 298-299

ActiveReports 2.0 Standard User's Guide | 13 X1 X2 Y1 Y2 ZOrder (Line) OLE Control OLE Object Properties BackColor (OLE) BackStyle (OLE) Class Object PictureAlignment SizeMode VerbCount ZOrder (OLE) OLE Object Methods CreateEmbedded DoVerb GetUserType GetVerbID GetVerbName InsertObject PageBreak Control Properties Enabled RTF Text Control RTF Text Control Properties BackStyle BulletIndent CanGrow CanShrink GetTab MaxLength Multiline SelAlignment SelBold SelBullet SelCharOffset SelColor 299 299-300 300 300 300-301 301 301-302 302 302-303 303 303-304 304 304-305 305 305-306 306-307 307 307-308 308 308 308-309 309 309-310 310 310 310-311 311-312 312 312-313 313 313 313-314 314 314-315 315 315 315-316 316

ActiveReports 2.0 Standard User's Guide | 14 SelFontName SelFontSize SelHangingIndent SelIndent SelItalic SelLength SelProtected SelRightIndent SelStart SelStrikeThru SelTabCount SelTabs SelText SelTextBackColor SelUnderline Tag Text TextRTF ZOrder (RTF) RTF Text Control Methods Clear Copy Cut DeleteField Find InsertField LoadFile Paste ReplaceField SaveFile SelectField Shape Control Properties BackColor (Shape) BackStyle (Shape) LineColor LineStyle LineWeight Shape 316-317 317 317 317-318 318 318 318-319 319 319-320 320 320 320-321 321 321 321-322 322 322 322-323 323-324 324 324 324-325 325 325 325-326 326 326-327 327 327-328 328 328-329 329 329 329-330 330 330-331 331-332 332

ActiveReports 2.0 Standard User's Guide | 15 SubReport Control Properties CanGrow CanShrink DataField Object ReportName ZOrder (SubReport) Data Controls ADO ADO Data Control Properties CommandTimeOut Connection ConnectionString ConnectionTimeOut CursorLocation CursorType DataSourceName DefaultDatabase LockType MaxRows NRecords Password Provider RecordSet Source UserID ADO DB Data Control Methods Refresh DAO DAO Data Control Properties Connect DatabaseName DefaultCursorType DefaultType Exclusive MaxRows Options Password 332 332-333 333 333-334 334-335 335 335-336 336 336 336-337 337-338 338 338-339 339-340 340 340-341 341 341 341-342 342 342 343 343 343-344 344 344-345 345 345 345 345-346 346-347 347 347 347-348 348 348-349 349 349-350

ActiveReports 2.0 Standard User's Guide | 16 Recordset RecordsetType RecordSource SystemDB UserName DAO Data Control Methods Refresh RDO RDO Data Control Properties Connect Connection CursorDriver DataSourceName Environment ErrorTheshold KeysetSize LockType LoginTimeout LogMessages MaxRows Options Password Prompt QueryTimeout Resultset ResultsetType RowsetSize SQL UserName Version RDO Data Control Methods Refresh XML XML Data Control Properties BOF Count CurrentPosition EOF 350 350 350-351 351-352 352 352 352-353 353 353-354 354 354-355 355 355-356 356 356 356-357 357 357 357-358 358 358 358-359 359 359-360 360 360 360-361 361 361-362 362 362 362 363 363 363 363-364 364 364-365

ActiveReports 2.0 Standard User's Guide | 17 FileURL NodeList RecordSetPattern ValidateOnParse XML Data Control Methods Field LoadXML MoveNext Reset History History Properties Count Position History Methods Back Forward Item Pages and PageSettings PageSettings Properties BottomMargin Collate Duplex Gutter LeftMargin MirrorMargins Orientation PaperBin PaperHeight PaperSize PaperWidth RightMargin TopMargin Pages Pages Properties Password Pages Methods Add Commit 365 365-366 366-367 367 367 367-368 368-369 369 369 369 369 370 370-371 371 371 371-372 372-373 373 373 373-374 374-375 375 375-376 376 376-377 377 378 378-379 379-380 380-381 381 381-382 382 382 382-383 383 383-384 384-385

ActiveReports 2.0 Standard User's Guide | 18 Count GetPagesInRange Insert InsertNew Item Load Remove RemoveAll Save PaperSizes Methods Count Item Name Parameters Parameter Properties DefaultValue Key Prompt Tag Value Parameters Methods Count Item Printer Printer Properties Collate (Printer) ColorMode Copies DeviceCopies DeviceName Devices DisplayProgressDialog DPI Duplex (Printer) FileName FromPage hDC MaxPage 385 385-386 386 386 386-387 387 387-388 388 388-389 389 389-390 390 390-391 391 391 391 392 392-393 393 393-394 394 394 394-395 395 395-396 396-397 397 397 397-398 398 398-399 399 399 399-400 400-401 401 401 401-402

ActiveReports 2.0 Standard User's Guide | 19 NDevices NPorts Orientation (Printer) PaperBinNames PaperBins PaperHeight (Printer) PaperSizes PaperWidth (Printer) Port Ports PrintQuality Status ToPage TrackDefault TwipsPerPixelX, TwipsPerPixelY Printer Methods AbortJob EndJob EndPage Escape PrintPage PrintDialog SetupDialog StartJob StartPage RptFields RptFields Properties Name Tag Value RptFields Methods Add Count Item Remove RemoveAll Sections Section Properties 402 402-403 403 404 404-405 405 405-406 406 406 406-407 407 407-408 408 408-409 409 409-410 410 410 410-411 411-412 412 412-413 413-414 414-415 415 415-416 416 416 416 416-417 417 417-418 418 418 418-419 419 419 419-421

ActiveReports 2.0 Standard User's Guide | 20 BackColor BackStyle CanGrow CanShrink ColumnCount ColumnDirection ColumnLayout ColumnSpacing Controls DataField GroupValue GrpKeepTogether Height IsRepeating KeepTogether Name NewColumn NewPage PrintAtBottom Repeat Script Type UnderlayNext Visible Section Methods Add Count Item Refresh Remove Section Events AfterPrint BeforePrint Format TOC TOC Properties Count CurrentPage 421 421 422 422 422-423 423 424 424 424-425 425 425-426 426 426-427 427 427-428 428 428-429 429 429-430 430 430-431 431-432 432-433 433 433 433-434 434 434-435 435 435 435-436 436 436 436-437 437 437 437-438 438

ActiveReports 2.0 Standard User's Guide | 21 History SelectedItem TOC Methods Add GotoPage Item Navigate PageNumber Remove RemoveAll TOCEntry Properties Name PageNumber PageOffSet Tools and Toolbar DDToolbar Properties DisplayTooltips Font Tools DDToolbar Methods Refresh DDTools Methods Add AddEx Count Insert Item DDTool Properties Caption Checked Enabled ID Style Tooltip Type Visible DDTool Methods AddIcon 438-439 439 439 439-440 440-441 441 441 442 442 442 443 443 443 444 444 444 444-445 445 445-446 446 446 446-447 447-448 448 448-449 449 449-450 450 450-451 451 451-452 452-453 453 453 453-454 454 454-455 455

ActiveReports 2.0 Standard User's Guide | 22

ActiveReports 2.0 Standard User's Guide | 23

User's Guide

User's Guide
Introduction Using ActiveReports' Documentation Chapter 1 - Installation Chapter 2 - Using ActiveReports for the First Time Chapter 3 - Printer and Page Settings Chapter 4 - Binding Reports to Data Controls Chapter 5 - Bound Reporting and Grouping Chapter 6 - Unbound Reporting and Grouping Chapter 7 - Using Subreports Chapter 8 - Dynamic (Run-Time) Reporting Chapter 9 - Creating Reports from an XML Document Chapter 10 - Additional Report Types Chapter 11 - Organizing Reports with the TOC and Frame Control Chapter 12 - Hyperlinking, CSS and ActiveReports Chapter 13 - Saving and Loading Chapter 14 - Scripting Chapter 15 - Using ActiveReports' ActiveX Viewer Control Chapter 16 - ActiveReports on the Web Support and Licensing

Introduction

Introduction
ActiveReports leverages the latest technologies including ActiveX, XML, ActiveScripting and CSS to provide you with full integration, open architecture, and a user-friendly interface.

Using ActiveReports' Documentation

Using ActiveReports' Documentation


Document Conventions Documentation Overview Sample Reports

Document Conventions

Document Conventions
This book uses the following typographical conventions:
Convention bold Description Programming language terms in text

ActiveReports 2.0 Standard User's Guide | 24

italic Embedded Caps monospace font Keyboard Shortcuts

In Syntax italics indicate placeholders for information you would supply. Dialog box elements are displayed in italics Language terms are capitalized for readability. The language is not case sensitive. Code Syntax and Examples

Delete means the Delete or Del key on your numeric keypad Escape means the Escape or Esc key on your keyboard Enter means Enter, Return, or the Carriage Return key on your keyboard Ctrl-Key, Shift Key, and Alt -Key are two key combinations. Press and hold the first key then press the second key and release. For example, Ctrl-Z, press and hold the Control key and press the Z letter key on your keyboard. Click: Click the primary (left) mouse button once Right-click: Click the secondary (right) mouse button once Double-click: Click the primary (left) mouse button twice without moving the mouse while clicking Shift-click: Press and hold the SHIFT key on your keyboard and click the primary (left) mouse button

Mouse Actions

Documentation Overview

Documentation Overview
ActiveReports' documentation consists of two separate manuals.

Developer's Guide
The Developer's Guide, which is broken into several smaller organized chapters, gives an overview of the fundamentals for using ActiveReports. It introduces users to the way ActiveReports works and describes the design-time and run-time user interface. In addition, it demonstrates a variety of examples and techniques for using ActiveReports in both simple and advanced reporting scenarios. The Developer's Guide's purpose is to provide a firm foundation from which new ActiveReports users can build their projects. The ideas presented in this manual are keys for beginning report designers. More complex samples and specialized information can be found in our knowledgebase at http://www.datadynamics.com/kb. The information in the knowledgebase can be used in conjunction with this manual to provide more complex solutions to reporting problems.

Developer's Reference Manual


The Developer's Reference Manual details the ActiveReports object model. It describes the properties, methods, and events for ActiveReports' internal objects and controls.

ActiveReports 2.x Features

ActiveReports 2.x Features


ActiveX Designer
ActiveReports is based on the Active Designer specification. This allows a component to be integrated into the hosting design environment while allowing it to make full use of its services. The designer is a fully compliant ActiveX control and object host. You can insert ActiveX controls or OLE objects, such as graphs and documents, into your reports. OLE objects can be bound to BLOB fields in your database.

User Friendly interface


ActiveReports is modeled after Visual Basic's form designer with many additional enhancements and features. This provides a familiar UI to help make report designing possible in a timely manner.

Familiar Programming Language


ActiveReports uses Visual Basic as its primary design language through object-based events and methods. This allows you to leverage your Visual Basic skills without having to learn a foreign formula or scripting language.

ActiveReports 2.0 Standard User's Guide | 25

Small Distribution Overhead


ActiveReports' designer DLL is roughly 1.5 MB and it does not require any additional DLLs to distribute. The internet-enabled Report Viewer ActiveX control is very small at only 456KB.

Powerful Object Model


ActiveReports objects are exposed through COM for complete control over all aspects of your report. The designer provides an easy to use environment while the object model provides programmable controls, sections, and printing options.

Multithreaded Reporting Engine


ActiveReports is multithreaded allowing reports to be generated very quickly and efficiently. ActiveReports has the ability to generate multiple reports simultaneously.

Table of Contents and Navigation History objects


The viewer contains a programmable table of contents tree allowing users to quickly jump between report sections.

Lightweight, Internet-enabled, ActiveX Control


The ActiveReports ActiveX control, ARView2, can be used to preview reports on the Internet or Intranet with a very small client cab file download. The ActiveX control provides the same features found when viewing the report in a Win32 application.

RTF, PDF, EXCEL, HTML, TIFF and Delimited Text Exports


ActiveReports includes multiple export filters to transform your report output into Rich Text Format for word-processing, Portable Document Format (PDF) for global file transfer, EXCEL format, HTML format for web viewing, TIFF format for faxing, and delimited text for spreadsheets and database use.

Online Searchable Knowledgebase


http://www.datadynamics.com/Forums/ShowForum.aspx?ForumID=31 (http://www.datadynamics.com/Forums/ShowForum.aspx?ForumID=31) Data Dynamics provides an online searchable knowledgebase allowing all Data Dynamics customers to search for helpful articles on any of Data Dynamics' products. The Knowledgebase contains many useful articles and running samples on ActiveReports2.

New Features
Enhanced ActiveReports 2.0 Viewer Control The ActiveReports 2.0 viewer control now has several advanced features. Users can preview multiple pages simultaneously, utilize the new text search feature to search through a report for a specified text string, and report pages can now be copied to the clipboard and pasted in another document. The viewer control also has enhanced IntelliMouse support, a splitter control, and the ability to add custom icons. Expanded Toolbar in the Designer The designer's toolbar has several new options. The additions include a page setup menu for modifying page settings, printer settings and style layouts during design time. Menus now include options to save and load reports from RPX files (ActiveReports' custom XML file format), a style dropdown box for applying global and specialized styles, and several new controls. New PageSettings Collection and Page Setup Designer ActiveReports 2.0 now uses a page settings collection that allows each page to be easily modified. The PageSettings collection contains properties for setting margins, printer orientation, collation, duplex printing, and page sizes. The page setup dialogs allow page and printer settings to be modified at design time rather than requiring the changes to be made at run time. With the added support for mirror margins and gutters, ActiveReports 2.0 makes publishing easy. Note: PageBottomMargin, PageTopMargin, PageLeftMargin, PageRightMargin are no longer used. New XML Features New XML enhancements allow reports to be loaded and saved at design time and run time. Also, the

ActiveReports 2.0 Standard User's Guide | 26 addition of an XML data control allows easy access to XML database structures. New Hyperlink Capabilities ActiveReports 2.0 adds hyperlink events to the report and viewer control, providing hyperlinking to URLs, TOC entries, and other reports. Drill-Down Capability With the addition of the new hyperlink event, users can set up hyperlinks to other ActiveReports as well as URLs. This allows ActiveReports to emulate drill-down reporting. A typical scenario would be for users to click on a parent record in one report and have another report displayed containing all of the child records. Enhanced Exporting Capabilities The export filters now support hyperlinks and the ability to save a report into a byte array rather than to disk. The PDF export has been updated to support font embedding and international character set support. The PDF export allows for password protection and compression during saving as well as TOC exporting.

ActiveReports 2.0 Architectural Overview

ActiveReports 2.0 Architectural Overview


Format
A report section contains a group of controls that are processed and printed at the same time as a single unit. ActiveReports defines the following section types:

Report Header A report can have one report header section that prints at the beginning of the report. It is generally used to print a report title, a summary table, a chart or any information that needs to appear only once at the report's start. Report Footer A report can have one report footer section that prints at the end of the report. It is used to print a

ActiveReports 2.0 Standard User's Guide | 27 summary of the report, grand totals or any information that needs to print once at the report's end. Page Header A report can have one page header section that prints at the top of each page. It is the first section that prints on the page except when the page contains a report header section. The page header section is used to print column headers, page numbers, a page title or any information that needs to appear at the top of each page. Page Footer A report can have one page footer section that prints at the bottom of each page. It is used to print page totals, page numbers or any other information that needs to appear at the bottom of each page. Group Header, Group Footer A report can consist of single or multiple (nested) groups, with each group having its own header and footer sections. The header section(s) are inserted and printed immediately before the detail section. The footer section(s) are inserted and printed immediately after the detail section. The number of times each group section prints depends on how the data is grouped. ActiveReports starts a new group (Header, Detail, and Footer) when the data to which the group is bound changes. Detail A report has one detail section. The detail section is the body of the report and one instance is created for each record in the report.

Report Processing
The speed in processing and output generation of ActiveReports is attributed to its intelligent, multithreaded, single-pass processing. ActiveReports will process and render each page as soon as the page is ready. If ActiveReports is not able to fully render a page because some of its data elements are not known, or its layout is not final, it places the page in cache until that data is available. Summary fields and KeepTogether constraints are the two reasons that a page would not be displayed immediately. The summary field is not complete until all the data needed for calculation is read from the data source. When a summary field such as a grand -total is placed ahead of its completion level such as placing it in the report header, the report header section and all following sections will be delayed until all the data is read.

Printing Process
ActiveReports output can be printed using different methods. The simplest is to call the PrintReport method. When the PrintReport method is called, ActiveReports checks to determine if the report has been processed earlier. If not, it starts the report processing to create the Pages collection. Then it starts a new print job and prints each page in the collection then ends the print job. You can call the Stop or Cancel methods while the report is processing or printing. Both methods will cause the print job to end. The Stop method will continue to print processed pages before closing the print job. The Cancel will immediately close the print job and clear the pages collection. In addition, you can call the Run method to process the report and create the pages collection. Next, start a print job using the Printer.StartJob method. Then, selectively print pages from the collection using the Printer.PrintPage method. Finally, close the print job using the Printer.EndJob method. If you use background printing using Run(True) you will receive PrintProgress events. The Status property is updated while the report is printing in the background.

Section Events
Regardless of the sections type or content, there are three events for each section: Format, BeforePrint, and AfterPrint. Because there are so many possible report designs, the event firing sequence must be dynamic in order to accommodate individual report demands. Out of these three events, the Format event is generally used the most, followed by the BeforePrint event, and in rare circumstances, the AfterPrint event. Note: The only guaranteed sequence of events is for each section to fire the Format event before firing the BeforePrint event, which in turn, occurs before the AfterPrint event. However, several

ActiveReports 2.0 Standard User's Guide | 28 Format events may fire for multiple detail records before their BeforePrint and AfterPrint events fire. Format This event fires after the data is loaded and bound to the controls contained in a section, but before the section is rendered to the canvas. The format event is the only event where the section's height may be changed. This section may be used to set or change the properties of any controls, or load subreport controls with subreports. If the CanGrow or CanShrink property of any control contained within a section, or the section itself, is set to true, all of the growing and shrinking of controls contained in this section, and the section itself, takes place in this event. Because of this, information about a control or section's height cannot be obtained in this event. BeforePrint This event fires before the section is rendered to the canvas. The growing and shrinking of the section and all controls contained in a section have already taken place by the time this event fires. Use this section to resize any controls if needed. Since all controls and section growth have already taken place by the time this event fires, this event may be used to get an accurate height of the section or, if needed, any controls contained in it. You may resize any controls in this event but you cannot resize the section itself. AfterPrint This event fires after the section is rendered to the canvas. Although Detail AfterPrint originally started off as a very important event prior to Version 1 Service Pack 3, it is rarely used in any of the newer builds of ActiveReports. When you are placing code in the section events, chances are you are going to be placing your code in the Format or BeforePrint events. This event is still useful for drawing on the canvas after text has already been rendered to the canvas.

Chapter 1 - Installation

Chapter 1 - Installing ActiveReports


Installation Steps Sample Reports Client Distribution

Installation Steps

Installation Steps
1. Select RUN from the Windows Start Menu. 2. Type <setup file path>\SETUP.EXE. 3. Click OK or press Enter to run the installation program. 4. When prompted, enter your name, organization and serial number. 5. Read the license agreement. 6. Select your installation directory or accept the suggested default directory. 7. Select the directory for the dll and ocx installation or accept the suggested default. 8. Select the components you wish to install. 9. Type the name of the program group or keep the default value. 10. Click Next to proceed with the installation. 11. The installation program will copy all of the selected ActiveReports components to the specified directory and register the control and DLLs in your system registry.

ActiveReports 2.0 Standard User's Guide | 29 12. You are now ready to use ActiveReports 2.

Sample Reports

Included Sample Reports


The ActiveReports installation includes many sample reports that employ different techniques for report design and programming. All sample reports include one or more pages in the report title section that describe the sample report and the techniques used to accomplish the desired results. The code behind sections in the sample reports demonstrates many techniques that make ActiveReports a powerful report writer with its fully programmable objects and controls. Following is a listing of these sample reports and the features that they demonstrate:
# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Name Annual Report Catalog (Custom Preview) Category Selection Custom Preview Customer Labels (Custom Preview) Customer Letters (Custom Preview) Customer Phonebook Drill-Down Employee Profiles (Custom Preview) Employee Sales By Country Invoice (Custom Preview) Price List By Category Print Bound DBGrid Print MSFlex Grid Product Categories Product Inventory Product Price List Product Weekly Sales RDFViewer RDO Sample ReportDLL Running Sales By Customer Scripting SecureMDB Students and Classes Tutor Description Demonstrates subreports, page-break and green bar printing. Demonstrates record grouping, page-break, OLE object binding, drawing with lines and shapes. Demonstrates record grouping, query modification and summary functions. Demonstrates OLE, Charting, Grouping, Mail Merge, and labels. Demonstrates label printing, column layouts, can grow, and can shrink properties. Demonstrates Mail Merge. Demonstrates, custom unbound grouping, column layout and "Continued .." on each page. Demonstrates hyperlinks and Drill-Down. Demonstrates OLE Image control Extensive totals, percentage of totals, delayed printing and conditional printing at run time. Demonstrates standard master-detail printing and setting recordsets at runtime from VB code. Demonstrates record grouping and bound OLE objects. Demonstrates using DBGrid. Demonstrates using MSFlexGrid. Demonstrates record grouping using linked subreports in the detail section. Demonstrates different formatting options, record grouping and repeating group headers. Demonstrates "Continued.." in page footer. A more complex sample showing programmable objects, cross tab and delayed printing. Demonstrates customizing the viewer control. Demonstrates using RDO, record grouping. Demonstrates setting up a report server dll. Demonstrates a variety of summarization options including subtotals and running total within groups. Demonstrates a variety of scripting procedures. Demonstrates using a secured database. Demonstrates simple lists, grouped master detail and programmable shape control to display a graph. Variety of step by step reports.

17
18 19 20 21 22 23 24 25 26

ActiveReports 2.0 Standard User's Guide | 30

27 28

Unbound XML

Demonstrates using ActiveReports in unbound report from a variety of data sources. Demonstrates a variety of XML procedures.

Client Distribution

Client Distribution
You need to include the following files on all clients when distributing your reports in an application.
File Name ActRpt2.DLL AB2DLL.dll ARVIEW2.ocx PDFExpt.DLL RTFExpt.DLL ExclExpt.DLL TextExpt.DLL HTMLExpt.DLL TiffExpt.dll Description The Reporting Engine (AR2Pro.dll For Professional Edition) The ActiveBar dll (For Professional Edition End User Designer projects) Only if you are using our ActiveX Viewer PDF Export Filter (when using PDF exporting) RTF Export Filter (when using RTF exporting; also to enable the copy button on the viewer) Excel Export Filter (when using Excel exporting) Text Export Filter (when using Text exporting) HTML Export Filter (when using HTML exporting) Tiff Export Filter (when using Tiff exporting)

Web Server Distribution


To serve reports to clients in a web environment, your web server should have arview2.cab (if using ActiveReports Viewer Control), actrpt2.dll (or ar2pro.dll for Professional Edition). You should also register any export dlls needed.

Chapter 2 - Using ActiveReports for the First Time

Chapter 2 - Using ActiveReports for the First Time


Adding ActiveReports to Visual Basic Adding a Report to the Visual Basic Environment User Interface Toolbars Context Menus Report Explorer Fields List Adding Controls to Your Report Adding ActiveX Controls and OLE Object Selecting Multiple Controls Sizing Sections Control Alignment and Sizing Formatting Controls Quick Start - Creating Your First Report Using ActiveReports' Print Preview Using ActiveReports' Wizard Converting Version 1.0 Reports to Version 2.0

ActiveReports 2.0 Standard User's Guide | 31

Converting Access Reports Converting Crystal Reports

Adding ActiveReports to Visual Basic

Adding ActiveReports to Visual Basic


ActiveReports is an ActiveX Designer control; the following steps describe how to include it in your Visual Basic IDE: 1. Start Visual Basic. 2. Choose Project > Components (Ctrl-T). 3. Click on the DesignersTab:

4. Choose Data Dynamics ActiveReports 2.0. If the ActiveReports entry does not appear in the list, make sure that "Selected Items Only" is not checked. If it still doesn't appear make sure that ActRpt2.DLL is registered by running regsvr32 on ActRpt2.DLL. Note: If you have ActiveReports 1 installed you can use ActiveReports 1 and ActiveReports 2 side by side as seen in the image provided. 5. Click OK to close the dialog box. Note: ActiveReports is not an ActiveX control, it is an ActiveX designer. So, it should not be referenced in the Controls tab under components. A reference to the appropriate dll is added automatically whenever you add ActiveReports to your project as explained in the next section.

Adding a Report to the Visual Basic Environment

Adding a Report to the Visual Basic Environment


To add a new report to your project: 1. Click the Project menu in Visual Basic.

ActiveReports 2.0 Standard User's Guide | 32 2. Choose Add Data Dynamics ActiveReports. Note: "Add Data Dynamics ActiveReports" will either be located directly on the project menu or on a submenu off of the project menu titled More ActiveX Designers. Visual basic creates a new window containing the report designer as shown in the provided image.

User Interface

User Interface
ActiveReports' user interface is similar to Visual Basic's form designer interface. It leverages your current knowledge and provides full integration within your Visual Basic environment.

Toolbars

ActiveReports 2.0 Standard User's Guide | 33

Toolbars
The toolbars in ActiveReports can be easily customized. ActiveReports' toolbars allow developers to rearrange buttons and menu options, as well as hide, display, dock or float toolbars.

To Move a Toolbar
Click the grab handle to a new location. for docked toolbars or the title bar for floating toolbars, and drag the toolbar

Toolbar's Context Menu


To access a toolbar's context menu, click the right mouse button anywhere in the toolbar's area. The context menu allows you to show or hide toolbars by selecting the toolbar name from the menu. In addition, you can customize the toolbars or create a new toolbar from the Customize option on the menu. Customized toolbar settings are saved in a ArToolbarCfg.tb file and they are restored the next time you start ActiveReports.

Main Toolbar
Button Name Report Explorer - shows or hides the report explorer tree and the fields list. Full-Screen - maximizes the ActiveReports designer to a full-screen view outside the Visual Basic IDE. Cut - Cuts the selected controls to the clipboard. Copy - Copies the selected controls to the clipboard.

Paste - Pastes the contents of the clipboard into the current selected section. Undo - the last action. View Grid - turns the grid display on or off. Script Editor - Starts ActiveReports Script Editor Reorder groups - displays the groups order dialog.

Format Toolbar
Button Name Style Sheets - sets the style sheet for a control Font - sets the typeface of the selected label or field control. Size - sets the font size of the selected label or field control. Bold - sets the bold typeface on or off. Italic - sets the italic typeface on or off. Underline - sets the underline typeface on or off. Text Align Left - aligns the text left within the control area. Text Align Center - align the text centered within the control area. Text Align Right - aligns the text right within the control area. BackColor - sets the background style to normal and the background color of the selected control to the specified color.

ActiveReports 2.0 Standard User's Guide | 34

ForeColor - sets the text color of the selected control to the specified color. LineColor - sets the line color for the selected line control. LineStyle - sets the line style of the selected line control.

Toolbox
Button Name Select - Allows you select controls on the report. Label - Insert a new static label control. Field - Insert a field textbox, bound to a database field or unbound. Checkbox - Insert a field checkbox, bound to a database field or unbound. Image - insert a picture, loaded from a file. Line - Insert a line control. Shape - Insert a rectangle, circle or square shape. RichEdit Control - Inserts ActiveReports RichText control. Frame Control - Inserts ActiveReports Frame control. PageBreak - Insert a page break within a section. Subreport - Insert a Subreport control to link to another report. OLE Object - Insert an OLE object, bound to a database field or unbound. ActiveX Control - Insert an ActiveX control. Barcode Control - Inserts ActiveReports Barcode control. ADO Data Control - Define an ADO data source. DAO Data Control - Define a DAO data source. RDO Data Control - Define an RDO data source. XML Data Control - Define an XML data source.

Alignment Toolbar
Button Name Bring to Front - Brings the selected controls to the top Z-Order Send to Back - Sends the selected controls to the bottom Z-Order Snap to Grid - Turns controls snap-to-grid on or off.

Align Left - aligns selected controls to the same left coordinate of the last selected control.
Align Center - aligns selected controls to the same center coordinate of the last selected control. Align Right - aligns selected controls to the same right coordinate of the first selected control. Align Top - aligns selected controls to the same top coordinate of the last selected control. Align Middle - aligns selected controls to the same middle coordinate of the last selected control.

ActiveReports 2.0 Standard User's Guide | 35

Align Bottom - aligns selected controls to the same bottom coordinate of the last selected control. Align to Grid - aligns the selected controls to the closest grid point. Center in Section - Centers a control in a section Make Same Width - makes all selected controls the same width as the last selected control. Make Same Height - makes all selected controls the same height as the last selected control. Make Same Size - makes all selected controls of the same height and width as the last selected control. Displays the position of the selected control within its parent section. Displays the dimensions of the selected control.

Print Preview Toolbar


Button Name Table of Contents Print Report Copy - Copies All of the text on the page. Find - Search for a specified string in the report. Single Page View - Changes view back to single page. Multi-Page View - Changes view to multi-page. Zoom Out/In Zoom Page Up/Down Page p of n History Back/Next

Context Menus

Context Menus
Context Menus can be accessed by right clicking on the report.
Menu Item Insert > Group Header/Footer Insert > Page Header / Footer Insert > Report Header / Footer Delete Section Reorder Groups Cut Copy Paste Function Adds a new group header/footer pair to the report. Adds a new page header/footer pair to the report. A single pair is allowed per report. This option is disabled once the first pair is added. Adds a new report header/footer pair to the report. A single pair is allowed per report. This option is disabled once the first pair is added. Deletes the current selected section from the report. This option does not apply to the Detail section in the report. This option is available when more than one group section are added to the report. It displays a dialog box to allow changes to the nesting order of the group sections in the report. Cuts the selected control to the clipboard. Copies the selected control to the clipboard Pastes the contents of the clipboard into the current section.

ActiveReports 2.0 Standard User's Guide | 36

Bring to Front Send to Back Align Size Format Border

Brings the selected control to the top of the Z-Order Sends the selected control to the bottom of the Z-Order Aligns controls to any of their vertical or horizontal coordinates. Sizes the controls to same width, height or both. Displays the border dialog box.

Report Explorer

Report Explorer
ActiveReports provides easy navigation through your report sections and controls by using the report explorer. To access the report explorer, click on the explorer icon in the main toolbar. You can navigate by clicking on the tree nodes representing the sections and controls on your report; ActiveReports will select each section or control as you click in the tree.

Fields List

Fields List
The second pane in the report explorer view displays a list of data source fields. The fields list is based on the data control in your report. Once the data control has been set up to connect to a database, the list is populated by clicking on the populate fields button located in this pane. You can drag and drop fields from the fields list to any section on your report. ActiveReports will automatically create a textbox control for the field you dropped and bind it to the data source for you.

Adding Controls to Your Report

Adding Controls to Your Report


To add controls to a report: 1. Click the control you want to add in the toolbox. 2. Move the mouse pointer to the section where you want to add the control; the mouse pointer will change to a cross hair. 3. Click and drag the mouse to size the rubber band to the desired size of the control. 4. The control is placed at the specified location and the toolbox current selection changes back to a Select pointer . Note: To add multiple copies of the same control, you can hold the Ctrl key while selecting the control from the toolbox and placing the controls in the section. Note: Line controls can be set to draw horizontally or vertically by holding the Ctrl (horizontal) or Shift (vertical) key while clicking and dragging the mouse.

Adding ActiveX controls and OLE objects

Adding ActiveX Controls and OLE objects


ActiveReports allows full access to OLE objects and ActiveX controls. To insert an OLE control into your report: 1. Click the control icon from the toolbox.

2. Select the area of the control

ActiveReports 2.0 Standard User's Guide | 37

3. ActiveReports displays the Insert Object dialog

4. You can select the type of the OLE object to be inserted and click OK to close the dialog. 5. Or, click Cancel to close the dialog and allow ActiveReports to select the object class from the bound data field. To insert an ActiveX control into your report: 1. Select the ActiveX control icon from the toolbox.

2. Select the control you want to insert from the ActiveX dialog

3. Size the area of the control. The ActiveX will always be printed within that area. ActiveReports will not grow or change the size of the ActiveX control based on its content. The ActiveX control will be rendered just as it would appear on a Visual Basic form at run time.

Selecting Multiple Controls

Selecting Multiple Controls


You can select multiple controls and then move, copy or do other things with them as a group. There are three methods to select more than one control:

ActiveReports 2.0 Standard User's Guide | 38 1. Hold down the Shift or Ctrl key while you click on the control you want to select. 2. Click in an empty area, and then draw a "rubber-banding" rectangle around all the controls that you want to select. Rubber banding does not allow you to select controls in different section.

3. Click on either the horizontal or the vertical ruler and drag the pointer to draw a shadow covering the control you want selected across all sections.

Moving and Sizing Controls

Moving and Sizing Controls


To move a control or a set of selected controls: select the controls you need to move and drag them with the mouse.

You can also adjust a control's size and location by specifying its coordinate properties in Visual Basic's property editor. Note: When you size a control beyond the boundaries of a section, the section will adjust to contain the control's new size.

Sizing Sections

Sizing Sections
You can change the width and height of the sections in your report. The height of each section can be modified individually. However, the width of all sections will change at the same time. Changing the width of sections will change the PrintWidth of the report.
l

To change the width of the sections, place the pointer at the right edge of the section. Click and drag the pointer left or right to expand or shrink the width of the section.

ActiveReports 2.0 Standard User's Guide | 39

To change the height of a section, place the pointer at the bottom edge of the section. Click and drag the pointer up or down to expand or shrink the height of the section.

You can change the section height by using the vertical ruler thumb down to adjust the height.

and dragging it up or

Double clicking on the section thumb allows you to quickly set the section height to precisely fit its contents. To change both width and height of a section, place the pointer at the lower-right corner of the section and drag it diagonally to change the size.

Control Alignment and Sizing

Control Alignment and Sizing


Control alignment and sizing toolbar buttons make it easy to organize the layout of your report and make sure that controls are sized and aligned precisely.
l

Select multiple controls in your report, making sure that the control you want to use as a template for aligning and sizing against is selected last.

Click the Align Left

, Center

or Right

to align the controls as shown below:

ActiveReports 2.0 Standard User's Guide | 40

Follow similar steps to vertically align or size the selected controls.

Formatting Controls

Formatting Controls
Setting Font Properties
To format the text of a label or a field control, click on the Ellipse button () of the Font property in Visual Basic's property window. You can set the typeface name, size and other font settings from the standard Font dialog. In addition, you can use the Format toolbar button and combo-boxes to set those properties for any selected control or controls. When working with non-English fonts, the language's script must be selected in the font property window and the language must be available in the system's regional settings.

Setting Foreground and Background Colors


Foreground and background colors can be set using the color drop-down in either Visual Basic's property window or the color palette toolboxes in the Format toolbar. The Format toolbar background color palette sets both the BackStyle property of the control to Normal and the BackColor property to the specified color. Background colors will not show if the BackStyle of the control is set to Transparent. The color palette toolboxes can be dragged and floated or docked to any of the window edges for quick access.

Selecting a Border Style


1. ActiveReports allows you to set the border of most controls to a variety of line styles and options. You can set these border styles using the Borders property sheet available from the control's context menu. You can set the borders of a single or multiple controls at the same time. 2. Select a control such as a label or field on your report. 3. Click the right mouse button for the context menu. 4. Select Format Border from the menu.

ActiveReports 2.0 Standard User's Guide | 41

5. You can set the border on each side of the control by selecting the line style and color then clicking the side (between the + signs) you wish to set. Presets contains a list of common border settings, you can click any of the buttons to set the border to the style shown.

Setting Output Formats


ActiveReports provides an easy to use Number Format dialog box. You can use this dialog to set the OutputFormat property of field controls to a valid formatting mask.

To access this dialog, click on the ellipse () button of the OutputFormat property in Visual Basic's property window.

Quick Start -Creating Your First Report

Quick Start - Creating Your First Report


1. Start Visual Basic. 2. Create a new Standard EXE project. 3. Add a Data Dynamics' ActiveReport to your project. 4. Select and place a ADO Data Control in the Detail section. 5. Right-click on the ADO Data Control and select Properties to bring up the Data Control's property window. 6. Select Build from the Properties window.

ActiveReports 2.0 Standard User's Guide | 42 7. Double-Click Microsoft Jet 4.0 OLE DB Provider from the Provider tab. 8. Set the database name to <VB Path>\NWIND.MDB. 9. Click OK. 10. Set the Source property to SELECT * FROM customers. 11. Click OK. 12. Place 2 label controls horizontally in the Page Header section. 13. Place 2 text controls horizontally in the Detail section. 14. The report should look like this:

15. Set the Label1 caption property to Company Name. 16. Set the Label2 caption property to Phone Number. 17. Set the Field1 DataField property to CompanyName (select from drop-down). 18. Set the Field2 DataField property to Phone (select from drop-down). 19. Click on the Slide control on the ruler beside the PageFooter and drag the PageFooter up to the bottom of the fields. 20. Add a button control to Form1. 21. In the Command1_Click event add the following code:
ActiveReport1.Show

22. Run the project. 23. Click the Command1 button on Form1 to preview your first ActiveReport.

Using ActiveReports' Print Preview

Using ActiveReports' Print Preview


You can use the preview window to preview single or multiple reports at the same time. The following code implements two click events to preview two different reports in the application.
Private Sub btnPreviewProductInventory_Click() Dim rpt As rptProductInventoryByCategory Set rpt = new rptProductInventoryByCategory rpt.show End Sub Private Sub btnPreviewProductList_Click() Dim rpt As rptProductPriceList Set rpt = new rptProductPriceList rpt.show End Sub

ActiveReports' multithreaded engine allows you to create several report instances that will run in parallel. Running the first report will display the following form.

ActiveReports 2.0 Standard User's Guide | 43

Using ActiveReports' Wizard

Using ActiveReports' Wizard


ActiveReports' wizard provides an easy step-by-step process to create a new ActiveReport. To create a new report using the wizard, follow these steps: 1. Choose Project > Add Form from Visual Basic's menu or click on the New Form toolbar. 2. Select ActiveReports 2 Wizard from the list of new form types. You will be presented with the following dialog, follow the steps to create your report. icon on the

ActiveReports 2.0 Standard User's Guide | 44

Note: If you do not see the entry for the wizard in the list of new form types, make sure the file ActiveReports 2 Wizard.VBZ is in your <VBPath>\template\forms directory and that the DLL ARWizard2DLL is properly registered on your system.

Converting Version 1.0 Reports to Version 2.0

Converting Version 1.0 Reports to Version 2.0


By using ActiveReports' UpSizer, reports created in version 1.0 can be easily converted to version 2.0. To launch the upsizer, run the ARUpSizer.exe file located in the ActiveReports installation directory. When the screen below appears, add the report files you wish to upsizer and select "upsizer."

When the reports are upsized, the old version 1.x reports will be renamed with a .Backup extension.

Converting Access Reports

Converting Access Reports


Access reports can easily be converted to ActiveReports format by running the Access upsizer wizard. Due to differences between products, the extent to which your reports will be converted will depend upon your specific report layout. However, since we have provided source code, you can

ActiveReports 2.0 Standard User's Guide | 45 modify the resulting ActiveReports to achieve the results you desire. To launch the upsizer, run the AccessToAR.exe file located in the ActiveReports installation directory. You will be presented with the following dialog. Follow the steps to convert your reports.

Converting Crystal Reports

Converting Crystal Reports


Reports created with Crystal Reports can be converted to ActiveReports format by running the Crystal Reports upsizer wizard. Due to differences between products, the extent to which your reports will be converted will depend upon your specific report layout. However, since we have provided source code, you can modify the resulting ActiveReports to achieve the results you desire. To launch the upsizer, run the CrystalToAR.exe file located in the ActiveReports installation directory. You will be presented with the following dialog. Follow the steps to convert your reports.

Chapter 3 - Printer and Page Settings

Chapter 3 - Printer and Page Settings

ActiveReports 2.0 Standard User's Guide | 46

Using the Page Setup Dialog Using the Printer Settings Dialog Changing Page and Printer Settings in Code

Using the Page Setup Dialogue

Using the Page Setup Dialog


With ActiveReports 2.0, page settings can be modified at design time, as well as run time. The Page Setup dialog (shown below) can be accessed by selecting File Page Setup from the toolbar menu.

From the Page Setup dialog, changes can be made to the page's margins (left, right, top and bottom), a gutter can be specified, and the mirror margins option can be selected. By setting a Gutter and selecting Mirror Margins, reports can easily be set up for publishing purposes. When Mirror Margins is selected, the report sets the inside margins for opposite pages to be the same width and the outside margins for opposite pages to be the same width. Specifying a Gutter will give extra space between the page's edge and the page's margins. By using these settings, extra space is provided so reports can be bound together.

Using the Printer Settings Dialogue

Using the Printer Settings Dialog


With ActiveReports 2.0, printer settings can be modified at design time, as well as run -time. The Print Settings dialog (shown below) can be accessed by selecting File Page Setup from the toolbar menu and then selecting the Printer Settings option button from the Report Settings dialog box.

ActiveReports 2.0 Standard User's Guide | 47

From the Printer Settings dialog, changes can be made to the printer's paper size and orientation, as well as indicating the paper bin, what type of collation to use, and if the report should be duplexed. The Printer Settings dialog also allows custom paper sizes to be specified. A custom paper size can be set up by selecting "Custom paper size" from the PaperSize dropdown box. Once this option has been selected, the width and height options will allow a specific height and width to be set (in twips). Note: Custom paper sizes will only work if the selected printer supports the specified paper size. If an unsupported paper size is set, the custom size will be ignored.

Changing Page and Printer Setting in Code

Changing Page and Printer Settings in Code


With ActiveReports 2.0, page and printer settings can be changed at run time, as well as design time. Through code, the DeviceName (printer) can be changed, as well as all of the printer settings available in the Printer Settings dialog, plus several other printer setting options. Note: When making changes to the printer settings, the code must be either in the ReportStart event or before.

DeviceName
By specifying a DeviceName, reports can be hard coded to use a certain printer. When Setting the DeviceName, use the full path and name for the printer. For example:
Private Sub ActiveReport_ReportStart() Printer.DeviceName = "\\ServerP01\HP LaserJet 5/5M" End Sub

The DeviceName can also be set to a null string. Since ActiveReports uses the default, or specified printer, to base its page and printer settings on, it is highly recommended to set the DeviceName to a null string when the application may run on a system with no default printer attached, such as a web server.

Orientation
A report's orientation can be changed in code by using either of the following syntaxes:
Dim lFlag As Boolean Private Sub ActiveReport_ReportStart() If lFlag Then

ActiveReports 2.0 Standard User's Guide | 48


PageSettings.Orientation = ddOLandscape Else PageSettings.Orientation = ddOPortrait End If End Sub

An individual page's orientation can also be set by using a similar call in the PageStart event. For example, the following few lines alternate each page's orientation from portrait to landscape.
Private Sub ActiveReport_PageStart() Static bFlag As Boolean If bFlag Then PageSettings.Orientation = ddOPortrait bFlag = False Else PageSettings.Orientation = ddOLandscape bFlag = True End If End Sub

Note: Using PageSettings.Orientation instead of Printer.Orientation will allow the orientation to be saved as part of the report.

PaperSize
The PaperSize property allows a report to be set to a number of pre-defined paper types. Below is a list of pre-defined PaperSize settings:
Setting 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 Description Letter, 8 1/2 x 11 in +A611Letter Small, 8 1/2 x 11 in Tabloid, 11 x 17 in Ledger, 17 x 11 in Legal, 8 1/2 x 14 in Statement, 5 1/2 x 8 1/2 in Executive, 7 1/2 x 10 1/2 in A3, 297 x 420 mm A4, 210 x 297 mm A4 Small, 210 x 297 mm A5, 148 x 210 mm B4, 250 x 354 mm B5, 182 x 257 mm Folio, 8 1/2 x 13 in Quarto, 215 x 275 mm 10 x 14 in 11 x 17 in Note, 8 1/2 x 11 in Envelope #9, 3 7/8 x 8 7/8 in Envelope #10, 4 1/8 x 9 1/2 in Envelope #11, 4 1/2 x 10 3/8 in Envelope #12, 4 1/2 x 11 in Envelope #14, 5 x 11 1/2 in C size sheet D size sheet E size sheet

ActiveReports 2.0 Standard User's Guide | 49

27 29 30 28 31 32 33 34 35 36 37 38 39 40 41 255

Envelope DL, 110 x 220 mm Envelope C3, 324 x 458 mm Envelope C4, 229 x 324 mm Envelope C5, 162 x 229 mm Envelope C6, 114 x 162 mm Envelope C65, 114 x 229 mm Envelope B4, 250 x 353 mm Envelope B5, 176 x 250 mm Envelope B6, 176 x 125 mm Envelope, 110 x 230 mm Envelope Monarch, 3 7/8 x 7 1/2 in Envelope, 3 5/8 x 6 1/2 in U.S. Standard Fanfold, 14 7/8 x 11 in German Standard Fanfold, 8 1/2 x 12 in German Legal Fanfold, 8 1/2 x 13 in User Defined

Note: A can only be used if supports size. If printer does not support specified PaperSize, report will use default PaperSize for the selected printer. To set the paper size in code, use the following syntax in either the ReportStart or PageStart events.
Dim pgCounter As Integer Private Sub ActiveReport_PageStart() pgCounter = pgCounter + 1 If pgCounter > 1 Then PageSettings.PaperSize = 1 'Letter End If End Sub Private Sub ActiveReport_ReportStart() PageSettings.PaperSize = 5 'Legal End Sub

In this example, the report's first page is set to legal and every page after is set to letter. By specifying a PaperSize of 256, a custom PaperSize can be defined. For custom paper sizes, a PaperWidth and PaperHeight value will need to be specified.
Private Sub ActiveReport_ReportStart() PageSettings.PaperSize = 256 'Custom PaperSize PageSettings.PaperHeight = 6 * 1440 'Six inches PageSettings.PaperWidth = 6 * 1440 'Six inches End Sub

Note: Setting the DeviceName to a null string will allow any PaperSize to be used. However, this will prevent the report from printing since no printer is defined.

Margins
A report's margins can also be set in code by using the following:
Private Sub ActiveReport_ReportStart() PageSettings.BottomMargin = 720 '1/2 Inch PageSettings.TopMargin = 2880 '2 Inches PageSettings.LeftMargin = 720 '1/2 Inch PageSettings.RightMargin = 720 '1/2 Inch End Sub

ActiveReports 2.0 Standard User's Guide | 50 Note: Margins are measured in twips, so a 1 inch margin will be equal to 1440 twips.

PrintWidth
Modifying the PrintWidth changes the amount of physical space a report can print to. If the report's size changes during run-time, such as changing a report's orientation when the designer is set to 8.5 inches, the PrintWidth will also need to be adjusted. This makes sure the report fills the entire printable area.
Private Sub ActiveReport_ReportStart() PageSettings.Orientation = ddOLandscape 'Sets the new printwidth to be 11 inches 'minus the left an right margins Me.PrintWidth = 11 * 1440 - (PageSettings.LeftMargin + PageSettings.RightMargin) '11 inches End Sub

Warning: Blank Pages or Red Vertical Lines: If the width of the report, plus the left and right margins, is greater than the width of the physical paper, a blank page will be printed between each report page. If a report's size is wider than the page, a vertical, dotted red line will appear on the right side of the page. To correct this problem ensure the sum of .PageLeftMargin + .PrintWidth + .PageRightMargin is less than the width of your paper (Printer.PaperWidth).

Chapter 4 - Binding Reports to Data Controls

Chapter 4 - Binding Reports to Data Controls


Using Remote Data Objects (RDO) Data Control Using Data Access Objects (DAO) Data Control Using ActiveX Data Objects (ADO) Data Control Using XML Data Objects (XML) Data Control Setting Recordset and Connection Properties Binding Controls to a Data Control

RDO (Remote Data Objects)

RDO (Remote Data Objects)


ActiveReports uses data controls that are similar to Visual Basic's data controls. Our Data Controls use standard Microsoft ADO, DAO, and RDO to connect to data sources. Note: You can only place one Data Control on a report and the Data Control can only be placed in the detail section of the report. The RDO Data control allows you to connect to your data source using Remote Data Objects (RDO) libraries. RDO is smaller than DAO and better suited for ODBC connections than DAO. RDO is only available in the Enterprise Edition of Visual Basic. ADO is now the suggested data access object model recommended by Microsoft for all new applications being created.

DSN Connection
You can connect using a Data Source Name (DSN) by using the Connect property or DataSourceName, UserName and Password properties. To connect using the DataSourceName property, you can select the DSN from the dropdown list in the property window. Then, type your UserName and Password in the corresponding properties. To use the Connect property, you should type a valid ODBC connection string in the Connection property. A valid connection string with a DSN is:
DSN=<dsn>;[UID=<userid>;][PWD=<password>]

ActiveReports 2.0 Standard User's Guide | 51 Note: The Microsoft Access ODBC driver allows you to specify a security database using the SystemDB parameter and a database name using the DBQ parameter. For example, DSN=MyAccessMDB; DBQ=C:\Data\mymdb.mdb; SystemDB=c:\data\mymdb.mdw; uid=admin; pwd=secure;

DSN-Less Connection
You can connect to your data source without the use of a DSN by using the Connect Property. You will need to specify the driver name in your connect string. For example: SQL server
DRIVER={SQL Server};SERVER=MySQLServer;DATABASE=pubs;UID=sa;PWD=admin;

MS Access
DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\data\mydb.mdb;

DAO (Data Access Objects)

DAO (Data Access Objects)


The DAO Data Control allows you to connect to your data source through the Visual Basic DAO libraries. DAO uses the Microsoft JET engine to process your SQL and manage your recordsets.

Connecting to Microsoft Access


1. Set the Connect property to Access from the dropdown list. 2. Set the DatabaseName property to the full pathname of your mdb file drive:\path\filename.mdb. 3. Set the RecordSource property to the name of a table, query, or a valid SQL statement. 4. If the Access Database is locked using a password, set the Connect property to:
";DATABASE=<database path and filename>;Pwd=< password>"

Connecting to ISAM files (dBase, FoxPro, Paradox)


1. Set the Connect property to the ISAM access type from the dropdown list. 2. Set the DatabaseName property to the data file path drive:\path. 3. Set the RecordSource property to a valid SQL statement.

Excel Files
1. Set the Connect property to the ISAM access type from the dropdown list. 2. Set the DatabaseName property to the full pathname of your xls file drive:\path\filename.xls. 3. Set the RecordSource property to the name of the table.

ADO (ActiveX Data Objects)

ADO (ActiveX Data Objects)


The ADO Data Control allows you to connect to your data sources using OLEDB libraries. To connect using ADO you must have an ADO provider installed on the machine.

Connecting to Microsoft Access using Jet 4.0


1. Right click on ADO Data Control >> Properties >> Click build button.

ActiveReports 2.0 Standard User's Guide | 52

2. Select Microsoft Jet 4.0 OLE DB Provider >> Click next. 3. Select or enter a database name >> Click test connection. 4. Click okay. 5. Enter a SQL statement into the source box (i.e. Select * from customers). 6. Click okay.

Connecting to SQL Server using SQLOLEDB


1. Right click on the ADO Data Control >> Properties >> Click Build Button. 2. Select Microsoft OLE DB Provider for SQL Server >> Click Next. 3. Select a server. 4. Choose Windows integrated security or a specific username and password. 5. Choose the database to connect to. 6. Click Test Connection >> Click okay. 7. Enter a SQL statement into the source box (i.e. Select * from customers). 8. Click okay. Note: For further help on connecting ADO data controls to data sources, please consult http://MSDN.Microsoft.com

XML

XML (Extensible Markup Language)


Connecting to an XML database: 1. Set the control's FileUrl property to an XML file or URL. 2. Enter an XSL pattern into the RecordSetPattern. The XSL pattern indicates the XML file nodes the report will iterate through when the report is generated. For example: the pattern //CUSTOMER would iterate through each CUSTOMER node in the XML file. The report will then use each node selected in the RecordSetPattern to create a detail section. Note: XML patterns are case sensitive. Typical XSL patterns:
Pattern Description

ActiveReports 2.0 Standard User's Guide | 53

//* //ITEM / //LAYOUT/ITEM/* //ITEM[@type] //ITEM[@id="1"]

All nodes All ITEM nodes Root item All child nodes of //LAYOUT/ITEM All item nodes that contain the type attribute All item nodes that have ID attribute value of "1"

As you change the RecordSetPattern, the indicators in the Fields List window will be updated to reflect the new nodes that will be used to iterate through the XML document. Note: In order to use the XML DataControl, MSXML3, or newer, is required to be on the system.

Setting Recordset and Connection Properties

Setting Recordset and Connection Properties


In addition to setting the connection and record source properties (source property for the ADO control) for data controls at design-time or run-time, you can set the Recordset property to a Recordset object at run-time. This allows ActiveReports to reuse the Recordset that you might have open in your VB application.
' Setting the recordset of a data control at run time Dim cn As ADODB.Connection ' ADO Connection Dim rs As ADODB.Recordset ' ADO Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\Program Files\Microsoft Visual" & _ "Studio\VB98\NWIND.MDB;Persist Security Info=False" rs.Open "SELECT * FROM Customers", cn '***************************************** 'DC1 is the name of the ADO data control * 'rptCustomers is the name of the report * '***************************************** rptCustomers.DC1.Recordset = rs rptCustomers.Show 'Preview the report

Binding Controls to a Data Control

Binding Controls to a Data Control


ActiveReports allows field controls, image controls and OLE object controls to be bound to fields in a data source control. When a report is run, ActiveReports reads each record from the data source and loads the bound field values into the control.

RDO/DAO/ADO Data Binding:


In relational databases, data binding is done through field names. The report assigns field names in the Recordset to each textbox control in the report. Controls are bound using DataField properties. You can select a DataField from the dropdown list in the property window. In addition to the above, you can use the Fields List Window to drag and drop fields on any of your report's sections. ActiveReports sets the name and DataField properties accordingly.

XML Data Binding:


In XML databases, the data is hierarchical, so data binding is done by specifying XPath expressions. For example: if the XML data control's RecordSetPattern is set to //ITEM, and the XML database has an address attribute attached to the ITEM node, the field's DataField property would be set to

ActiveReports 2.0 Standard User's Guide | 54 @address. ActiveReports will apply the @address XPath to the current ITEM node and assign the value to the control. When setting a control's DataField property, higher level nodes can be accessed by using "../" to move back one node. ActiveReports provides a powerful XPath builder. This allows reports to be built by dragging and dropping items from the Fields List browser to the report designer. Note: W3C XPath documents are located at:http://www.w3.org/TR/xpath, and a tutorial can be found at: http://www.zvon.org/xxl/XPathTutorial/General/examplesl

Chapter 5 - Bound Reporting and Grouping

Chapter 5 - Bound Reporting and Grouping


Simple Table or List Reports Using Parameters in Reports Grouping Records Grouping on a Calculated Expression Adding a Summary Field in the GroupFooter Conditional Summary Fields Using Formulas and Calculating Fields Page N of M in the PageFooter Page N of M in the GroupHeader

Simple Table or List Report

Simple Table or List Reports


The simplest reporting style is a tabular listing of fields from a record source. This sample demonstrates the basics for setting up bound reports by introducing the ideas of using a DataControl and connecting field controls through their DataField property. 1. Create a new Visual Basic EXE. 2. Add two command buttons to Form1. 3. Name the command buttons cmdPrint and cmdPreview. 4. Add ActiveReports to the project. 5. Place the following code under the command buttons on Form1:
Private Sub cmdPrint_Click() ActiveReport1.printreport false End Sub Private Sub cmdPreview_Click() ActiveReport1.show End Sub

6. Place an ADO data control on ActiveReport1. 7. Connect to Nwind.mdb (see Chapter 3 for help with connecting). Note: The samples in this manual use the NorthWind database included with Microsoft Visual Basic. 8. Set the DataControl's source property to the following SQL statement:
SELECT * FROM customers

9. Place 4 labels in the PageHeader section and set their properties as follows:

ActiveReports 2.0 Standard User's Guide | 55

Name Caption Height Left Top Width

lblCustomer Customer 270 0 0 2880

lblCity City 270 2970 0 2430

lblCountry Country 270 5490 0 1800

lblPostalCode Postal Code 270 7380 0 1800

10. Click on the PageHeader section and set its height property to 285. 11. Click the button in the fields list window to populate the fields list. 12. Click and drag the following fields from the fields list into the detail section: CompanyName, City, Country and PostalCode. 13. Set the field's properties as follows: Name DataField Height Left Top Width Alignment txtCompanyName CompanyName 270 0 0 2880 0-Left txtCity City 270 2970 0 2430 0-Left txtCountry Country 270 5490 0 1800 0-Left txtPostalCode Postal Code 270 7380 0 1800 1-Right

14. Run the project and click the Preview button on Form1.

Using Parameters With Bound Reports

Using Parameters in Reports


This sample demonstrates how to use parameters within a report's query string. Parameters allow reports to prompt users for specific bits of information so custom queries can be run. The syntax for setting up a parameter is as follows:
<%[Key Required]|[Caption Optional]|[Default Value Optional]%>

1. Continuing with the sample started above, make the following modification to the DataControl's source property:
SELECT * FROM customers WHERE customerID ="'<%customerID|Enter Customer ID:|ALFKI%>'"

2. Add the following code to the report to close the report if the parameter's dialog is cancelled.
Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) If Cancelled Then Me.Cancel Unload Me End If End Sub

Tip: The PromptDialogClosed event can also be used to validate or format parameters entered by the user. 3. Save and run the report. When the report is run, the parameter's dialog box will be displayed (shown below). The default value specified in the parameter's syntax is given along with the specified caption.

ActiveReports 2.0 Standard User's Guide | 56

Grouping Records

Grouping Records
Using the report we created in the first exercise, we will demonstrate grouping in ActiveReports. Reports can be grouped by using GroupHeaders/Footers with their DataField properties set to the database field being grouped on. ActiveReports allows up to 32 nested groupsin a single report. Note: ActiveReports does not order the records for grouping. It assumes the Recordset is already sorted in the same grouping order. For example, in this exercise, the data source needs to be sorted by Country to get the desired results. 1. Continuing with the report created in the first exercise, select the data control and modify the Source property as follows:
SELECT * FROM Customers ORDER BY Country

2. Select the report's Detail section. 3. Right-click and select Insert to add a Group Header/Footer. 4. Click on the new section "GroupHeader1" to select it. 5. Modify the section's properties as follows: Name DataField Height ghOrderGroup Country 360

Note: Setting the GroupHeader's DataField property is what causes ActiveReports to group. This tells ActiveReports to group on the Country field. Each time the value changes in the country field, ActiveReports will start a new group. 6. Click on the new section "GroupFooter1" to select it. 7. Modify the section's properties as follows: Name Height gfOrderGroup 270

8. Add a Field control to the ghOrderGroup section and set its properties as follows: Name DataField Height Left Top Width txtGroupCountry Country 360 0 0 4230

ActiveReports 2.0 Standard User's Guide | 57

Font.Size Font.Bold

12 True

9. Run the project and press "Preview" to see your report grouped by Country.

Grouping on Calculated Expression

Grouping on a Calculated Expression


Many reports require grouping based on a calculated expression such as the first letter in a company's name or total product sales ranges. This type of grouping can be achieved in ActiveReports by setting the GroupHeader's GroupValue property. Note: In order to get correct grouping the data source should be sorted by the grouped fields. Continuing with the project above, we can easily convert the project to group by the first letter of the Company Name. 1. Modify the Data Control's Source property to order the Recordset by CompanyName.
SELECT * FROM Customers ORDER BY CompanyName

2. Change the name of txtCountry to txtCompanyInitial. 3. Change the ghOrderGroup's DataField property to CompanyInitial. 4. Add the following code to the DataInitialize event:
Private Sub ActiveReport_DataInitialize() Me.Fields.Add "CompanyInitial" End Sub

5. Add the following code to the FetchData event:


Private Sub ActiveReport_FetchData(EOF As Boolean) Me.Fields("CompanyInitial").Value = Left(Me.Fields("CompanyName").Value, 1) End Sub

6. Run the project and press "Preview" to see your report using the GroupValue to group the records by the first letter of each company.

Adding a Summary Field in Group Footer

Adding a Summary Field in the Group Footer


Summary fields can be added to any section to calculate totals, counts, averages and other aggregations. The summary field's placement dictates when the section containing the field, and sections after it, will be printed. A section with a summary field will be delayed until all the calculations are completed. This allows summary fields to be place ahead of their detail. Summary fields are calculated according to the field control's Summary properties. A summary field control is updated with each new detail record. When a field is placed ahead of the detail section (ReportHeader, PageHeader or GroupHeader), the detail section is formatted with each record and the summary field is updated. When all records for the summary level are read, the header section is printed followed by the delayed sections. Summary fields are controlled by the following field control properties:

SummaryType
Specifies where the field's calculations will be done. The summary types are: GrandTotal Calculates the summary expression once for all detail records in the report. PageTotal Calculates the summary expression once for each page. SubTotal Calculates the summary expression once per SummaryGroup section.

ActiveReports 2.0 Standard User's Guide | 58

SummaryFunc
Sets the type of aggregation the summary field will use to calculate its total. Summary function can be set to Sum, Average, Count, Min, Max, Variance and Standard Deviation. In addition, you can set the summary function to calculate based on another field's distinct values. Distinct summarization is valuable when the field's value repeats in several detail records and the summary function needs to include a single value from all repeating values. For example, transaction records of orders might look like this.
Order ID 1001 1001 1001 1002 1002 Date 5/16/97 5/30/97 6/15/97 4/20/97 4/30/97 Amount 3000 -500 -2500 2550 -2500

A Count summary function would calculate 5 as the number of records. However, a distinct count on the SummaryDistinct Order ID field would properly return 2 as the number of orders. The same would apply for other distinct functions.

SummaryGroup
Calculates a subtotal summary for the indicated group. It defines the group section level from which a subtotal should be calculated. It is usually the matching group header section associated with the section where the summary field is placed.

SummaryRunning
Calculates running totals that accumulate with each printing and reset at the specified level. ddSRGroup - Keeps a running total of the specified field within a single group span. ddSRALL - Keeps a running summary throughout the whole report. In this exercise, we will count the number of customers in each group from the previous report. We will add a summary field in the group footer gfOrderGroup. 1. Start by opening the previous project. 2. Set the gfOrderGroup section height to 285. 3. Add a label control to the gfOrderGroup section and set its properties as follows: Name Caption Height Left Top Width lblGFooter "Number of Customers" 270 0 0 2070

4. Add Field control to the gfOrderGroup section and set its properties as follows: Name Height Left Top txtCustomerCount 270 2160 0

ActiveReports 2.0 Standard User's Guide | 59

Width

1980

5. Set the txtCustomerCount properties as follows: DataField SummaryFunc SummaryGroup SummaryType Alignment CompanyName 2-ddSFCount ghOrderGroup 3-ddSMSubTotal 1-ddTXRight

6. Run the project and select Preview to see the new report with a customer count in each group.

Conditional Summary Fields

Conditional Summary Fields


Some reports require totals, counts, or other summary formulas based on a certain condition. For example, if a data set has employee sales to different countries on a particular date, you might want to print the total sales for each country in the group footer without grouping the record on the Country field.

Sales For: 6/5/1996


Last Name Leverling First Name Janet Country USA Sales 1000

Leverling Davolio Davolio

Janet Nancy Nancy

UK USA UK

560 2000 1067

Sales For: 6/5/1996


Country USA UK USA UK Last Name Leverling Leverling Davolio Davolio First Name Janet Janet Nancy Nancy Total USA Total UK Sales 1000 560 2000 1067 3000 1672

This sample project demonstrates how to set up a report for conditional summaries by using variables to perform aggregate operations. 1. Create a new Visual Basic EXE. 2. Add two command buttons to Form1. 3. Name the command buttons cmdPrint and cmdPreview. 4. Add ActiveReports to the project. 5. Place the following code under the command buttons on Form1.

ActiveReports 2.0 Standard User's Guide | 60

Private Sub cmdPrint_Click() ActiveReport1.printreport false End Sub Private Sub cmdPreview_Click() ActiveReport1.show End Sub

6. Place an ADO data control on ActiveReport1. 7. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 8. Set the data control's source property to the following SQL statement.
SELECT DISTINCTROW Employees.Country, Employees.LastName, Employees.FirstName, Orders.ShippedDate, Orders.OrderID, [Order Subtotals].Subtotal AS SaleAmount FROM Employees INNER JOIN (Orders INNER JOIN [Order Subtotals] ON Orders.OrderID = [Order Subtotals].OrderID) ON Employees.EmployeeID = Orders.EmployeeID ORDER BY Orders.ShippedDate Desc

9. Right-click and insert a GroupHeader/Footer. 10. Click on the New Section "GroupHeader1" to select it. 11. Modify the section's properties as follows: Name DataField Height ghShippedDate ShippedDate 840

12. Click on the new section "GroupFooter1" to select it. 13. Modify the section's properties as follows: Name Height gfShippedDate 810

14. Add two text fields to gfShippedDate and modify their properties as follows: Name Height Left Top Width Alignment OutputFormat DataField SummaryFunc SummaryGroup SummaryRunning SummaryType txtTotalUSA 270 7740 90 1530 ddTxRight $###0.00 SalesUSA 0 - ddSFSum ghOrderGroup 1 - ddSRGroup 3 - ddSMSubTotal txtTotalUK 270 7740 450 1530 ddTxRight $###0.00 SalesUK 0 - ddSFSum ghOrderGroup 1 - ddSRGroup 3 - ddSMSubTotal

15. Add two labels to gfShippedDate and modify their properties as follows: Name Caption Height lblTotalUSA US Total Sales 270 lblTotalUK UK Total Sales 270

ActiveReports 2.0 Standard User's Guide | 61

Left Top Width Alignment Font.Bold

6120 90 1530 ddTxRight True

6120 450 1530 ddTxRight True

16. Click and drag the following fields from the fields list into the detail section: Country, LastName, FirstName and SaleAmount. 17. Set the field's properties as follows: Name DataField Height Left Top Width Alignment OutputFormat txtCountry Country 270 0 0 1440 ddTXLeft txtLastName LastName 270 1530 0 2520 ddTXLeft txtFirstName FirstName 270 4140 0 2790 ddTXLeft txtSaleAmount SaleAmount 270 7920 0 1440 ddTXRight $###0.00

18. Click and drag the following field from the field's list into ghShippedDate: ShippedDate. 19. Set the field's properties as follows: Name DataField Height Left Top Width Font.Size Font.Bold txtShippedDate ShippedDate 360 1620 0 2790 16 True

20. Add five labels to ghShippedDate and modify their properties as follows: Name Caption Height Left Top Width Font.Bold Font.Size Alignment lblSales Sales: 270 0 0 1530 True 16 ddTXRight lblCountry Country 270 0 540 1440 True lblLastName Last Name 270 1530 540 2520 True lblFirstName First Name 270 4140 540 2790 True lblSaleAmount Sales Amount 270 7830 540 1440 True

ActiveReports 2.0 Standard User's Guide | 62 21. Set the Detail section's CanShrink property to True. 22. Add the following code to the DataInitialize and FetchData events to increment an integer variable for each country's SaleAmount detail item:
Private Sub ActiveReport_DataInitialize() Me.Fields.Add "SalesUSA" Me.Fields.Add "SalesUK" End Sub Private Sub ActiveReport_FetchData(EOF As Boolean) If Me.Fields("Country").Value = "USA" Then Me.Fields("SalesUSA").Value = Me.Fields("SaleAmount").Value Me.Fields("SalesUK").Value = 0 ElseIf Me.Fields("Country").Value = "UK" Then Me.Fields("SalesUSA").Value = 0 Me.Fields("SalesUK").Value = Me.Fields("SaleAmount").Value Else Me.Fields("SalesUSA").Value = 0 Me.Fields("SalesUK").Value = 0 End If End Sub

Using Formulas and Calculated Fields

Using Formulas and Calculated Fields


In this example, we will create a new report that prints customers sales from the order details records. The report will be grouped and summarized by customer, and total sales will be calculated as the total of the quantity in each detail record multiplied by the product price. This example demonstrates the ability to use a field's DataField property to perform calculations. 1. Create a new ActiveReport as shown in the first tutorial. 2. Insert a ADO data control in the detail section. 3. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 4. Set the data control's source property to the following SQL statement:
SELECT Customers.CompanyName, [Order Details].UnitPrice, [Order Details].Quantity FROM Products INNER JOIN ((Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID WHERE (((DatePart("yyyy",[OrderDate]))=1995)) ORDER BY Customers.CompanyName, Products.ProductName

5. Insert a group header/footer section. 6. Set the GroupHeader properties as follows: Name DataField Height ghCustomer CompanyName 765

7. Add a field control to the ghCustomer section and set its properties as follows: Name DataField Height txtCompanyName CompanyName 360

ActiveReports 2.0 Standard User's Guide | 63

Left Top Width

0 0 5670

8. Add four labels to the ghCustomer section and set their properties as follows: Name Caption Height Left Top Width lblProductName Product Name 270 0 450 3330 lblQuantity Quantity 270 3420 450 1530 lblUnitPrice Unit Price 270 5040 450 1890 lblExtended Extended 270 7020 450 1620

9. Set the detail section height to 300 and add the following text controls: Name DataField Height Left Top Width OutputFormat txtProductName ProductName 270 0 0 3330 txtQuantity Quantity 270 3420 0 1530 Number txtUnitPrice UnitPrice 270 5040 0 1890 Currency 270 7020 0 1620 Currency txtExtended

10. Your report should look like this:

11. Set the DataField property for txtExtended to the following


= Quantity * UnitPrice

12. Run the project and click Preview to see the new report with the extended price calculation.

Page N of M in the Page Footer

Using Formulas and Calculated Fields Page N of M in the Page Footer


You can add page numbering to your report using the field's PageCount summary type. Page numbers are created using a running summary field.

ActiveReports 2.0 Standard User's Guide | 64 1. Add two text fields and two labels to your Page Footer section. 2. Set the following properties: First Field Name SummaryRunning SummaryType txtPageNumber 2-ddSRAll 4-ddSMPageCount

Second Field Name SummaryType txtPageCount 4-ddSMPageCount

First Label Name Caption Second Label Name Caption lblOf of lblPage Page

3. Your page footer should look like this:

When you preview your report, you should get a continuous n of m page count. Note: Using the PageCount causes all report sections to be delayed until the report is completed.

Page N of M in the Group Header

Page N of M in the Group Header


You can add page numbering to your groups by using the field's PageCount summary type. Page numbers are created using a running summary field. 1. Add two text fields and two labels to your Group Header section. 2. Set the following properties: First Field Name SummaryGroup SummaryRunning SummaryType txtPageNumber GroupHeader1 1-ddSRGroup 4-ddSMPageCount

Second Field

ActiveReports 2.0 Standard User's Guide | 65

Name SummaryGroup SummaryType First Label Name Caption

txtPageCount GroupHeader1 4-ddSMPageCount

lblPage Page

Second Label Name Caption lblOf of

3. When you preview your report, you should get a continuous n of m page count. Note: Using the PageCount causes all report sections to be delayed until the report is completed.

Chapter 6 - Unbound Reporting and Grouping

Chapter 6 - Unbound Reporting and Grouping


Unbound Reports Simple Unbound Reports Grouping with Unbound Reports Adding Summary Fields to Unbound Reports Unbound Reporting with Arrays Unbound Reporting with Collections Unbound Reporting with Text Files

Unbound Reports

Unbound Reports
ActiveReports gives you complete control to bind reports to any type of data source, including arrays, through its programmable object model. You can create a report without using a data control, and then load the data from your data source into the report's control at runtime. ActiveReports' Fields property allows data binding between the control and the run-time fields. It also allows the control's DataField property to be set to any of the run-time defined field names. The DataInitialize and FetchData events are used to define the run-time fields and feed the data values of these fields so they can be used with unbound controls. Note: These two events can also be used to create calculated fields in bound reports (reports that have a data control).

Simple Unbound Reports

Simple Unbound Reports


This sample demonstrates the fundamentals of using the DataInitialize and FetchData events to set up unbound reports. The DataInitialize event must be used to add fields to the report's fields

ActiveReports 2.0 Standard User's Guide | 66 collection and the FetchData event must be used to populate these fields with data. 1. Create a new ActiveReport as shown in the first tutorial. 2. Select the most current version of Microsoft's ActiveX Data Object Library in Visual Basic's reference list. 3. Place four labels in the PageHeader section and set their properties as follows: Name Caption Height Left Top Width Alignment lblCustomer Customer 270 0 0 2880 0-ddTXLeft lblCity City 270 2970 0 2430 0-ddTXLeft lblCountry Country 270 5490 0 1800 0-ddTXLeft lblPostalCode Postal Code 270 7380 0 1800 1-ddTXRight

4. Click on the PageHeader section and set its height property to 285. 5. Place four textboxes in the Detail section and set their properties as follows: Name Text DataField Height Left Top Width Alignment txtCustomer Customer Customer 270 0 0 2880 0-Left txtCity City City 270 2970 0 2430 0-Left txtCountry Country Country 270 5490 0 1800 0-Left txtPostalCode PostalCode PostalCode 270 7380 0 1800 1-Right

6. Click on the Detail section and set its height property to 285. 7. Add the following code to the report (Note: the path to the NWind database may need to be changed):

Dim cn As ADODB.Connection Dim rs As ADODB.RecordsetPrivate Sub ActiveReport_DataInitialize() Dim cnnStr As String ' Open data base here (called from form) Set cn = New ADODB.Connection Set rs = New ADODB.Recordset ' Add fields to ActiveReports' Fields Collection Fields.Add "Customer" Fields.Add "City" Fields.Add "Country" Fields.Add "PostalCode" ' Set Connection String and connect to DB cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft ' Set recordset properties and generate recordset rs.Open "SELECT * FROM customers ORDER BY CompanyName", cn End Sub Private Sub ActiveReport_FetchData(EOF As Boolean) ' Exit sub if EOF is true If rs.EOF=True Then Exit Sub EOF = False ' Sets ActiveReports' fields collection values to the ' current recordset value Fields("Customer").Value = rs!CompanyName

ActiveReports 2.0 Standard User's Guide | 67


Fields("City").Value = rs!City Fields("Country").Value = rs!Country Fields("PostalCode").Value = rs!PostalCode ' Advance recordset rs.MoveNext End Sub

8. Run the report.

Grouping With Unbound Reports

Grouping with Unbound Reports


Continuing with the report created in the first example, this sample will demonstrate how to set up grouping in unbound reports. When setting up grouping, the GroupHeader's DataField property is used in the same manner as a field control's to retrieve the grouping data from the database. 1. Modify the code's SQL statement to match the following: 2. Select the Detail Section in the report. 3. Right-click and Insert a Group Header/Footer. 4. Click on the new section "GroupHeader1" to select it. 5. Modify the section properties as follows: Name DataField Height ghOrderGroup Country 360

Note: The DataField property set here is what causes ActiveReports to group. This tells ActiveReports to group on the Country field. Each time the value changes in the country field, ActiveReports will start a new group. 6. Select all the fields from the PageHeader by holding "CTL" and clicking on each field. 7. Right-click on the selection and select "Cut". 8. Click on ghOrderGroup to select it. 9. Right-click on ghOrderGroup and select "Paste". 10. Run the report.

Adding Summary Fields to Unbound Reports

Adding Summary Fields to Unbound Reports


Continuing with the report created in the previous example, this sample will demonstrate how to add summary fields to unbound reports. 1. Click on GroupFooter1 and modify the section's properties as follows: Name Height gfOrderGroup 500

2. Place a textbox in the gfOrderGroup section. 3. Set the field's properties as follows: Name Text txtCustomerTotal CustomerTotal

ActiveReports 2.0 Standard User's Guide | 68

DataField Height Left Top Width Alignment SummaryFunction SummaryGroup SummaryRunning SummaryType

Customer 270 7380 0 1880 0-Right 2-ddSFCount ghOrderGroup 1-ddSRGroup 3-ddSMSubTotal

4. Place a label in the gfOrderGroup Section. 5. Set the label's properties as follows: Name Caption Height Left Top Width lblCustomerTotal Total Customers: 270 5760 0 1620

6. Run the report.

Unbound Reporting with Arrays

Unbound Reporting with Arrays


This sample demonstrates how to set up and use an array with ActiveReports. Reports using arrays use the FetchData and DataInitialize events in the same manner as unbound database reports. When using arrays, it is also important to make sure the report uses the FetchData event to increment the array. 1. Create a new ActiveReport as shown in the first tutorial. 2. Select the Detail Section in the report. 3. Right-click and Insert a Group Header/Footer. 4. Click on the new section "GroupHeader1" to select it. 5. Modify the section properties as follows: Name DataField Height BackColor BackStyle ghOrderGroup OrderID 690 &H00C0FFFF& 1-ddBKNormal

6. Place a textbox in the ghOrderGroup section.

ActiveReports 2.0 Standard User's Guide | 69 7. Set the field's properties as follows: Name Text DataField Height Left Top Width Font.Size txtOrderID Order ID OrderID 630 0 0 1440 14

8. Click on the Detail section and modify the section's properties as follows: Height BackColor BackStyle 270 &H00C0FFC0& 1-ddBKNormal

9. Place five textboxes in the Detail section and modify their properties as follows: Name DataField Height Left Top Width Alignment txtProductID ProductID 270 0 0 1440 1ddTXRight txtProductName ProductName 270 1440 0 2880 0-ddTXLeft txtQty Qty 270 4320 0 1440 1ddTXRight txtPrice Price 270 5760 0 1440 1ddTXRight txtAmount Amount 270 7200 0 1440 0ddTXLeft

10. Click on the GroupFooter1 section and modify the section's properties as follows: Name Height BackColor BackStyle gfOrderGroup 330 &H00FFFFC0& 1-ddBKNormal

11. Place a textbox in the gfOrderGroup section and modify the section's properties as follows: Name Text DataField Height Left Top Width txtOrderTotal OrderTotal Amount 270 7200 0 1440

ActiveReports 2.0 Standard User's Guide | 70

Alignment SummaryType 12. Add the following code to the report:


Option Explicit Public bLastIsSingle As Boolean Private arr(1 To 12) As OrderItem Private iRow As Integer Private tmpAmount As Currency Private bNewGroup As Boolean Private Type OrderItem OrderNo As Long ProductID As Long ProductName As String Qty As Integer Price As Currency Amount As Currency End Type

1-ddTXRight 1-ddSMGrandTotal

Private Sub ActiveReport_DataInitialize() Fields.Add "OrderID" Fields.Add "ProductID" Fields.Add "ProductName" Fields.Add "Qty" Fields.Add "Price" Fields.Add "Amount" iRow = LBound(arr) initarray End Sub Private Sub ActiveReport_FetchData(eof As Boolean) If iRow > UBound(arr) Then eof = True Exit Sub End If Fields("OrderID") = arr(iRow).OrderNo Fields("ProductID") = arr(iRow).ProductID Fields("ProductName") = arr(iRow).ProductName Fields("Qty") = arr(iRow).Qty Fields("Price") = arr(iRow).Price Fields("Amount") = arr(iRow).Amount ' It is important to set EOF to False if there are more records ' otherwise the default True value will be used and the report ' will stop eof = False iRow = iRow + 1 End Sub Public Sub InitArray() arr(1).OrderNo = 100 arr(1).ProductID = 1 arr(1).ProductName = "Hard Drive" arr(1).Qty = 1 arr(1).Price = 435 arr(1).Amount = arr(1).Qty * arr(1).Price arr(2).OrderNo = 100 arr(2).ProductID = 2 arr(2).ProductName = "CD ROM" arr(2).Qty = 1: arr(2).Price = 199 arr(2).Amount = arr(2).Qty * arr(2).Price arr(3).OrderNo = 100 arr(3).ProductID = 3 arr(3).ProductName = "32MB RAM" arr(3).Qty = 2: arr(3).Price = 85 arr(3).Amount = arr(3).Qty * arr(3).Price End Sub

13. Run the report.

ActiveReports 2.0 Standard User's Guide | 71

Unbound Reporting with Collections

Unbound Reporting with Collections


This sample demonstrates how to set up and use a collection with ActiveReports. Reports using collections use the FetchData and DataInitialize events in the same manner as unbound database reports. When using a collection, it is also important to make sure the report uses the FetchData event to increment the collection. 1. Continuing with the project started in the last example, add two classes to the project and set their properties as follows: Name Order Orders

2. Add the following code to the Order class:


Option Public Public Public Public Public Explicit Key As String ProductID As Long ProductName As String Qty As Integer Price As Currency

3. Add the following code to the Orders class:


Option Explicit 'local variable to hold collection Private mCol As Collection Public Function Add(Key As String, Optional sKey As String) As Order 'create a new object Dim objNewMember As Order Set objNewMember = New Order 'set the properties passed into the method objNewMember.Key = Key If Len(sKey) = 0 Then mCol.Add objNewMember Else mCol.Add objNewMember, sKey End If 'return the object created Set Add = objNewMember Set objNewMember = Nothing End Function Public Property Get Item(vntIndexKey As Variant) As Order 'used when referencing an element in the collection 'vntIndexKey contains either the Index or Key to the collection, 'this is why it is declared as a Variant 'Syntax: Set foo = x.Item(xyz) or Set foo = x.Item(5) Set Item = mCol(vntIndexKey) End Property Public Property Get Count() As Long 'used when retrieving the number of elements in the 'collection. Syntax: Debug.Print x.Count Count = mCol.Count End Property Public Sub Remove(vntIndexKey As Variant) 'used when removing an element from the collection 'vntIndexKey contains either the Index or Key, which is why 'it is declared as a Variant 'Syntax: x.Remove(xyz) mCol.Remove vntIndexKey End Sub

ActiveReports 2.0 Standard User's Guide | 72


Public Property Get NewEnum() As IUnknown 'this property allows you to enumerate 'this collection with the For...Each syntax Set NewEnum = mCol.[_NewEnum] End Property Private Sub Class_Initialize() 'creates the collection when this class is created Set mCol = New Collection End Sub Private Sub Class_Terminate() 'destroys collection when this class is terminated Set mCol = Nothing End Sub

4. Change the report's code to match the following:


Option Explicit Public bLastIsSingle As Boolean Private colOrders As New Orders Private Sub ActiveReport_DataInitialize() Fields.Add "OrderID" Fields.Add "ProductID" Fields.Add "ProductName" Fields.Add "Qty" Fields.Add "Price" Fields.Add "Amount" InitCollection End Sub Private Sub ActiveReport_FetchData(eof As Boolean) Static i As Integer i = i + 1 If i > colOrders.Count Then eof = True Exit Sub Else eof = False End If Fields("OrderID").Value = colOrders.Item(i).Key Fields("ProductID").Value = colOrders.Item(i).ProductID Fields("ProductName").Value = colOrders.Item(i).ProductName Fields("Qty").Value = colOrders.Item(i).Qty Fields("Price").Value = colOrders.Item(i).Price Fields("Amount").Value = colOrders.Item(i).Qty * colOrders.Item(i).Price End Sub Public Sub InitCollection() Dim o As Order With colOrders Set o = .Add("100") o.ProductID = 1 o.ProductName = "Hard Drive" o.Qty = 1: o.Price = 435 Set o = .Add("100") o.ProductID = 2 o.ProductName = "CD ROM" o.Qty = 1 o.Price = 199 Set o = .Add("100") o.ProductID = 3 o.ProductName = "32MB RAM" o.Qty = 2 o.Price = 85 End With End Sub

5. Run the report.

Unbound Reporting with Text Files

ActiveReports 2.0 Standard User's Guide | 73

Unbound Reporting with Text Files


This sample demonstrates how to set up and use a text file with ActiveReports. Reports using text files use the FetchData and DataInitialize events in the same manner as unbound database reports. 1. Create a new ActiveReport as shown in the first tutorial. 2. Select the PageHeader section and set the section's height to 270. 3. Place four labels in the PageHeader and set their properties as follows: Name Caption Height Left Top Width lblProductID Product ID 270 0 0 1350 lblProductName Product Name 270 1440 0 3780 lblQtyPerUnit Qty Per Unit 270 5310 0 2520 lblPrice Price 270 7920 0 1350

4. Select the Detail section and set the section's height to 270. 5. Place four textboxes in the Detail section and set their properties as follows: Name Text DataField Height Left Top Width Alignment txtProductID ProductID ProductID 270 0 0 1350 1-Right txtProductName ProductName ProductName 270 1440 0 3780 0-Left txtQtyPerUnit QtyPerUnit QuantityPerUnit 270 5310 0 2520 0-Left txtPrice Price Price 270 7920 0 1350 1-Right

6. Add the following code to the Report:


Option Explicit Private hFile As Integer Private Sub ActiveReport_DataInitialize() hFile = FreeFile Open App.Path & "\Products.txt" For Input As #hFile ' This sets up the fields used in data binding Fields.Add "ProductID" Fields.Add "ProductName" Fields.Add "QuantityPerUnit" Fields.Add "UnitPrice" End Sub Private Sub ActiveReport_FetchData(eof As Boolean) Dim sLine As String Dim arr() As String ' ' ' ' ' ' ' ' We reached the end of the file we exit leaving the eof parameter as True (default except on first call) that will tell AR that we are done feeding data otherwise we have to set the eof parameter to False so that AR continues fetching data, until we're done if the report had a data control, the value of the parameter will be ignored, AR will always follow the data control's recordset EOF property

ActiveReports 2.0 Standard User's Guide | 74


If VBA.eof(hFile) Then eof = True Exit Sub Else eof = False End If Line Input #hFile, sLine arr = Split(sLine, ",") ' Here we set the values of the fields that we defines as unbound ' or user defined. Fields("ProductID").Value = Val(arr(0)) Fields("ProductName").Value = arr(1) Fields("QuantityPerUnit").Value = arr(4) Fields("UnitPrice").Value = arr(5) End Sub Private Sub ActiveReport_ReportEnd() If hFile <> 0 Then Close #hFile End If End Sub

7. Create a text file named Products.txt in the project's directory. 8. Add the following entries to the text file:
1,Chai,1,1,10 boxes x 20 bags,$18.00,39,0,10,0 2,Chang,1,1,24 - 12 oz bottles,$19.00,17,40,25,0 3,Aniseed Syrup,1,2,12 - 550 ml bottles,$10.00,13,70,25,0

9. Run the report.

Chapter 7 - Using Subreports

Chapter 7 - Using Subreports


Subreports Bound Subreports Using Parameters with Subreports Embedded Subreports Shaped/Hierarchical Subreports Unbound Subreports

Subreports

Subreports
ActiveReports allows reports to contain any number of child reports by using the Subreport control. Child reports, or Subreports, are executed each time their parent section (the section in which the Subreport control is placed) is printed. You can use subreports to print any of the following types of reports.
l l

Related child reports that contain data from a source different from the main report. Related or unrelated lists to be printed in parallel horizontally or vertically. For example, use subreports to print a list of top 10 products, top 10 customers and top 10 employees. Each of these lists can be printed using a separate child report.

Note: Subreports can be nested within each other where a child report can contain a Subreport control which links to grand-child and so on. Subreports print only their group and detail sections Page headers and footer are not printed in the parent report.

ActiveReports 2.0 Standard User's Guide | 75

Adding a Subreport
To insert a Subreport into your report: 1. Click the Subreport control on the toolbox. 2. Place the control in the section where the Subreport will be printed. The Subreport will be executed each time the specified section is printed. Note: The Subreport will be confined by the width of the control, but the height will grow according the needs of the Subreport.

Linking a Subreport to the Main Report


Each Subreport must link to the Subreport control's object property at run time. ActiveReports cannot instantiate the child report directly. So the Subreport control's object property is used to instantiate the child report.

Bound Subreports

Bound Subreports
The following sample demonstrates the fundaments for using subreports. The sample demonstrates how to set the Subreport control's object property to the child report, and how to modify the child report's record source based off of the data in the parent report to retrieve the correct information. Add two new ActiveReports to a project, as shown in the first tutorial, and set their properties as follows:
Name rptSupplier rptProducts

With rptSupplier
1. Insert a ADO data control in the detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 3. Set the data control's source property to the following SQL statement:
SELECT * FROM suppliers ORDER BY country

4. Insert a Group Header/Footer section. 5. Set the GroupHeader's properties as follows: Name DataField Height ghCountry Country 735

6. Place a textbox in the ghCountry section and set its properties as follows: Name DataField Height Left Top Width Font.Size Font.Bold txtCountry Country 360 0 0 2790 17 True

ActiveReports 2.0 Standard User's Guide | 76 7. Place three labels in the ghCountry section and set their properties as follows: Name Caption Height Left Top Width Font.Bold lblCompanyName Company Name 270 0 450 5040 True lblContact Contact 270 5220 450 2070 True lblPhoneNumber Phone Number 270 7470 450 1890 True

8. Set the Detail section's height to 1110. 9. Place three textboxes in the Detail section and set their properties as follows: Name Text DataField Height Left Top Width ForeColor txtCompanyName CompanyName CompanyName 270 0 90 5040 &HOOCOOO8& txtContactName ContactName ContactName 270 5130 90 2160 &HOOCOOO8& txtPhoneNumber PhoneNumber PhoneNumber 270 7380 90 1980 &HOOCOOO8&

10. Place a Subreport control in the Detail Section and set its properties as follows: Name Height Left Top Width subProducts 360 0 450 9360

11. Add the following code to rptSupplier:


Dim i_SupID As Integer Private Sub ActiveReport_FetchData(EOF As Boolean) 'Get the current records supplier ID If Not Me.DataControl1.Recordset.EOF Then i_SupID = Me.DataControl1.Recordset!supplierID End If End Sub Private Sub ActiveReport_ReportEnd() Unload subProducts.object Set subProducts.object = Nothing End Sub Private Sub ActiveReport_ReportStart() Set subProducts.object = New rptProducts End Sub Private Sub Detail_Format() 'Sets the subreport's recordsource to the current supplier

ActiveReports 2.0 Standard User's Guide | 77


subProducts.object.DataControl1.Source = "SELECT * FROM products INNER _ JOIN categories ON products.categoryid = categories.categoryid _ WHERE products.supplierID = " & i_SupID End Sub

With rptProducts
1. Insert a ADO data control in the detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 3. Set the data control's source property to the following SQL statement:
SELECT * FROM products INNER JOIN categories ON products.categoryid = categories.categoryid

4. Remove the PageHeader/Footer section. 5. Insert a GroupHeader/Footer section. 6. Set the GroupHeader's properties as follows: Name DataField Height BackColor BackStyle ghCategory products.CategoryID 300 &H00C0FFFF& 1-Normal

7. Place two textboxes in the ghCategory section and set their properties as follows: Name DataField Height Left Top Width Font.Size Font.Bold txtCategoryName CategoryName 270 0 0 2880 11 True txtDescription Description 270 2970 0 6210 10 True

8. Set the GroupFooter's height to 0. 9. Set the Detail section's properties as follows: Height BackColor BackStyle 330 &H00C0E0FF& 1-Normal

10. Place three textboxes in the Detail section and set their properties as follows: Name Text DataField Height Left txtProductName ProductName ProductName 270 1620 txtUnitsInStock UnitsInStock UnitsInStock 270 6210 txtUnitPrice UnitPrice UnitPrice 270 8370

ActiveReports 2.0 Standard User's Guide | 78

Top Width OutputFormat

0 2970

0 1080

0 990 Currency

11. Place three labels in the Detail Section and set their properties as follows: Name Caption Height Left Top Width Font.Bold lblProductName Product Name: 270 0 0 1530 True lblUnitsInStock Units In Stock: 270 4680 0 1530 True lblUnitPrice UnitPrice: 270 7290 0 1080 True

12. Run the report.

Using Parameters with Subreports

Using Parameters with Subreports


Parameters can be used with subreports to connect the Subreport to the parent report. By setting a parameter for the field that links the parent report to the child report, the parent report can pass the information to the child through the parameters. The main difference when working with subreports is that the Subreport's ShowParametersUI should be set to false. By adding the following modification to the above code, the previous sample can be adapted to use parameters:

With rptProducts
1. Set the ShowParametersUI to False. 2. Modify the DataControl's source property to match the following:
"SELECT * FROM products INNER JOIN categories ON products.categoryid = categories.categoryid WHERE products.supplierID = <%supplierID%>"

With rptSuppliers
1. Comment out the code in the detail section. 2. Save and run the report.

Embedded Subreports

Embedded Subreports
The following sample demonstrates how to set up embedded subreports. When setting up embedded subreports, the principles are the same as setting up a parent-child report, but applied to the childgrandchild reports. Add three new ActiveReports to a project, as shown in the first tutorial, and set their properties as follows:
Name rptCustomers rptEmployees rptOrders

With rptEmployees

ActiveReports 2.0 Standard User's Guide | 79 1. Insert a ADO data control into the Detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 3. Set the data control's source property to the following SQL statement:
SELECT * FROM Employees

4. Remove the PageHeader/Footer section. 5. Insert a GroupHeader/Footer section. 6. Set the GroupHeader's properties as follows: Name DataField Height BackColor BackStyle Repeat ghEmployee EmployeeID 690 &H00FF8080& 1-Normal 1-Every Page

7. Place four textboxes in the ghEmployee section and set their properties as follows: Name DataField Height Left Top Width ForeColor txtEmployeeID EmployeeID 270 1440 90 1440 White txtExtension Extension 270 5760 90 1440 White txtLastName LastName 270 1440 360 2790 White txtFirstName FirstName 270 5760 360 3420 White

8. Place four labels in the ghEmployee section and set their properties as follows: Name Caption Height Left Top Width Font.Bold ForeColor lblEmployeeID Employee ID: 270 90 90 1350 True White lblExtension Extension: 270 4320 90 1350 True White lblLastName Last Name: 270 90 360 1350 True White lblFirstName First Name: 270 4320 360 1350 True White

9. Set the GroupFooter's height to 0. 10. Set the Detail section's properties as follows: Height CanShrink 900 True

11. Place a Subreport control in the Detail section and set its properties as follows:

ActiveReports 2.0 Standard User's Guide | 80

Name Height Left Top

subOrders 900 0 0 9360

Width 12. Add the following code to rptEmployees:


Dim empID As Integer Private Sub ActiveReport_FetchData(EOF As Boolean) ' Store the current records employee ID If Not DataControl1.Recordset.EOF Then empID = DataControl1.Recordset!employeeID End If End Sub Private Sub ActiveReport_ReportEnd() ' Unload the subreport's object Unload subOrders.object Set subOrders.object = Nothing End Sub Private Sub ActiveReport_ReportStart() ' Set the subreport control's object the a new rptOrder Set subOrders.object = New rptOrders End Sub

Private Sub Detail_Format() Dim s_SQL As String 'Set the SQL string for the rptOders recordset s_SQL = "SELECT DISTINCT Products.ProductName, Products.ProductID, _ Orders.*, [Order Details].*" s_SQL = s_SQL & " FROM Products INNER JOIN (Orders INNER JOIN _ [Order Details] ON Orders.OrderID = [Order Details].OrderID)" s_SQL = s_SQL & " ON Products.ProductID = [Order Details].ProductID_ Where orders.EmployeeID = " s_SQL = s_SQL & empID & " Order By products.ProductName, _ [order details].quantity desc" subOrders.object.DataControl1.Source = s_SQL End Sub

With rptOrders
1. Insert a ADO data control into the Detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 3. Set the data control's source property to the following SQL statement:
SELECT Products.ProductName, Products.ProductID,Orders.*, [Order Details].* FROM Products INNER JOIN (Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID

4. Remove the PageHeader/Footer section. 5. Insert a GroupHeader/Footer section. 6. Set the GroupHeader's properties as follows: Name DataField Height GroupKeepTogether KeepTogether ghOrders Orders.OrderID 555 2-All True

ActiveReports 2.0 Standard User's Guide | 81

BackColor BackStyle

&H008080FF& 1-Normal

7. Place three textboxes in the ghOrders section and set their properties as follows: Name DataField Height Left Top Width ForeColor txtProductName ProductName 270 1080 180 3150 &H00FF0000& txtOrderDate OrderDate 270 5220 180 1440 &H00FF0000& txtQuantity Quantity 270 7650 180 1440 &H00FF0000&

8. Place three labels in the ghOrders section and set their properties as follows: Name Caption Height Left Top Width Font.Bold ForeColor lblProduct Product: 270 90 180 990 True &H00FF0000& lblDate Date: 270 4320 180 900 True &H00FF0000& lblQuantity Quantity: 270 6660 180 990 True &H00FF0000&

9. Set the GroupFooter's height to 0. 10. Set the Detail section's properties as follows: Height CanShrink 900 True

11. Place a Subreport control in the Detail section and set its properties as follows: Name Height Left Top Width subCustomers 900 0 0 9360

12. Add the following code to rptOrders:


Dim custID As String Private Sub ActiveReport_FetchData(EOF As Boolean) ' Store the current records customer ID If Not DataControl1.Recordset.EOF Then custID = DataControl1.Recordset!customerID

ActiveReports 2.0 Standard User's Guide | 82


End If End Sub Private Sub ActiveReport_ReportEnd() ' Unload the subreport's object Unload subCustomers.object Set subCustomers.object = Nothing End Sub Private Sub ActiveReport_ReportStart() ' Set the subreport control's object the a new rptOrder Set subCustomers.object = New rptCustomers End Sub Private Sub Detail_Format() On Error GoTo errHndl 'Set the SQL string for the rptOders recordset subCustomers.object.DataControl1.Source = "Select * from customers _ where customerID = '" & custID & "'" Exit Sub errHndl: Resume Next End Sub

With rptCustomers
1. Insert a ADO data control into the Detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting) 3. Set the data control's source property to the following SQL statement:
select * from customers

4. Remove the PageHeader/Footer section. 5. Insert a GroupHeader/Footer section. 6. Set the GroupHeader's properties as follows: Name Height BackColor BackStyle ghCustomers 60 &H0080C0FF& 1-Normal

7. Set the GroupFooter's properties as follows: Name Height BackColor BackStyle gfCustomers 60 &H0080C0FF& 1-Normal

8. Set the Detail section's properties as follows: Height CanShrink BackColor BackStyle 1110 True &H0080C0FF& 1-Normal

9. Place six textboxes in the Detail section and set their properties as follows:

ActiveReports 2.0 Standard User's Guide | 83

Name DataField Height Left Top Width CanShrink

txtCompanyName CompanyName 270 1170 0 7560 True

txtContactName ContactName 270 1170 270 3150 True

txtPhone Phone 270 5850 270 2880 True

txtAddress Address 270 1170 540 7560 True

txtCity City 270 1170 810 3150 True

txtPostalCode PostalCode 270 5850 810 2880 True

10. Place six labels in the Detail section and set their properties as follows: Name Caption Height Left Top Width Font.Bold lblCompanyName Company Name: 270 90 0 1080 True lblContactName Contact Name: 270 90 270 1080 True lblPhone Phone: 270 4320 270 1530 True lblAddress Address: 270 90 540 1080 True lblCity City: 270 90 810 1080 True lblPostalCode Postal Code: 270 4320 810 1440 True

11. Run the report.

Shaped/Hierarchical Subreports

Shaped/Hierarchical Subreports
This sample demonstrates how to set up a report and subreports to use Hierarchical Recordset. The example shows how to pass the shaped Recordset to the child reports by setting the Subreport's Recordset to the shaped child Recordset. Add three new ActiveReports to a new project, as shown in the first tutorial, and set their properties as follows:
Name rptCustomers rptEmployees rptOrders

With rptOrders
1. Insert a ADO data control into the Detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 3. Set the data control's source property to the following SQL statement:
SELECT * FROM Orders

4. Select the newest Microsoft ActiveX Data Object Library from Visual Basic's reference list. 5. Remove the PageHeader/Footer section. 6. Insert a GroupHeader/Footer section. 7. Set the GroupHeader's properties as follows: Name DataField Height BackColor ghOrders OrderID 810 &H00800000&

ActiveReports 2.0 Standard User's Guide | 84

BackStyle

1-Normal

8. Place six textboxes in the ghOrders section and set their properties as follows: Name DataField Height Left Top Width ForeColor OutputFormat txtShippedDate ShippedDate 270 1440 0 1440 White txtRequiredDate RequiredDate 270 4320 0 1440 White txtShipName ShipName 270 1440 270 4320 White txtFreight Freight 270 7830 270 1350 White Currency txtShipAddress ShipAddress 270 1440 540 5580 White

9. Place Six labels in the ghOrders section and set their properties as follows: Name Caption Height Left Top Width ForeColor Font.Bold lblShipped Shipped: 270 90 0 1350 White True lblRequired Required: 270 3060 0 1260 White True lblShipName Ship Name: 270 90 270 1350 White True lblCost Cost: 270 7200 270 630 White True lblAddress Address: 270 90 540 1350 White True lblCity City: 270 7200 540 630 White True

10. Set the GroupFooter's height to 60. 11. Set the Detail section's properties as follows: Height BackColor BackStyle 1065 &H00000080& 1-Normal

12. Place two Subreport controls in the Detail section and set their properties as follows: Name Height Left Top Width subCustomers 450 0 0 9180 subEmployees 360 0 540 9180

13. Add the following code to rptOrders:


Private Sub ActiveReport_DataInitialize() On Error GoTo errHndl Dim rs As ADODB.Recordset Dim sConnect As String

ActiveReports 2.0 Standard User's Guide | 85


Dim sSQL As String Dim sProgress As String Dim cn As ADODB.Connection Set rs = New ADODB.Recordset Set cn = New ADODB.Connection ' Open hierarchical recordset: ' -rsOrders ' -rsCustomers ' -rsEmployees sConnect = "Data Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=NWIND.MDB" & _ cn.Provider = "MSDataShape" cn.Open sConnect sSQL = "SHAPE {SELECT * FROM orders} AS rsOrders" sSQL = sSQL & " APPEND " & _ "({SELECT * FROM customers WHERE CustomerID = ?} " sSQL = sSQL & " RELATE CustomerID TO PARAMETER 0) AS rsCustomers, " sSQL = sSQL & " ({SELECT * FROM Employees WHERE EmployeeID = ?} " sSQL = sSQL & " RELATE EmployeeID TO PARAMETER 0) AS rsEmployee" rs.StayInSync = False rs.Open sSQL, cn Set Me.DataControl1.Recordset = rs Set Me.subEmployees.object = New rptEmployees Set Me.subCustomers.object = New rptCustomers errHndl: Debug.Print Err.Number & Err.Description Unload Me End Sub Private Sub Detail_Format() On Error GoTo errhndler Dim rsCust As ADODB.Recordset Dim rsEmp As ADODB.Recordset Set Set Set Set Exit Sub errhndler: Debug.Print Err.Number & Err.Description End Sub rsCust = DataControl1.Recordset.Fields("rsCustomers").Value.Clone rsEmp = DataControl1.Recordset.Fields("rsEmployee").Value.Clone subCustomers.object.sourceRecordSet = rsCust subEmployees.object.sourceRecordSet = rsEmp

With rptCustomers
1. Insert a ADO data control into the Detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 3. Set the data control's source property to the following SQL statement:
SELECT * FROM Customers

4. Remove the PageHeader/Footer section. 5. Set the Detail section's properties as follows: Height CanShrink BackColor BackStyle 585 True &H00000080& 1-Normal

6. Place two textboxes in the Detail section and set their properties as follows:

ActiveReports 2.0 Standard User's Guide | 86

Name DataField Height Left Top Width ForeColor

txtContactName ContactName 270 1530 0 7110 White

txtCompanyName CompanyName 270 1530 270 7110 White

7. Place two labels in the Detail section and set their properties as follows: Name Caption Height Left Top Width ForeColor Font.Bold lblOrderedBy Ordered By: 270 0 0 1440 White True lblFor For: 270 0 270 1440 White True

8. Add the following code to rptCustomers:


Option Explicit Private Enum ERRS ERRS_VBINVALIDPROPERTYVALUE = 380 End Enum Public Property Set sourceRecordSet(ByVal rs As ADODB.Recordset) On Error GoTo errhndler If rs Is Nothing Then Err.Raise ERRS_VBINVALIDPROPERTYVALUE, "rptCustomers.<Property _ End If Set Me.DataControl1.Recordset = rs Exit Property errhndler: Debug.Print Err.Number & Err.Description End Property

With rptEmployees
1. Insert an ADO data control into the Detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 3. Set the data control's source property to the following SQL statement:
SELECT * FROM Employees

4. Remove the PageHeader/Footer section. 5. Set the Detail section's properties as follows: Height CanShrink BackColor 300 True &H00000080&

ActiveReports 2.0 Standard User's Guide | 87

BackStyle

1-Normal

6. Place two textboxes in the Detail section and set their properties as follows: Name DataField Height Left Top Width ForeColor txtFirstName FirstName 270 1620 0 1080 White txtLastName LastName 270 2700 0 1440 White

7. Place a label in the Detail section and set its properties as follows: Name Caption Height Left Top Width ForeColor Font.Bold lblProcessedBy Processed By: 270 0 0 1530 White True

8. Add the following code to rptCustomers:


Option Explicit Private Enum ERRS ERRS_VBINVALIDPROPERTYVALUE = 380 End Enum Public Property Set sourceRecordSet(ByVal rs As ADODB.Recordset) On Error GoTo errhndler If rs Is Nothing Then Err.Raise ERRS_VBINVALIDPROPERTYVALUE, "rptEmployee.<Property _ Set> sourceRecordSet" End If Set Me.DataControl1.Recordset = rs Exit Property errhndler: Debug.Print Err.Number & Err.Description End Property

9. Run the report.

Using the SubReport's DataField Property


ActiveReports 2.0 also provides an easier way to used shaped/hierarchical recordsets by using the Subreport control's DataField property. The report generated above can also be created by setting subCustomers'DataField property to rsCustomers and subEmployees' DataField property to rsEmployee. After setting these properties, the code in the parent report's Detail_Format and all the code in the child reports are not needed.

ActiveReports 2.0 Standard User's Guide | 88

Unbound Subreports

Unbound Subreports
This sample demonstrates how to set up unbound subreports by passing information and search criteria from the parent report to the Subreport. This sample demonstrates two different methods for passing the Recordset. One method is to clone the recordset and the second is to establish a new Recordset in the Subreport. When working with unbound reports, it is important to use the DataInitialize and FetchData events to add fields to the report's field collection and retrieve data from the database. 1. Add three new ActiveReports to a new project as shown in the first tutorial and set their properties as follows: Name rptCustomers rptCustomersClone rptOrders

2. Select the most current version of Microsoft's ActiveX Data Object Library in Visual Basic's reference list.

With rptCustomers
1. Remove the PageHeader/Footer section. 2. Insert a GroupHeader/Footer section. 3. Set the GroupHeader's properties as follows: Name DataField Height CanShrink GrpKeepTogether KeepTogether Repeat Font.Bold ghCountry Country 810 True 2-All True 1-Every Page True

4. Place a textbox in the ghCountry section and set its properties as follows: Name DataField Height Left Top Width Font.Size Font.Bold txtCountry Country 540 0 0 2880 22 True

5. Place three labels in the ghCountry section and set their properties as follows: Name Caption lblCustomer Customer lblCity City lblPostalCode Postal Code

ActiveReports 2.0 Standard User's Guide | 89

Height Left Top Width Font.Bold

270 0 540 2880 True

270 2880 540 2800 True

270 5760 540 1800 True

6. Set the GroupFooter's height to 60. 7. Set the Detail section's properties as follows: Height KeepTogether 630 True

8. Place a Subreport control in the Detail section and set its properties as follows: Name Height Left Top Width subCustomersClone 630 0 0 9360

9. Add the following code to rptCustomers:


Public cn As ADODB.Connection Dim rs As ADODB.Recordset Public myCloneRS As ADODB.Recordset Private s_Country As String Private Sub ActiveReport_DataInitialize() Dim cnnStr As String ' Open data base here (called from form) Set cn = New ADODB.Connection Set rs = New ADODB.Recordset Set myCloneRS = New ADODB.Recordset ' Add fields to ActiveReports' Fields Collection Fields.Add "Country" ' Set Connection String and connect to DB cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program _ Files\Microsoft Visual Studio\VB98\NWind.mdb" cn.Open cnnStr ' Set recordset properties and generate recordset rs.CursorType = adOpenStatic rs.LockType = adLockOptimistic rs.Open "Select * from customers order by Country", cn ' Create a clone of the current recordset to use in the subreport Set myCloneRS = rs.Clone End Sub Private Sub ActiveReport_FetchData(EOF As Boolean) ' Exit sub if EOF is true If rs.EOF Then Exit Sub ' Sets ActiveReports' fields collection values to the ' current recordset value Fields("Country").Value = rs!country s_Country = rs!country ' Advance recordset rs.MoveNext

ActiveReports 2.0 Standard User's Guide | 90


If Not rs.EOF Then ' If not EOF set the FetchData's EOF value to False EOF = False End If End Sub Private Sub ActiveReport_ReportEnd() ' Unload the subreport Unload subCustomersClone.object Set subCustomersClone.object = Nothing ' Unload the recordsets and database Set myCloneRS = Nothing Set rs = Nothing Set cn = Nothing End Sub Private Sub ActiveReport_ReportStart() ' Set the subreport's object to a new rptCustomersClone Set subCustomersClone.object = New rptCustomersClone End Sub Private Sub Detail_Format() ' Filter the cloned recordset to select the country country myCloneRS.Filter = "Country = '" & s_Country & "'" End Sub

With rptCustomersClone
1. Remove the PageHeader/Footer section. 2. Set the Detail section's properties as follows: Height BackClor BackStyle CanShrink KeepTogether 1260 &H00FFC0C0& 1-Normal True True

3. Place three textboxes in the Detail section and set their properties as follows: Name DataField Height Left Top Width txtCustomer Customer 270 0 0 2880 txtCity City 270 2880 0 2880 txtPostalCode PostalCode 270 5760 0 1800

4. Place four labels in the Detail section and set their properties as follows: Name Caption Height Left Top Width Font.Bold lblOrdered Ordered 270 90 360 1350 True lblRequired Required 270 1530 360 1260 True lblShipped Shipped 270 2880 360 1350 True lblCost Cost 270 4320 360 1440 True

ActiveReports 2.0 Standard User's Guide | 91 5. Place a Subreport control in the Detail section and set its properties as follows: Name Height Left Top Width subOrders 630 0 630 9360

6. Add the following code to rptCustomers:


Private rsClone As ADODB.Recordset Private s_CustomerID As String Private Sub ActiveReport_DataInitialize() Fields.RemoveAll ' Add fields to ActiveReports' Fields Collection Fields.Add "Customer" Fields.Add "City" Fields.Add "Country" Fields.Add "PostalCode" Set rsClone = New ADODB.Recordset Set rsClone = rptCustomer.myCloneRS ' Move to the beginning of the cloned recordset If Not rsClone.EOF Or Not rsClone.BOF Then rsClone.MoveFirst End If End Sub Private Sub ActiveReport_FetchData(EOF As Boolean) ' Exit sub if EOF is true If rsClone.EOF Then Exit Sub ' Sets ActiveReports' fields collection values to the ' current recordset value Fields("Customer").Value = rsClone!CompanyName Fields("City").Value = rsClone!City Fields("Country").Value = rsClone!country Fields("PostalCode").Value = rsClone!PostalCode s_CustomerID = rsClone!CustomerID ' Advance recordset rsClone.MoveNext If Not rsClone.EOF Then ' If not EOF set the FetchData's EOF value to False EOF = False End If End Sub Private Sub ActiveReport_ReportStart() ' set the subreport's object to a new rptOrders Set subOrders.object = New rptOrders End Sub Private Sub Detail_Format() ' Pass the current customer ID to the rptOrders subreport subOrders.object.CustomerID = s_CustomerID End Sub

With rptOrders
1. Remove the PageHeader/Footer section. 2. Insert a GroupHeader/Footer section. 3. Set the GroupHeader's properties as follows: Name ghOrders

ActiveReports 2.0 Standard User's Guide | 92

Height BackColor BackStyle GrpKeepTogether KeepTogether 4. Set the GroupFooter's properties as follows: Name Height BackColor BackStyle KeepTogether

60 &H000040C0& 1-Normal 2-All True

gfOrders 60 &H000040C0& 1-Normal True

5. Set the Detail section's properties as follows: Height BackColor BackStyle CanShrink KeepTogether 270 &H00C0E0FF& 1-Normal True True

6. Place four textboxes in the Detail section and set their properties as follows: Name Text DataField Height Left Top Width OutputFormat txtOrdered Ordered Ordered 270 0 0 1440 txtRequired Required Required 270 1440 0 1440 txtShipped Shipped Shipped 270 2880 0 1440 txtCost Cost Cost 270 4320 0 1440 Currency

7. Add the following code to rptOrders:


Private rsNewRS As ADODB.Recordset Private m_CID As String Public Property Let CustomerID(s_CID As String) ' Store the current customerID m_CID = s_CID End Property Public Property Get CustomerID() As String ' Get the current customerID CustomerID = m_CID End Property Private Sub ActiveReport_DataInitialize() Fields.RemoveAll ' Add fields to ActiveReports' Fields Collection

ActiveReports 2.0 Standard User's Guide | 93


Fields.Add "Ordered" Fields.Add "Shipped" Fields.Add "Required" Fields.Add "Cost" 'Generate a new orders recordset based off of the current customerID Set rsNewRS = New ADODB.Recordset rsNewRS.CursorType = adOpenForwardOnly rsNewRS.LockType = adLockOptimistic rsNewRS.Open "SELECT * FROM Orders WHERE CustomerID = '" & CustomerID_ & "'", rptCustomer.cn End Sub Private Sub ActiveReport_FetchData(EOF As Boolean) ' Exit sub if EOF is true If rsNewRS.EOF Then Exit Sub ' Sets ActiveReports' fields collection values to the ' current recordset value Fields("Ordered").Value = rsNewRS!OrderDate Fields("Shipped").Value = rsNewRS!ShippedDate Fields("Required").Value = rsNewRS!RequiredDate Fields("Cost").Value = rsNewRS!Freight ' Advance recordset rsNewRS.MoveNext If Not rsNewRS.EOF Then ' If not EOF set the FetchData's EOF value to False EOF = False End If End Sub

8. Run the report.

Chapter 8 - Dynamic (Run-Time) Reporting

Chapter 8 Dynamic (Run-Time) Reporting


Modifying and Formatting Controls at Run Time Creating Dynamic Reports Dynamic Reports

Modifying and Formatting Controls at Run Time

Modifying and Formatting Controls at Run Time


ActiveReports objects and controls are completely accessible at run time. You can modify the properties of any of the report sections and controls to get a dynamic view of your report. The format event allows you to modify all properties of the section or controls including height, visibility and other visual properties. This is the only event in which you can modify the printable area of a section. Once this event is completed, any changes to the section's height will not be reflected in the report output. You can use the BeforePrint event to modify other aspects of the sections or controls in your report.

Creating Dynamic Reports

Creating Dynamic Reports


ActiveReports provides you with two powerful methods that allow you to create an ad hoc report based on the user input. The report can include any number of sections and controls and you can adjust the properties of each section or control in your code to lay out the report according to the user's specifications. To create an ad hoc report at run time, you must have a template of the report you wish to create. This template can be a blank report or a starting point of all your ad hoc reports, which might contain

ActiveReports 2.0 Standard User's Guide | 94 some standard layout. This template is necessary because the report object is created at run time directly from the main ActiveReport class and it will not inherit the container extended properties such as the Show method, Width and Height properties and so on. After you create an instance of your report template, you can use the Sections.Add and Controls.Add methods to add new sections and controls to your report. You can add data sources using the built-in data controls, bind your controls to it using the DataSource and DataField properties of bindable controls. This capability allows you to create ad hoc reports and translate forms and grids in your application into printable reports on the fly.

Dynamic Reports

Dynamic Reports
This sample demonstrates how to generate a report at run time by using Sections.Add, and Controls.Add to add controls and sections. As well as use WithEvents to gain access to section events in the class. It is important to remember controls and sections should not be added after the ReportStart event has finished. 1. Add a Visual Basic form to a Project and set its name to frmDynamic. 2. Add a new ActiveReports to the project as shown in the first tutorial. 3. Add a Command Button to the form and set its properties as follows: Name Caption Height Left Top Width cmdRun Run Report 615 960 240 2295

4. On the button's Click event add the following code:


Private Sub cmdRun_Click() ' sets up and runs the report Set rptMain = New ActiveReport1 Set rptSub = New ActiveReport1 BuildMain rptMain.Show End Sub

5. Add the following code to frmDynamic:


' Using WithEvents allows access to the different ' section events (_Format,_BeforePrint,_AfterPrint) Dim WithEvents subDetail As DDActiveReports2.Section Dim WithEvents myGHeader As DDActiveReports2.Section Public CustomerID As String Dim rptMain As ActiveReport1 Dim rptSub As ActiveReport1 Private Sub BuildMain() Dim oCtrl As Object Dim hCtrl As Object Dim ghCtrl As Object Dim gfCtrl As Object rptMain.PageSettings.BottomMargin = 720 rptMain.PageSettings.TopMargin = 720

ActiveReports 2.0 Standard User's Guide | 95


rptMain.documentName = "Customer" 'Setting up a control in the detail section Set oCtrl = rptMain.Sections("Detail").Controls.Add("DDActiveReports2.subreport") With oCtrl .Name = "sub" .Height = 300 .Width = 6000 .Top = 0 .Left = 0 End With 'Add a datacontrol to the main report and set the connection 'ConnectionString and Source. Set oCtrl = rptMain.Sections("Detail").Controls.Add("DDActiveReports2.DataControl") oCtrl.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data _ Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb;_ Persist Security Info=False" oCtrl.Source = "select * from Customers" 'setting up the detail section rptMain.Detail.Height = 300 rptMain.Detail.BackStyle = 1 '1 = normal 0 = transparent rptMain.Detail.BackColor = &HC0C0C0 rptMain.Detail.ColumnCount = 1 rptMain.Detail.KeepTogether = True rptMain.Detail.CanGrow = True rptMain.Detail.CanShrink = True 'Add a report heading and grouping to the report rptMain.Sections.Add "Group", 1, ddSTGroupHeader, 500 Set myGHeader = rptMain.Sections("group") Set subDetail = rptMain.Sections("detail") rptMain.Sections.Add "foot", 3, ddSTGroupFooter, 60 rptMain.Sections("group").GrpKeepTogether = True rptMain.Sections("group").KeepTogether = True rptMain.Sections("group").BackStyle = 1 rptMain.Sections("group").BackColor = &H808080 rptMain.Sections("group").DataField = "CustomerID" rptMain.Sections("foot").BackStyle = 1 rptMain.Sections("foot").BackColor = vbBlack 'Add a text field to the group header Set ghCtrl = rptMain.Sections("group").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt1" .Height = 300 .Width = 1500 .Left = 0 .BackStyle = 1 '1 = normal 0 = transparent .BackColor = &H800000 .ForeColor = &HC0FFFF .DataField = "CustomerID" .Border.Shadow = True End With Set ghCtrl = rptMain.Sections("group").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt2" .Height = 300 .Width = 4500 .Top = 100 .Left = 1750 .BackStyle = 1 '1 = normal 0 = transparent .BackColor = &H800000 .ForeColor = &HC0FFFF .DataField = "CompanyName" .Border.Shadow = True End With Set ghCtrl = rptMain.Sections("group").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt3" .Height = 300 .Width = 2500 .Top = 100 .Left = 6500

ActiveReports 2.0 Standard User's Guide | 96


.BackStyle = 1 '1 = normal 0 = transparent .BackColor = &H800000 .ForeColor = &HC0FFFF .DataField = "ContactName" .Border.Shadow = True End With 'Add a label to the groupfooter rptSub.documentName = "Report Order" rptSub.Detail.BackColor = &HC0C0C0 rptSub.Detail.BackStyle = 1 rptSub.Detail.KeepTogether = False rptSub.Detail.Height = 300 rptSub.Detail.CanGrow = True rptSub.Detail.CanShrink = True Set ghCtrl = rptSub.Sections("detail").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt1" .Height = 300 .Width = 1500 .Top = 0 .Left = 1 .BackStyle = 1 '1 = normal 0 = transparent .BackColor = &HC0C0C0 .ForeColor = &H800000 .DataField = "OrderDate" .OutputFormat = "MM/DD/YYYY" End With Set ghCtrl = rptSub.Sections("detail").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt2" .Height = 300 .Width = 1500 .Top = 0 .Left = 1500 .BackStyle = 1 '1 = normal 0 = transparent .BackColor = &HC0C0C0 .ForeColor = &H800000 .DataField = "ShippedDate" .OutputFormat = "MM/DD/YYYY" End With 'Add a Datacontrol to the subreport Set oCtrl = rptSub.Sections("Detail").Controls.Add("DDActiveReports2.DataControl") oCtrl.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data _ Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb;Persist _ Security Info=False" End Sub nbsp; Private Sub myGHeader_Format() CustomerID = rptMain.Sections("group").Controls("txt1").Text End Sub Private Sub subDetail_Format() ' Sets up the subreport control and connects the subreport's datacontrol ' to the database Set rptMain.Detail.Controls("sub").object = rptSub rptSub.DataControl1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data_ Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb;Persist _ Security Info=False" rptSub.DataControl1.Source = "select * from Orders where CustomerID _ = '" & CustomerID & "'" End Sub

Creating Dynamic Reports without a Templete DSR


ActiveReports 2 allows dynamic reports to be generated and sent directly to the viewer control without using a designer DSR file as a templete. The project above can easily be converted to demonstrate this ability by adding a viewer control to the visual basic form (see chapter 15), removing the report designer from the project and modifying the code as follows:
Dim rptMain As ActiveReport

ActiveReports 2.0 Standard User's Guide | 97


Dim rptSub As ActiveReport Private Sub cmdRun_Click() ' setups up and runs the report Set rptMain = New ActiveReport Set rptSub = New ActiveReport BuildMain ARViewer21.ReportSource = rptMain End Sub

Chapter 9 - Creating Reports from an XML Document

Chapter 9 - Creating Reports from XML Documents


Bound XML Data Reports XML Data Reports and Subreports XML Reports using LoadXML

Bound XML Data Reports

Bound XML Data Reports


This sample demonstrates the fundamentals for connecting reports to an XML database. One of the main differences when creating reports with XML data is that the DataField property must be set to a valid Xpath expression. Note: More information on Xpath standards can be found at http://www.w3.org/TR/xpath, and a tutorial can be found at: http://www.zvon.org/xxl/XPathTutorial/General/examplesl 1. Create a new Visual Basic project. 2. Add a new report to the project, as shown in the first tutorial, and set its name to rptCustomer. 3. Add an XML DataControl to the report and set its properties as follows: FileURL RecordSet Pattern C:\Customer.xml //CUSTOMER

Note: The customer.xml database can be located in the samples directory included with ActiveReports. If the fields list is populated after setting the FileURL and RecordsetPattern, the different nodes will be visible. The red arrow in the image below indicates the current node.

ActiveReports 2.0 Standard User's Guide | 98 4. Add a label to the PageHeader and set its properties as follows: Name Caption Height Left Top Width Font.Size Font.Bold Alignment VerticalAlignment lblCustomers Customers 540 0 0 8820 24 True 2-ddTXCenter 1-ddTXMiddle

5. Add three labels to the Detail section and set their properties as follows: Name Caption Height Left Top Width Font.Bold lblID ID 270 0 0 1350 True lblEmail Email 270 2880 0 1440 True lblName Name 270 0 270 1350 True

6. Add three fields to the Detail Section and set their properties as follows: Name Text DataField Height Left Top Width txtID ID @id 270 1440 0 720 txtEmail Email @email 270 4410 0 4860 txtName Name NAME 270 1440 270 7830

7. Save the project and run it.

XML Data Reports and Subreports

XML Data Reports and Subreports


This sample demonstrates how to use the Subreport's DataField property to pass nodelists from the parent report to the child. Continuing with the project started above, add two more reports to the project and set their properties as follows:
Name srptOrders srptOrderItems

ActiveReports 2.0 Standard User's Guide | 99

With rptCustomers
1. Add a Subreport control to the Detail section and set its properties as follows: Name DataField Height Left Top Width srptOrders ORDER 360 0 810 9270

2. Add the following code to the project:


Private Sub ActiveReport_ReportEnd() Unload srptOrders.object Set srptOrders.object = Nothing End Sub Private Sub ActiveReport_ReportStart() Set srptOrders.object = New srptOrders End Sub

With srptOrders
1. Remove the PageHeader/Footer section. 2. Set the Detail Section's height to 570. 3. Add an XML DataControl to the report and set its properties as follows: FileURL Recordset Pattern customer.xml //Order

4. Add two fields to the Detail section and set their properties as follows: Name Text Text Height Left Top Width txtOrderNumber OrderNumber NUMBER 270 0 0 1440 txtOrderDate OrderDate DATE 270 1620 0 4140

5. Add a Subreport control to the Detail section and set its properties as follows: Name DataField Height Left Top Width srptItems ITEM 270 0 270 9270

ActiveReports 2.0 Standard User's Guide | 100 6. Add the following code to the project:
Option Explicit Private Sub ActiveReport_ReportEnd() Unload srptItems.object Set srptItems.object = Nothing End Sub Private Sub ActiveReport_ReportStart() Set srptItems.object = New srptOderItems End Sub

With srptOrderItems
1. Remove the PageHeader/Footer Section. 2. Insert a GroupHeader/Footer. 3. Set the GroupHeader's properties as follows: Name Height ghOrderItems 360

4. Add three labels to the GroupHeader and set their properties as follows: Name Caption Height Left Top Width Font.Bold lblISBN ISBN 270 0 0 2790 True lblTitle Title 270 2880 0 4320 True lblPrice Price 270 7380 0 1350 True

5. Set the GroupFooter's properties as follows: Name Height gfOrderItems 270

6. Add a field control to the GroupFooter and set its properties as follows: Name Text DataField Height Left Top Width Font.Bold SummaryFunc SummaryGroup txtOrderTotal Total Price 270 7380 0 1350 True 0-ddSFSum ghOrderItems

ActiveReports 2.0 Standard User's Guide | 101

SummaryType 7. Set the Detail section's height to 300.

3-ddSMSubTotal

8. Add an XML DataControl to the report and set its properties as follows: FileURL RecordSet Pattern customer.xml (blank)

9. Add three fields to the Detail section and set their properties as follows: Name Text DataField Height Left Top Width txtISBN ISBN @isbn 270 0 0 2790 txtTitle Title TITLE 270 2880 0 4320 txtPrice Price PRICE 270 7380 0 1350

10. Save the project and run it.

Using the XML DataControl's Field property


When working with XML data the returned fields list is not static like it is when working with tables. Because of this, special operations can be performed based off of the current node by navigating through the XML tree. The current node is indicated by the specified Recordset pattern. In the sample project above, Order is the current node for rptCustomers with the XML databases' structure as follows: Customers Order Item Item Order Item Since the current node is Orders, the item and customers information can be reached by using an XPath expression. For example ./Item can be used to access the item node and ../Customers can be used to access the customer's node. Note: More information on XPath expressions can be found at msdn.microsoft.com/library/psdk/smlsdk/xslr3prn. For example: By adding the following code to rptOrderItems, from the sample project above, the project can be modified to check if an item has a publisher (./PUBLISHER). If the item has a publisher the txtTitle field can be modified to include the publisher.
Private Sub Detail_Format() If dc.Field("./PUBLISHER", False) <> "" Then txtTitle.Text = txtTitle.Text & vbCrLf & "Published _ By: " & dc.Field("./PUBLISHER", False) End If End Sub

Returning a NodeList
The DataControl's field property can also return a full NodeList. The code segment below is also a

ActiveReports 2.0 Standard User's Guide | 102 modification of the project above. By using the following code in srptOrder, instead of setting the Subreport control's DataField property to ITEM, the returned NodeList can be passed to the Subreport.
Private Sub Detail_Format() Dim nodList As Object ' This demonstrates the use of nodeList property and ' Field method as an alternative to automatic subreport linking Set nodList = dc.Field("ITEM", True) srptItems.object.dc.NodeList = nodList End Sub

XML Reports using LoadXML

XML Reports using LoadXML


Using LoadXML with the XML DataControl allows an XML string to be used with a report. The following sample demonstrates how an XML string can be used to load data into a report. 1. Create a new Visual Basic project. 2. Add a new report to the project, as shown in the first tutorial, and set its name to rptOrderItems. 3. Add an XML DataControl to the report. 4. Add the following code to the ActiveReport_DataInitialize event:
Private Sub ActiveReport_DataInitialize() XMLDataControl1.ValidateOnParse = True XMLDataControl1.RecordsetPattern = "//Order/Customer/Manifest/Item" XMLDataControl1.LoadXML ("<Order><Customer><Name>John _ Doe</Name><Cardnum>131 131 131 131</Cardnum><_ Manifest><Item><ID>204</ID><Title>_ Making the Transition from C++ to the Java(tm)Language</Title>_ <Quantity>1</Quantity><UnitPrice>$10.75<_ /UnitPrice></Item></Manifest><Receipt><_ Subtotal>$23.75</Subtotal><Tax>$2.43</Tax>_ </Receipt></Customer></Order>") End Sub

5. Set the Detail section's properties as follows: Height BackColor BackStyle 765 &H00C0FFFF& 1-Normal

6. Add four fields to the Detail section and set their properties as follows: Name Text DataField Height Left Top Width txtTitle Title Title 270 7380 90 4500 txtID ID ID 270 90 360 1440 txtQuantity Quantity Quantity 270 3330 360 1440 txtUnitPrice UnitPrice UnitPrice 270 4950 360 1440

7. Save the report and run it.

ActiveReports 2.0 Standard User's Guide | 103

Chapter 10 - Additional Report Types

Chapter 10 - Additional Report Types


Top N Reports Master Detail Reports Summary Reports Mail-Merge Reports Columnar Reports Creating Labels Conditional Printing Green-bar Printout Report Multi-Page Sections Charts Multiple Records per Section Modifying the Pages Collection of a Processed Report Report Coding Tips

Top n Reports

Top n Reports
ActiveReports requires no special handling for Top n Records report styles. You can easily implement such reports by setting your data source to a Top n filtered query. If your data source does not support Top n queries, you can set your query to return your records ordered by the Top n value descending. Then set the MaxRows property to n. For example, to list the Top 10 customers by their sales number. You can create a query that returns all customer sales ordered by the sales value descending and set the MaxRows property of the data control to 10. ActiveReports will process only 10 records from the sorted query results.

Master Detail Reports

Master Detail Reports


Master detail reports are implemented in ActiveReports using a JOIN SQL query and adding a group on the master key. The master records can be placed in the group header and footer sections and the detail records placed in the detail section. For example, to create a master-detail of orders and order detail records, you can create a query such as:
"SELECT * FROM order, [order details] WHERE orders.OrderID = [order details].OrderID".

Then, create a group where the group field is the OrderID field. Place all order fields such as ID and Date in the group header sections and place the order detail fields in the detail section.

Summary Reports

Summary Reports
Summary Reports are implemented by setting Visible property to False or setting its height to 0. The detail section will be processed and the summary group header and footer sections will be printed without the detail section.

ActiveReports 2.0 Standard User's Guide | 104

For example, to create a summary of sales of all orders, you can create the same report mentioned above and set the detail height to 0. ActiveReports will print the summary of each order without printing its detail level. Note: In most instances it is more efficient to use aggregated SQL queries to retrieved summarized data instead of reading through all the records in a database.

Mail-Merge Reports

Mail-Merge Reports
ActiveReports supports mail-merge reports using the RichText control. The RichText control can contain field placeholders that are replaceable with their values (merged) at run time. To create a mail-merged report, insert a RichText control in the detail section of your report; edit the text of your letter as you would a word-processing document. Use the insert field command to add a mail-merge field into the text. In the detail format event, add the following code to update the field values in the RichText control for each record in your detail section.
Private Sub Detail_Format() With dcRptData.Recordset rtf.ReplaceField("LastName",.Fields("LName").Value) rtf.ReplaceField("FirstName",.Fields("FName").Value) End With End Sub

Columnar Reports

Columnar Reports
ActiveReports supports newspaper column layout in both the detail and group sections. You can render the columns either horizontally or vertically in the section with options to break the column on group sections (start a new column on the change of a group).

Creating Labels

Creating Labels
You can use ActiveReports to print any label size by using the newspaper column layout. To create a report that prints labels to a laser printer labels sheet: 1. Set the report width to the total width of the label sheet. 2. Set the columns property of your Detail section to the number of labels across the page. 3. Adjust the column spacing property, if needed, to increase/decrease the space between columns. 4. Remove the page header and footer sections from your report. 5. Set the height of the Detail section to the exact height of the label. 6. Set the detail section's CanGrow/CanShrink properties to false. 7. Adjust the top, right, bottom and left margins to match the sheet. 8. Finally, place your text and label controls in the column area in the detail section.

Skipping Labels
ActiveReports allows you to skip labels on a label sheet using the LayoutAction property. LayoutAction has several uses, one of which is to skip a section i.e. do not print anything and move to the next printable area. So for each label you want to skip you can set the LayoutAction property to 2

ActiveReports 2.0 Standard User's Guide | 105 - ddLAMoveLayout in the format event of the detail section. The section will be skipped without moving to the next record in the data source.
Dim iSkipLabels As Integer Private Sub Detail_Format() If iSkipLabels > 0 Then iSkipLabels = iSkipLabels 1 LayoutAction = ddLAMoveLayout End If End Sub

Conditional Printing

Conditional Printing
ActiveReports allows you to print or suppress any control at run time based on a condition in your data. This can be achieved by modifying the Visible property of the control in the Format event of the parent section. For example, you can print an "Outstanding" label for employees that exceeded their sales goals for the period by adding the following code in the Detail Format event:
Private Sub Detail_Format() If txtEmployeeSales.DataValue > txtEmployeeGoal.DataValue Then lblOutstanding.Visible = True Else lblOutstanding.Visible = False End If End Sub

Similarly, you can modify any of the print properties of controls in any of the format events in your report.

Green-Bar Printout Reports

Green-Bar Printout Reports


You can create green-bar printouts by alternating the shading or background color of your detail section in the format event.
Dim I As Integer Private Sub Detail_Format() If (I Mod 2) = 0 Then ' Set the detail Detail.BackStyle Detail.BackColor Else Detail.BackStyle End If I = I + 1 End Sub

BackStyle to normal = ddBKNormal = vbGreen = ddBKTransparent

Multi-Page Sections

Multi-Page Sections
By using the PageBreak control you can span a report header or report footer section across multiple pages. You can use this to add multiple summary pages to your reports that might contain charts, summary tables and table of contents.

Charts

ActiveReports 2.0 Standard User's Guide | 106

Charts
ActiveReports does not include a built-in data chart control. However, its support for ActiveX controls allows you to use any charting control in your report. You can use the data in your report to set series and data points in the chart as the report is being processed. If you place the chart in the report header (i.e. before its data is processed) you will need to place a summary field control in the same section. This allows ActiveReports to delay printing the section until all the required data is processed and you will get a chance to load your chart data correctly. See the EmployeeSales report for an example of this technique. Another alternative is to place the chart control in a child report and link it to a Subreport control in the main report. This allows you to fully process the data for the chart and then render it into the main report using the Subreport control. However, this would require going through more than one Recordset, one for the main report and another for the child report.

Multiple Records Per Section

Multiple Records Per Section


LayoutAction property allows you to control how many records are printed in a single section. In the Detail section format event you can set the LayoutAction to ddLANextRecord, which moves the record pointer but keeps the current section active for printing. This allows you to print multiple records in the same section. You can use this functionality to print Aging reports, calendar of events in a calendar format, and more such reports. See the Samples directory for an example of using this powerful feature (Students and Classes Schedule).

Modifying the Pages Collection of a Processed Report

Modifying the Pages Collection of a Processed Report


ActiveReports caches the printed pages into canvas objects in the Pages collection. Once a report is completed, you can access each canvas object in the collection and modify its contents using the canvas drawing methods. In addition, you can save and load canvas objects into the collection using the Save and Load methods. You can overlay a preset layout to any of the pages (pre-printed forms) using the Overlay method. ActiveReports allows you to reorder the pages in the collection and selectively print odd or even pages. You can also change the printer device of each page or group of pages.

Report Coding Tips

Report Coding Tips


1. A control should not be referenced outside of its section. If information from a control in one section needs to be used in another, use a variable to pass the information. 2. The PageHeader/Footer should not contain bound controls. 3. The PageHeader/Footer should not be used to group information. Grouping should be done with GroupHeaders/Footers. 4. Section events do not fire in a sequential order so reports should not be structured to rely on section event order. 5. The BeforePrint event should be used to do page specific formatting. 6. Controls should not be dynamically added after the ReportStart event finishes. 7. If a report's PrintWidth is greater than the paper's width, a blank page will print after each report page.

ActiveReports 2.0 Standard User's Guide | 107 8. If a printer does not support a specified PaperSize, the default paper size will be used instead. 9. When working with web servers, it is extremely important to set up the default users for the web site to have read/write permissions to project files, ActiveReport's dlls, the export directory and the database. 10. Once a report finishes running, the report will need to be re -run to reflect any changes to the layout. For example: if the orientation is changed from the print dialog box after a report has run, the report's layout will not be rendered for the new layout until it is re -run.

Chapter 11 - Organizing Reports with the TOC and Frame Control

Chapter 11 - Organizing Reports with the TOC and Frame Control


Setting Up a Table of Contents Using the TOC with Subreports Using the TOC with Groups Working with the Frame Control Using the Frame Control for a Table

Setting Up a Table of Contents

Setting Up a Table of Contents


Setting up a table of contents allows reports to be organized and easily navigated. By default, no table of contents is created when a report is run. However, by simply adding TOC.Add <caption> to the desired section event, TOC entries can be set up as the report runs. The small section of code below demonstrates how to set up a simple TOC for each detail item.
Private Sub Detail_Format() Me.TOC.Add txtCompanyName End Sub

The code above generates the following table of contents:

ActiveReports 2.0 Standard User's Guide | 108

Using the TOC with Subreports

Using the TOC with Subreports


The table of contents can also be used in conjunction with subreports to generate a collapsible item tree. By using the "\" when adding an item to the TOC, a level break will be created. The following code demonstrates how to set up TOC to work with subreports.
Private Sub Detail_Format() TOC.Add Me.ParentReport.txtCompanyName & "\" & txtProductName End Sub

The code above generates the following table of contents:

ActiveReports 2.0 Standard User's Guide | 109

Using the TOC with Groups

Using the TOC with Groups


Depending on the desired page location of each TOC entry, different section events can be used to add the items to the table of contents. For example, using the GroupHeader_Format event will mark the TOC entry at the beginning of the GroupHeader, while using the GroupHeader_AfterPrint event will mark the TOC entry at the end of the GroupHeader. The following code sample demonstrates setting up a table of contents with grouping.
Dim sCountry As String Private Sub ActiveReport_FetchData(EOF As Boolean) If Not DataControl1.Recordset.EOF then sCountry = DataControl1.RecordSet.Fields("country") End if End Sub Private Sub Detail_Format() TOC.Add sCountry & "\" & txtCustomer End Sub Private Sub ghOrderGroup_Format() TOC.Add sCountry End Sub

The code above generates the following table of contents:

ActiveReports 2.0 Standard User's Guide | 110

Note: When viewing a report in "whole Page" mode, or smaller, clicking on the table of contents entry will not change the page's vertical position.

Working with the Frame Control

Working with the Frame Control


The frame control adds another element to help organize a report's visible appearance. The frame control makes it easier to set up tables and corrects problems with controls and sections not growing when static objects, such as an image are used. The frame control also has a CloseBorder property to adjust whether or not a line should printed at the bottom of the page if a section spans across multiple pages. The frame control works by dragging the control into the desired section and adding panes for each column or row needed. Each pane has the ability to split horizontally or vertically. Each pane can also have its own border properties and backcolors specified, as well as contain controls.

Using the Frame Control for a Table

Using the Frame Control for a Table


This sample demonstrates how to set up a table by using the frame control. It makes use of the unbound grouping project set up in chapter 6. 1. In ghOrderGroup add a frame control and split the frame, vertically, into four panes. 2. Set the width of each pane to equal the width of the label it will contain. 3. On the first three panes set a border on the top, bottom and left side. 4. On the last pane set a border on every side. 5. Set each panes back color to &H00C0C0C0&. 6. Set the frame control's CanShrink property to True. 7. Set ghOrderGroup's CanShrink property to True. 8. In the Detail section, repeat the same process with another frame control for each field control. 9. On the first three panes set a border on the bottom and left side.

ActiveReports 2.0 Standard User's Guide | 111 10. On the last pane set a border on the right, bottom, and left side. 11. Set the Detail section's CanShrink property to True. 12. The report designer should look like this:

13. Save and run the report. The results should look like this:

Chapter 12 - Hyperlinking, CSS and ActiveReports

Chapter 12 - Hyperlinking and Styles


Using Hyperlinks:
l l

Using HTML Links Using Hyperlinks for DrillDown Reports

ActiveReports 2.0 Standard User's Guide | 112


l l

Using Hyperlinks with the TOC Using the MouseOver Event with Hyperlinks

Using Style Class:


l l

Creating Global Styles Using Special Style Classes

Using Hyperlinks

Using Hyperlinks
ActiveReports gives users the ability to add hyperlinks to reports. These reports can then be previewed, displayed in the ActiveX viewer control, or exported. The hyperlink property can be set to any HTML style link (such as http:// and mailto://), items in the TOC (TOC://), and can be used to simulate drill-down reporting. By using the hyperlink property, reports can have "clickable" controls which can be used for a variety of different tasks. Included in these tasks is the ability to run and display other reports. The following sample projects demonstrate using each of these types of linking.

Using HTML links

Using HTML links


This sample project demonstrates setting up labels with HTML style hyperlinks. 1. Create a new ActiveReport, as shown in the first tutorial, and set the report's name to rptRDFs. 2. Insert an ADO data control into the Detail section. 3. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 4. Set the data control's source property to the following SQL statement:
SELECT * FROM Suppliers ORDER BY CompanyName

5. Change the PageFooter's Height to 930. 6. Place a line control in the PageFooter and set its properties as follows: LineColor LineWeight X1 X2 Y1 Y2 &H00800000& 3 0 4320 90 90

7. Place two labels in the PageFooter and set their properties as follows: Name Caption Height Left Top Width Hyperlink lblEmail Need Assistance? Email Support: Support@company.com 360 0 180 2790 mailto:support@company.com lblHomePage Visit our home page: www.datadynamics.com 270 0 630 3780 www.datadynamics.com

ActiveReports 2.0 Standard User's Guide | 113 8. Place five fields in the Detail section and set their properties as follows: Name Text DataField Height Left Top Width Font.Bold Font-Size FontUnderline ForeColor 9. Add the following code to the Detail_Format event:
Private Sub Detail_Format() Dim iStart As Integer Dim sHTML As String 'This strips out the url from the database entry and 'replaces the "#" character If txtHomePage.Text <> "" Then iStart = InStr(1, txtHomePage.Text, "#", vbTextCompare) sHTML = Right(txtHomePage.Text, (Len(txtHomePage.Text) - iStart)) sHTML = Replace(sHTML, "#", "", 1, -1, vbTextCompare) txtHomePage.Hyperlink = sHTML txtHomePage.Text = Replace(txtHomePage.Text, "#", " ", 1, -1, vbTextCompare) End If End Sub

txtCompanyName CompanyName CompanyName 360 270 180 4860 True 12

txtContactName ContactName ContactName 270 0 450 2880

txtPhone Phone Phone 270 2970 450 1890

txtFax Fax Fax 270 4860 450 2160

txtHomePage HomePage HomePage 270 1440 720 7920 True

True &H00800000&

10. Save the project and run it.

Using Hyperlinks for Drill-Down reports

Using Hyperlinks for Drill-Down reports


This sample project demonstrates how to emulate drill-down reporting by using the report's HyperLink event to run and preview the child reports. 1. Continuing with the project above, add a second report to the project and set its properties as follows: Name BorderStyle arDrillDown 1-vbFixedSingle

2. Insert a ADO data control in the Detail section. 3. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 4. Set the data control's source property to the following SQL statement:
SELECT * FROM Products, Categories WHERE Products.CategoryID = Categories.CategoryID

5. Insert a GroupHeader/Footer section.

ActiveReports 2.0 Standard User's Guide | 114 6. Set the GroupHeader's properties as follows: Name Height ghCategory 840

7. Set the GroupFooter's properties as follows: Name Height gfCategory 135

8. Place a field in ghCategory and set its properties as follows: Name Text DataField Height Left Top Width Font.Size Font.Bold txtCategoryName CategoryName CategoryName 450 0 0 4050 16 True

9. Set the Detail section's height to 345. 10. Place three labels in ghCategory and set their properties as follows: Name Caption Height Left Top Width Font.Bold Alignment lblProductName Product Name 270 0 540 4140 True lblQperU Qnty Per Unit 270 4230 540 2880 True lblUnitPrice Unit Price 270 7200 540 1440 True 1-ddTXRight

11. Place three fields in the Detail section and set their properties as follows: Name Text DataField Height Left Top Width txtProductName ProductName ProductName 270 0 0 4140 txtQuantityPerUnit QuantityPerUnit QuantityPerUnit 270 4230 0 2880 txtUnitPrice UnitPrice UnitPrice 270 7200 0 1440

ActiveReports 2.0 Standard User's Guide | 115

Alignment OutputFormat

1-ddTXRight Currency

With rptRDFs (from project above)


1. Change the following properties for txtCompanyName: ForeColor Font.Underline &H00800000& True

2. Add the following code to the AcitveReport_FetchDate event:


Dim i_CompanyID As Integer Private Sub ActiveReport_FetchData(EOF As Boolean) If Not EOF Then 'Gets the current records SupplierID i_CompanyID = DataControl1.Recordset.Fields("SupplierID") End If End Sub

3. Add the following code to the ActiveReport_hyperlink event:


Private Sub ActiveReport_hyperLink(ByVal Button As Integer, Link As String) 'Check to see if an email link or web page has been selected If InStr(1, Link, "htm", vbTextCompare) = 0 And InStr(1, Link, "mailto",_ vbTextCompare) = 0 Then 'Change the drillDown reports record source string to select 'only for the selected supplier ID arDrillDown.DataControl1.Source = "Select * from products, categories _ where products.categoryID = categories.categoryID and products._ supplierID = " &Link arDrillDown.Show End If End Sub

4. Add the following lines to the Detail_Format Event:


'Set the hyperlink for the company to the companies ID txtCompanyName.Hyperlink = i_CompanyID

5. Save the project and run the report

Using Hyperlinks with the TOC

Using Hyperlinks with the TOC


This sample project demonstrates how to use the hyperlink property to reference back to the TOC. In this sample, a directory is set up to match the items entered in the TOC. 1. Continuing with the project above, add a second report to the project and set its name to arTOC. 2. Set the PageHeader's height to 1080. 3. Place three labels in the PageHeader and set their properties as follows: Name Caption Height Left Top lblDirectory Company Name Directory 540 0 0 lblCompanyName Company Name 270 90 720 lblPage Page 270 270 720

ActiveReports 2.0 Standard User's Guide | 116

Width Font.Bold Font.Size Alignment VerticalAlignment

9360 True 20 2-ddTXCenter 1-ddTXMiddle

2790 True 9

1170 True 9 2-ddTXCenter 1-ddTXMiddle

4. Place a Line control in the PageHeader and set its properties as follows: LineColor LineWeight X1 X2 Y1 Y2 &H00800000& 3 0 9360 990 990

5. Place two Fields in the Detail Section and set their properties as follows: Name Text Height Left Top Width Font.Size Font.Bold Font.Underline ForeColor Alignment txtEntry CompanyName 270 90 90 2790 8 True True &H00800000& txtPage Page 270 3420 90 1170 8 True True Black 2-ddTXCenter

6. Add the following code to the report:


Option Explicit Public PrintTOC As DDActiveReports2.TOC Private iEntry As Integer Private Sub ActiveReport_FetchData(eof As Boolean) iEntry = iEntry + 1 If iEntry >= PrintTOC.Count + 1 Then Exit Sub eof = False End Sub Private Sub ActiveReport_Initialize() Set PrintTOC = Nothing End Sub Private Sub ActiveReport_ReportStart() If PrintTOC Is Nothing Then Me.Cancel End If End Sub

ActiveReports 2.0 Standard User's Guide | 117

Private Sub Detail_Format() Sets the TOC entry caption to the field's text txtEntry.Text = PrintTOC.Item(iEntry - 1) 'Creates a hyperlink to the toc by using the 'company name, which was used to add the 'entry to the toc txtEntry.Hyperlink = "toc://" & PrintTOC.Item(iEntry - 1) 'puts in the page number for the TOC item txtpage.Text = PrintTOC.pageNumber(iEntry - 1) End Sub

With rptWebLinks 1. Adjust the ActiveReport_hyperLink event to check to see if a TOC hyperlink has been selected:
Private Sub ActiveReport_hyperLink(ByVal Button As Integer, Link As String) If InStr(1, Link, "htm", vbTextCompare) = 0 And InStr(1, Link, "mailto", _ vbTextCompare) = 0 And InStr(1, Link, "toc://", vbTextCompare) = 0 Then 'Change the drillDown reports record source string to select 'only for the selected supplier ID arDrillDown.DataControl1.Source = "Select * from products, categories _ where products.categoryID = categories.categoryID and _ products.supplierID = " &Link arDrillDown.Show End If End Sub

2. Add the following line of code to the Detail_Format event to add the CompanyName to the TOC:
TOC.Add txtCompanyName

3. Add the following code to the ActiveReport_ReportEnd event:


Private Sub ActiveReport_ReportEnd() Dim rpt As New arTOC Dim iPg As Integer Dim pg As Canvas 'Runs the arTOC report to generate the TOC Set rpt.PrintTOC = TOC rpt.Run ' Insert all the arTOC pages into the end of ' this report iPg = Me.Pages.Count For Each pg In rpt.Pages Pages.Insert iPg, pg iPg = iPg + 1 Next ' Commit all changes to the pages collection Pages.Commit Unload rpt Set rpt = Nothing End Sub

4. Save the project and run it.

Using the MouseOver event with Hyperlinks

Using the MouseOver Event with Hyperlinks


The report and viewer control both have MouseOver events, giving access to the control's Hyperlink and PageX and PageY position. By using this event, a ToolTip control or Status Bar control can be updated to display information about the particular link. Below is a code segment using the Viewer control's MouseOver event to update a form's Status Bar.
Private Sub ARViewer21_MouseOver(ByVal PageX As Long, ByVal PageY As _

ActiveReports 2.0 Standard User's Guide | 118


Long, ByVal hyperLink As String) If InStr(1, hyperLink, "htm", vbTextCompare) > 0 Then Me.StatusBar1.Panels(1).Text = "Click to Visit Home Page:" & hyperLink ElseIf InStr(1, hyperLink, "mailto", vbTextCompare) > 0 Then Me.StatusBar1.Panels(1).Text = "Send Email:" & Right(hyperLink,_ Len(hyperLink) - 7) Else Me.StatusBar1.Panels(1).Text = "" End If End Sub

Using CSS

Using Style Classes


ActiveReports adds global style class names to allow controls to be formatted easily. With the use of Global Styles, groups of controls can be set to a single style with just a few clicks. ClassName and the different control's style property can also be used to create specialized styles in code and through scripting.

Creating Global Styles

Creating Global Styles


1. Select "File" from the designer menu. 2. Select "Page Settings" from the dropdown menu to open up the "Report Settings" window. 3. Select the "Styles" menu to display the style sheet (seen below).

4. Select "New" to add a new style, or select predefined style to modify. 5. Give the new style an identifiable name and select a base style.

ActiveReports 2.0 Standard User's Guide | 119

Note: The Base style sets the initial properties for the new style to match those of the selected predefined style. 6. Modify the properties to set up the desired effect and select "OK". 7. To apply a global style, select the control(s) you wish to apply the style to and select the new style from the style drop-down box.

Using the ClassName Property


The ClassName property can also be used to set a control's global style by setting the control's ClassName property to a style listed in the style's drop-down box.

Using Special CSS Styles

Using Special Style Classes


There are a couple of different ways to implement special styles for individual controls. At design time, setting a control's style property in the property window to a properly formatted CSS string will change the control's appearance. For example, the following code sets a control to use dark green, underlined, 16 point Verdana.
font-family: verdana; font-size: 16pt; color: rgb(0,64,0); font-weight: bold; textdecoration: underline;

Note: If the CSS string entered is not properly formatted, it will not remain in the style property window. The same aesthetic look can also be set at run time through code. The following sets the txtName filed to match the same style.
Private Sub Detail_Format() txtName.Style = "font-family: Verdana; font-size: 16pt; color: rgb(0,64,0); _ font-weight: bold; text-decoration: underline;" End Sub

Note: If a control is set to a global style, changing its style will only affect the individual control and not every control using the same global style.

Chapter 13 - Saving and Loading

ActiveReports 2.0 Standard User's Guide | 120

Chapter 13 - Saving and Loading


Saving and Loading RDF Files Using ActiveReports' Export Filters Saving and Loading Canvas Object Saving and Loading Report Layouts Saving and Loading to a Byte Array

Saving And Loading RDF Files

Saving And Loading RDF Files


ActiveReports allows reports to be saved into their own standard format called an RDF file (Report Document Format). Once a report has been saved to an RDF file, it can be loaded into the viewer control and used to display reports in custom preview applications and on the web. Below is a sample project demonstrating how to save and load these RDF files. 1. Create a new Visual Basic EXE project. 2. Change the name of From1 to frmRDFs. 3. Create a new ActiveReport, as shown in the first tutorial, and set the report's name to rptRDFs (See Chapter 15). With frmRDFs 1. Add the Data Dynamics ActiveReports Viewer 2.0 control to frmRDFs. 2. Add two command buttons below the viewer control and set their properties as follows: Name Caption Enabled cmdSave Save Report True cmdLoad Load Report False

3. Add the following code to the cmdSave_Click event:


Private Sub cmdSave_Click() rptRDFs.Run rptRDFs.Pages.Save App.Path & "\SavedRDF.RDF" cmdLoad.Enabled = True End Sub

4. Add the following code to the cmdLoad_Click event:


Private Sub cmdLoad_Click() ARViewer21.Pages.Load App.Path & "\SavedRDF.RDF" frmRDFs.Caption = "RDF File loaded: " & App.Path & "\SavedRDF.RDF" End Sub

With rptRDFs 1. Insert a ADO data control in the Detail section. 2. Connect to Nwind.mdb (see Chapter 3 for help with connecting). 3. Set the data control's source property to the following SQL statement:
SELECT * FROM Employees ORDER BY Title

4. Remove the PageHeader/Footer sections from the report. 5. Add a GroupHeader/Footer to the report. 6. Set the GroupHeader's properties as follows: BackColor Black

ActiveReports 2.0 Standard User's Guide | 121

BackStyle CanShrink Height DataField GrpKeepTogether KeepTogether

1-Normal False 330 EmployeeID 2-All True

7. Place three fields in the GroupHeader and set their properties as follows: Name Text DataField Height Left Top Width txtEmployeeID EmployeeID EmployeeID 270 0 0 1260 txtFirstName FirstName FirstName 270 1440 0 1440 txtLastName LastName LastName 270 2880 0 1440

8. Set the GroupFooter's properties as follows: BackColor BackStyle CanGrow Height KeepTogether Black 1-Normal False 100 True

9. Select the Detail section and set the section's properties as follows: BackColor BackStyle CanShrink Height &H00404040& Normal False 1650

10. Place a Shape control in the Detail Section and set its properties as follows: BackColor BackStyle Height Left Top Width &H00C0C0C0& 1-ddBKNormal 720 0 450 9360

11. Right-click on the Shape control and select "Send To Back." 12. Place eight textboxes in the Detail section and set their properties as follows: Name Text DataField txtTitle Title Title txtHireDate HireDate HireDate txtExtension Extension Extension txtHomePhone HomePhone HomePhone txtAddress Address Address

ActiveReports 2.0 Standard User's Guide | 122

Height Left Top Width ForeColor BackColor BackStyle

270 90 90 1440 &H00E0E0E0&

270 1620 90 1440 &H00E0E0E0&

270 3150 90 1440 &H00E0E0E0&

270 90 1260 1440 &H00E0E0E0&

270 90 540 9180

&H00E0E0E0& 1-ddBKNormal

13. Save the project and run it.

Using ActiveReports' Export Filters

Using ActiveReports' Export Filters


Included with ActiveReports are several specialized export filters (PDF, RTF, Text, Excel, TIFF and HTML). With these export filters, reports can easily be made available to others in various formats. In order to use ActiveReports' export filters, the filter must first be referenced through Visual Basic's reference list. The reference names will generally be ActiveReports <filter> Export Filter.

1. Once a filter is referenced, it can be used with the report. 2. The sample project below demonstrates the basics for exporting a report to each of the different filters. 3. Using the same sample above, add a second Form to the project and set the Project's properties startup object to this form. 4. Select all of the export filter references for VB's reference list. 5. Add a command button to the form and set its properties as follows: Name Caption cmdExport Export Report

ActiveReports 2.0 Standard User's Guide | 123 6. Add the following code to the cmdExport_Click event:
Dim exportType As String Private Sub cmdExport_Click() exportType = cExportType.Text ExportReport MsgBox cExportType.Text & " Export Completed" End Sub

7. Add a ComboBox to the form and set its properties as follows: Name List cExportType PDF Excel TIFF HTML Text

8. Add the following sub and code to the form:


Private Sub ExportReport() Dim oPDF As ActiveReportsPDFExport.ARExportPDF Dim oEXL As ActiveReportsExcelExport.ARExportExcel Dim oTXT As ActiveReportsTextExport.ARExportText Dim oHTML As ActiveReportsHTMLExportLexport Dim oTIFF As ActiveReportsTIFFExport.TIFFExport rptExport.Run Select Case exportType Case "PDF" Set oPDF = New ActiveReportsPDFExport.ARExportPDF oPDF.FileName = App.Path & "\PDFExport.PDF" oPDF.Export rptExport.Pages Case "Excel" Set oEXL = New ActiveReportsExcelExport.ARExportExcel oEXL.FileName = App.Path & "\EXLExport.xls" oEXL.Export rptExport.Pages Case "Text" Set oTXT = New ActiveReportsTextExport.ARExportText oTXT.FileName = App.Path & "\TXTExport.txt" oTXT.PageDelimiter = ";" oTXT.TextDelimiter = "," oTXT.Export rptExport.Pages Case "HTML" Set oHTML = New ActiveReportsHTMLExportLexport oHTML.FileNamePrefix = "HTMLExport" oHTMLLOutputPath = App.Path oHTML.Export rptExport.Pages Case "Tiff" Set oTIFF = New ActiveReportsTIFFExport.TIFFExport oTIFF.FileName = App.Path & "\TIFFExport.tiff" oTIFF.Export rptExport.Pages End Select End Sub

9. Save project and run it. Note: In order for a report to be exported to the specified filter, the report must first be run and the export filter must be given a file name to use. Export code can either be placed in a separate sub, such as the code above, or placed in the ActiveReport_ReportEnd event.

Using OnProgress
Each filter has an OnProgress event that can be used to track an export's page progress. This event can be used to display a status bar or counter showing the export's status. Below is a code snippet demonstrating how to use WithEvents to gain access to this event.
Dim myFilter Dim WithEvents FilterEvents As ActiveReportsPDFExport.ARExportPDF Private Sub cmdExport_Click() Set myFilter = New ActiveReportsPDFExport.ARExportPDF rptExport.Run False 'Set the progress bar's max value to the number 'of pages in the report

ActiveReports 2.0 Standard User's Guide | 124


ProgressBar1.Max = rptExport.Pages.Count ProgressBar1.Value = 0 myFilter.FileName = App.Path & "\out.pdf" Set FilterEvents = myFilter myFilter.Export rptExport.Pages End Sub Private Sub FilterEvents_OnProgress(ByVal PageNumber As Long) 'Updates the progress bar ProgressBar1.Value = PageNumber ProgressBar1.Refresh End Sub

Note: More detailed information concerning other methods and properties available for the different export filters can be found in the ARExport help file, which is located in <ActiveReports Install Directory>\Help.

Saving and Loading Canvas Files

Saving and Loading Canvas Files


Saving and loading canvas files allows individual report pages to be saved, loaded or combined together with other reports. Below is a sample, continuing with the project started at the beginning of this chapter, demonstrating the basics for how to save and load these canvas files. 1. Change the code under the cmdLoad_Click event to match below:
Dim cnv As Canvas Dim pgs As Integer Private Sub cmdLoad_Click() Dim rptTemp As ActiveReport Set rptTemp = New ActiveReport For x = 0 To pgs - 1 Set cnv = new Canvas cnv.Load App.Path & "\rptRDF_" & x & ".cnv" rptTemp.Pages.Insert x, cnv Next rptTemp.Pages.Commit ARViewer21.ReportSource = rptTemp End Sub

2. Change the code under the cmdSave_Click event to match below:


Private Sub cmdSave_Click() rptRDFs.Run For Each pg In rptRDFs.Pages Set cnv = rptRDFs.Pages(pgs) cnv.Save App.Path & "\rptRDF_" & pgs & ".cnv" pgs = pgs + 1 Next cmdLoad.Enabled = True cmdSave.Enabled = False End Sub

3. Save the report and run it.

Saving and Loading Report Layouts

Saving and Loading Report Layouts


Report layouts can be save into XML format (.RPX files) by using two different methods. The first method uses the ActiveReports Save/Open menu to save the selected report designer. Note: When saving reports to RPX, only script code will be saved. Below is a code sample, continuing with the project started at the beginning of the chapter, demonstrating how to save and load XML-formatted files (.RPX files) at run time.

ActiveReports 2.0 Standard User's Guide | 125 1. Change the code under the cmdLoad_Click event to match below:
Private Sub cmdLoad_Click() Dim rptTemp As ActiveReport Set rptTemp = New ActiveReport rptTemp.LoadLayout App.Path & "\rptRDF.RPX" ARViewer21.ReportSource = rptTemp End Sub

2. Change the code under the cmdSave_Click event to match below:


Private Sub cmdSave_Click() rptRDFs.Run rptRDFs.SaveLayout App.Path & "\rptRDF.RPX", ddSOFile cmdLoad.Enabled = True cmdSave.Enabled = False End Sub

3. Save the report and run it.

Saving and Loading to a Byte Array

Saving and Loading to a Byte Array


Saving reports as byte arrays make it possible to save and load reports from a database, or pass reports back and forth between dlls. Below is a code sample, continuing with the project started at the beginning of the chapter, demonstrating how to save and load reports to a byte array. 1. Change the code under the cmdLoad_Click event to match below:
Dim rByte() as Byte Private Sub cmdLoad_Click() Dim rptTemp As ActiveReport Set rptTemp = New ActiveReport rptTemp.LoadLayout rByte ARViewer21.ReportSource = rptTemp End Sub

2. Change the code under the cmdSave_Click event to match below:


Private Sub cmdSave_Click() rptRDFs.Run rByte = rptRDFs.SaveLayout("", ddSOByteArray) cmdLoad.Enabled = True cmdSave.Enabled = False End Sub

3. Save the report and run it.

Chapter 14 - Scripting

Chapter 14 - Scripting
What are Scripts For? How to Add Scripts Working with Scripts Using XML (.RPX) Files

What are Scripts for?

ActiveReports 2.0 Standard User's Guide | 126

What are Scripts for?


The main purpose for scripts is to allow reports saved to an XML file to contain code. RPX files are independent of the report designer and cannot run visual basic code. Scripts provide a way to interact with the saved reports using ActiveScripting languages. By including scripting when reports are saved into XML, they can later be loaded, run and displayed directly to the viewer control without needing to use the designer. Scripting can also be used in conjunction with RPX files to allow distributed reports to be updated without recompiling. In addition, you can use script expressions in the DataField property of fields and group sections to create calculated fields and custom grouping. Note: More information about ActiveScripting can be found on Microsoft's site at http://msdn.microsoft.com/scripting/

How to Add Scripts

How to Add Scripts


To add scripting to a report, click the View Scripts icon to open up the script editor (shown below).

Once the script editor is open, each of the report designer's objects and events are accessible. By selecting the desired object and event, scripting code can be set up with the same events as a report in VB code (shown below).

ActiveReports 2.0 Standard User's Guide | 127

If the report is saved to an RPX file, the code added in the script editor will become part of the file. Since the code needed for the report is included in the RPX file, it can easily be loaded, run and then either displayed in the viewer control or exported at a later time.

Please be aware, however, that the RPX file format is not secure (i.e. the user can view the source). If there is any concern about security, connection strings or other sensitive information should be contained in a separate class and accessed using AddNamedItem. AddNamedItem should also be used for setting properties of controls.

Working With Scripts

Working with Scripts


In order to interact with the controls on a report, the following syntax must be used in the script. rpt.Sections("name of section").Controls("name of control") Important: "rpt" must be used with all calls relating back to the report. It functions in the same way as calling "me" in Visual Basic. If the script references a control, a public variable, or a public property in the DSR's code, "rpt" must be used. For example: If a report's database settings need to be modified, the following code could be used in a script.
Sub OnDataInitialize Dim cnnStr ' Set Connection String and connect to DB cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWind.mdb" rpt.DataControl1.ConnectionString = cnnStr ' Set recordset properties and generate recordsset rpt.Sections("Detail").Controls("DataControl1").Source = "Select * from_ customers order by Country" End Sub

Note: Since the RPX format is not secure, putting all sensitive information into a separate class and calling it via AddNamedItem is recommended.

ActiveReports 2.0 Standard User's Guide | 128

Scripts can be used in two different ways, either with the aid of a report DSR file, or independently.

Working With a DSR File


When using an RPX file that contains scripts with a DSR file, the DSR file's code can be run in conjunction with the scripting code. By loading the RPX file from the file menu, or at run-time, the RPX file can be imported into the existing report designer. Note: If an RPX file is loaded into the designer, the report being displayed in the designer will be replaced by the RPX file's layout. When an RPX file is loaded, the event firing sequence will be the standard report event sequences with the saved VB code being called first, followed by the scripting code. Since scripting code is called second, scripts can be used to override pre-existing report code.

Working Without a DSR file


In order to use an RPX file without a DSR file, the saved report needs to be independent of any visual basic code. However, it is also very important to keep sensitive information, such as a connection string, out of the RPX file because the file is not secure. In the following example, the script generates an unbound report in much the same way as setting up a normal unbound report. The sample demonstrates how to use the AddNamedItem method to allow the script to reference a function contained within a class in the project. This allows the connection to be made inside the visual basic project, with the resulting Recordset returned to the script. The sample unbound grouping project from chapter 6 can easily be converted to an unbound scripting sample by removing all the code from the visual basic project and adding the following code in the script editor:
Dim rs ' as ADODB.Recordset Sub OnDataInitialize ' Add fields to ActiveReports' Fields Collection rpt.Fields.Add "Customer" rpt.Fields.Add "City" rpt.Fields.Add "Country" rpt.Fields.Add "PostalCode" ' Set recordset to the recordset returned from calling the ' public function getRSet in clsDB. set rs = myDB.getRSet End Sub Sub OnFetchData(eof) ' Exit sub if EOF is true If rs.EOF Then Exit Sub ' Sets ActiveReports' fields collection values to the ' current recordset value rpt.Fields("Customer").Value = rs.fields("CompanyName") rpt.Fields("City").Value = rs.fields("city") rpt.Fields("Country").Value = rs.fields("Country") rpt.Fields("PostalCode").Value = rs.fields("PostalCode") ' Advance recordset rs.MoveNext ' If not EOF set the FetchData's EOF value to False EOF = False End Sub

1. Once the script has been entered, save the report as "UnboundScript.RPX" and start a new visual Basic project. 2. Select the most current version of Microsoft's ActiveX Data Object Library in Visual Basic's reference list. 3. Add a class to the project and set its name to clsDB. 4. Add the following public function to the class.
Public Function getRSet() As ADODB.Recordset Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset ' Set Connection String and connect to DB

ActiveReports 2.0 Standard User's Guide | 129


cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft _ Visual Studio\VB98\NWind.mdb" cn.Open cnnStr ' Set recordset properties and generate recordsset rs.Open "Select * from customers order by Country", cn Set getRSet = rs End Function

5. Add the ActiveX viewer control to the form and size as desired (see chapter 15). 6. In the Form_Load event, add the following code to load and display the saved RPX file:
Private Sub Form_Load() Dim rptXML As ActiveReport Set rptXML = New ActiveReport rptXML.LoadLayout App.Path & "\UnboundScript.RPX" rptXML.AddNamedItem "myDB", new clsDB rptXML.Run Set ARViewer21.ReportSource = rptXML End Sub

7. Save the project in the same directory as the UnboundScript.RPX file and run it.

Using AddNamedItem and AddCode


The AddNamedItem and AddCode methods are used to add items to the script's global name space. By using AddNamedItem or AddCode code, elements from inside the Visual Basic project can be used inside the scripts. By using AddNamedItem, as seen above, scripts can become aware of functions in a visual basic class contained inside the project. By using AddCode, actual code segments can be added to the script at run-time. The sub added through AddCode must be a properly formatted string. The code segment below demonstrates how to use AddCode within a project:
Private Sub ViewPreview() On Error GoTo ehViewPreview Set m_rpt = Nothing Set m_rpt = New ActiveReport m_rpt.ResetScripts m_rpt.AddNamedItem "vbo", m_vbo m_rpt.AddCode ScriptCode() m_rpt.ScriptDebuggerEnabled = True m_rpt.Run False Set arv.ReportSource = m_rpt Exit Sub ehViewPreview: MsgBox Str(Err.Number) & " - " & Err.Description, vbOKOnly, _ "Error: ViewPreview" End Sub Private Function ScriptCode() As String Dim sCode As String sCode = sCode & _ "Function IIf(Expression, TruePart, FalsePart) " & vbCrLf & _ "IIf = vbo.IIf(Expression, TruePart, FalsePart)" & vbCrLf & _ "End Function" & vbCrLf & vbCrLf sCode = sCode & _ "Function Format(expr, fmt) " & vbCrLf & _ " Format = vbo.Format(expr, fmt)" & vbCrLf & _ "End Function" & vbCrLf & vbCrLf ScriptCode = sCode End Function

Note: Scripting contains many advanced features and possibilities that go beyond the scope of this manual. For more advanced demonstrations on scripting possibilities, please visit our knowledgebase and included sample projects.

Using RPX Files

Using XML (.RPX) Files

ActiveReports 2.0 Standard User's Guide | 130

RPX files contain report layouts that use an open XML based format. The XML schema contains the layout and scripts for each report. The RPX files allow distributed reports to be changed and modified without having to recompile the project. Using RPX files also makes it possible to use a database of report file names to set up a collection of reports to run. Since RPX files are using an open format, future compatibility with platforms such as .NET is built in. When saving your report layouts to RPX files you should not use compiled VB events because that code cannot be stored in the RPX files and loading and running the RPX file might result in runtime errors.

Chapter 15 - Using ActiveReports' ActiveX Viewer Control

Chapter 15 - Using ActiveReports' ActiveX Viewer Control


ActiveReports' ARViewer Control Adding the Viewer to VB Creating a Custom Preview Form Using Split Windows with the Viewer Adding Buttons to the Viewer Control Controlling Printing and Printer setup on the Viewer

ActiveReports' ActiveX Viewer Control

ActiveReports' ActiveX Viewer Control


ActiveReports includes a lightweight ActiveX control to view report output in custom preview forms or in Microsoft Internet Explorer. The ActiveX viewer allows developers to modify the toolbars or add their own custom menu commands to the preview form.

ActiveReports 2.0 Standard User's Guide | 131

You can create your own localized preview window by modifying the tools, captions and tooltips. This section explains the steps needed to add the viewer control to your project, use it on a form and add more output functionality to your preview.

Adding the Viewer Control to VB

Adding the Viewer Control to VB


1. Select Project > Components from Visual Basic menu or press Ctrl-T to display the components dialog box. 2. Select and check the "Data Dynamics ActiveReports Viewer 2.0" entry in the list.

3. The ActiveReport Viewer icon

should appear in your toolbox.

Note: If you do not see the "ActiveReports Viewer Control" in the list, you might need to register the ARView2.ocx using RegSvr2.EXE. It is located in your ActiveReports installation directory.

Creating a Custom Preview Screen

Creating a Custom Preview Screen


1. Start with the "Quick Start" example project described earlier. 2. Remove Form1 and add a new form to your project. 3. Set the form name to frmPreview. 4. Click on the "ActiveReport Viewer" icon in your toolbox.

5. Place the control on your form, size it according to your needs. 6. Set the control name to arv. 7. Add the following code to the frmPreview_OnLoad event:

ActiveReports 2.0 Standard User's Guide | 132


Private Sub Form_Load() arv.ReportSource = New ActiveReport1 End Sub

Your form should look like this:

Using Split Windows on the Viewer Control

Using Split Windows on the Viewer Control


The Viewer control's windows can easily be split into two sections by dragging the slitter control down.

ActiveReports 2.0 Standard User's Guide | 133

Once the viewer is split into two section, report layouts can be examined and report pages can easily be compared.

Adding Buttons to the Viewer Control

Adding Buttons to the Viewer Control


This sample project demonstrates how to customize the viewer control by adding additional buttons

ActiveReports 2.0 Standard User's Guide | 134 and icons. After adding these buttons, special functions such as exporting or exiting the project, can be set up to run when the buttons are clicked. 1. Start a new Visual Basic standard EXE project. 2. Set Form1's properties as follows: Name BorderStyle Height Width frmViewer 1-Fixed Single 8310 13440

3. Select the ActiveX Viewer Control from VB's component list and add the viewer control to frmViewer. 4. Select Microsoft's Common Dialog control from VB's component list and add the control to frmViewer. 5. Set the common dialog control's name to cmndlg. 6. Set the viewer control's properties as follows: Name Height Left Top Width 7. Add the following code to the report:
Private Sub addButtonsToARV() 'Insert a splitter control 'in the second position (after the 'TOC button) arv.ToolBar.Tools.Insert 1, "" arv.ToolBar.Tools.Item(1).Type = 2 arv.ToolBar.Tools.Item(1).ID = 999 'Insert the Close botton in the 'third position arv.ToolBar.Tools.Insert 2, "Close" arv.ToolBar.Tools.Item(2).Caption = "&Close" arv.ToolBar.Tools.Item(2).Tooltip = "Close Project" arv.ToolBar.Tools.Item(2).ID = 1000 'Insert another splitter in the 'fourth position arv.ToolBar.Tools.Insert 3, "" arv.ToolBar.Tools.Item(3).Type = 2 arv.ToolBar.Tools.Item(3).ID = 1001 'Insert the Open button in the 'fifth position and assign it 'and icon arv.ToolBar.Tools.Insert 4, "O&pen" arv.ToolBar.Tools.Item(4).AddIcon LoadPicture("C:\Program Files\Microsoft _ Visual Studio\Common\Graphics\Icons\Win95\openfold.ico") arv.ToolBar.Tools.Item(4).Tooltip = "Open RDF File" arv.ToolBar.Tools.Item(4).ID = 1002 'Insert the Save button in the sixth 'position and assign it an icon and 'disable it arv.ToolBar.Tools.Insert 5, "&Save" arv.ToolBar.Tools.Item(5).AddIcon LoadPicture("C:\Program Files\Data _ Dynamics\ActiveReports Pro\Samples\Professional Edition\Diamond Reports_ \res\Standard\tfsave.ico") arv.ToolBar.Tools.Item(5).Tooltip = "Save Report to RDF" arv.ToolBar.Tools.Item(5).Enabled = False

arv 7815 120 0 13095

ActiveReports 2.0 Standard User's Guide | 135


arv.ToolBar.Tools.Item(5).ID = 1003 'Add the PDF export button to the 'end of the toolbar and disable it arv.ToolBar.Tools.AddEx("&PDF").Tooltip = "Export To PDF" arv.ToolBar.Tools.Item(arv.ToolBar.Tools.Count - 1).Enabled = False arv.ToolBar.Tools.Item(arv.toolbar.tools.count-1).ID = 1004 End Sub

8. Add the following code to the Form_Load event:


Private Sub Form_Load() addButtonsToARV End Sub

9. Add the following code to the arv_ToolbarClick event:


Private Sub arv_ToolbarClick(ByVal Tool As DDActiveReportsViewer2Ctl.DDTool) Select Case Tool.Caption Case Is = "O&pen" 'Call the open sub tbOpen Case Is = "&Close" 'call the exit sub tbExit Case Is = "&PDF" 'call the PDFExport sub tbPDFExport Case Is = "&Save" 'call the Save sub tbSave End Select End Sub

10. Add the following subs to handle the click events:


Private Sub tbExit() Unload Me End Sub Private Sub tbOpen() cmndlg.Filter = "Report Document File (*.rdf)|*.rdf" cmndlg.ShowOpen If cmndlg.FileName <> "" Then If Not arv.ReportSource Is Nothing Then Set arv.ReportSource = Nothing End If arv.Pages.Load cmndlg.FileName 'Enables buttons when a report is loaded arv.ToolBar.Tools.Item(5).Enabled = True arv.ToolBar.Tools.Item(arv.ToolBar.Tools.Count - 1).Enabled = True End If End Sub Private Sub tbPDFExport() Dim pdf As New ActiveReportsPDFExport.ARExportPDF Set pdf = New ActiveReportsPDFExport.ARExportPDF cmndlg.Filter = "Portable Document Format" & _ " (*.pdf)|*.pdf" cmndlg.DefaultExt = ".pdf" cmndlg.ShowSave If cmndlg.FileName <> "" Then pdf.FileName = cmndlg.FileName If Not arv.ReportSource Is Nothing Then pdf.Export arv.ReportSource.Pages Else pdf.Export arv.Pages End If End If End Sub Private Sub tbSave()

ActiveReports 2.0 Standard User's Guide | 136


cmndlg.Filter = "Report Document File (*.rdf)|*.rdf" cmndlg.DefaultExt = ".rdf" cmndlg.ShowSave If cmndlg.FileName <> "" Then If Not arv.ReportSource Is Nothing Then arv.ReportSource.Pages.Save _ cmndlg.FileName Else arv.Pages.Save cmndlg.FileName End If End If End Sub

Warning: Setting the viewer's ReportSource = nothing while the report is still running will not cancel the report. If the ReportSource is set to nothing while the report is running, the viewer will retain the pages already processed, and the table of contents will not work. To clear the viewer use .Pages.RemoveAll and then .Pages.Commit. 11. Save the project and run it.

Controlling Printing and Printer Setup on the Viewer

Controlling Printing and Printer Setup on the Viewer


The viewer control has a Printer property that you can use to set up the printer or call the print method for some pages in the Pages collection. Note: Paper size and page orientation will not be reflected in the report until you restart it since the report has been rendered to the original print specification. You can create a global printer object and use it for all reports included in your application. Before starting each report you can set the printer property of the report to the global printer object. Using the same preview form, we will implement printer setup and print menu options. Add the following code to your form: 1. Continuing with the project started above, add the following code to the Form_Load event:
Private Sub Form_Load() addButtonsToARV ' This overrides the print tool For cnt = 0 To arv.ToolBar.Tools.Count - 1 If "&Print..." = arv.ToolBar.Tools(cnt).Caption Then arv.ToolBar.Tools(cnt).ID = CONST_PRINTTOOLID End If Next cnt End Sub

2. Modify the arv_ToolbarClick event to handle the printer click event:


Private Sub arv_ToolbarClick(ByVal Tool As DDActiveReportsViewer2Ctl.DDTool) Dim bReturn As Boolean Select Case Tool.Caption Case Is = "O&pen" 'call the open sub tbOpen Case Is = "&Close" 'call the exit sub tbExit Case Is = "&PDF" 'call the PDFExport sub tbPDFExport Case Is = "&Save" 'call the Save sub tbSave Case Is = "&Print..." arv.UseSourcePrinter = True arv.Printer.SetupDialog bReturn = arv.Printer.PrintDialog(Me.hWnd)

ActiveReports 2.0 Standard User's Guide | 137


If bReturn Then arv.PrintReport False CancelledJob = False Else CancelledJob = True End If End Select End Sub

3. Modify the Open sub to enable the printer button:


Private Sub tbOpen() cmndlg.Filter = "Report Document File (*.rdf)|*.rdf" cmndlg.ShowOpen If cmndlg.FileName <> "" Then If Not arv.ReportSource Is Nothing Then Set arv.ReportSource = Nothing End If arv.Pages.Load cmndlg.FileName 'Enables buttons when a report is loaded arv.ToolBar.Tools.Item(5).Enabled = True arv.ToolBar.Tools.Item(arv.ToolBar.Tools.Count - 1).Enabled = True 'Enable print button arv.ToolBar.Tools.Item(7).Enabled = True End If End Sub

Chapter 16 - ActiveReports on the Web

Chapter 16 - ActiveReports on the Web


Using the ARViewer Control with Internet Explorer Using the Java Viewer Control Creating a ReportServer with ASP and ActiveReports

Using the Viewer Control with Internet Explorer

Using the ARViewer Control with Internet Explorer


Saved RDF reports can be used in conjunction with the ActiveX viewer in Microsoft Internet Explorer. The DataPath property allows you to download pages asynchronously to the client browser. This is an example of inserting the viewer control into your page.
<object ID="arv" classid="clsid:8569D715-FF88-44BA-8D1D-AD3E59543DDE" codebase="arview2.cab" width=100% height=70%> /object> <Script LANGUAGE="VBScript"> ' Set the data path to the relative path ' of your pages output Sub Window_onLoad() ARViewer1.DataPath="salesbycountry.rdf" End Sub </Script>

Note: The Window_OnLoad event should be used to set the DataPath. If this event is not used, reports may not be displayed. There are several ways distribute reports on the web. If you have periodic reports you can schedule a VB application to process reports and transfer new RDF files to your web site. On the other hand, if you want live reports you can generate reports on the fly by either using ASP pages or using CGI

ActiveReports 2.0 Standard User's Guide | 138 scripts which will run reports interactively. Note: Since web environments do not create event handlers automatically, you must create these yourself. Remember that if you use events that require parameters, you must supply these parameters or the events will not fire.

Using the Java Viewer Control

Using the Java Viewer Control


ActiveReports' Java viewer (ARViewer.jar) can be used with browsers not supporting ActiveX controls. Below is a sample html page demonstrating how to use the JavaViewer to load RDF reports:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- saved from url=(0052)http://www.datadynamics.com/test/arvj/NSIEWinSol.asp--> <HTML><HEAD><TITLE>ARJavaViewer HTML Test Page</TITLE> <META content="text/html; charset=windows-1252" http-equiv=Content-Type> <SCRIPT event=actionPerformed(ActionEvent1) for=Arvj language=javascript type=text/javascript> <!-//window.alert("TOC or Hyperlink:[" + ActionEvent1.getSource().toString() + "]." ); //--> </SCRIPT> <SCRIPT language=JavaScript type=text/javascript> <!-function cboReport_onChange() { var sFile = Form1.cboReport.options(Form1.cboReport.selectedIndex).text; Form1.Arvj.setDataPath("reports/" + sFile ); //alert(cboReport.options(cboReport.selectedIndex).text); return; } //--> </SCRIPT> </HEAD> <BODY> <DIV style="BORDER-BOTTOM: 1px; BORDER-LEFT: 1px; BORDER-RIGHT: 1px; BORDER-TOP:1px"><LABEL for=txtPassword>Enter the password for your report file here and click 'set':</LABEL> <INPUT id=txtPassword name=txtPassword size=6> <INPUT id=button1 name=button1 onclick=Form1.Arvj.getPages().setPassword(txtPassword.value); type=button value="Set Password"> </DIV><!--"CONVERTED_APPLET"--><!-- CONVERTER VERSION 1.3 --> <FORM action="" id=Form1><BR>Please select a report from the list below:<BR> <SELECT id=cboReport name=cboReport onchange="return cboReport_onChange()"> <OPTION selected>AnnualReport.rdf</OPTION> <OPTION>Catalog.rdf</OPTION> <OPTION>CustomerLabels.rdf</OPTION> <OPTION>CustomersPhoneBook.rdf</OPTION> <OPTION>EmployeeProfiles.rdf</OPTION> <OPTION>EmployeeSales.rdf</OPTION> <OPTION>EmployeeSalesByCountry.rdf</OPTION> <OPTION>Invoice.rdf</OPTION> <OPTION>PriceListByCategory.rdf</OPTION> <OPTION>ProductInventoryByCategory.rdf</OPTION> <OPTION>ProductWeeklySales.rdf</OPTION> <OPTION>Top10.rdf</OPTION> </SELECT> <BR>com.datadynamics.activereports.ActiveReportsViewer will appear below in a Java enabled browser.<BR> <OBJECT align=middle classid=clsid:8AD9C840-044E-11D1-B3E9-00805F499D93 codeBase=http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0 height="70%" id=Arvj name=Arvj width="80%"><PARAM NAME="ARCHIVE" VALUE="ARViewer.jar"> <PARAM NAME="cache_option" VALUE="Plugin"> <PARAM NAME="cache_archive" VALUE="ARViewer.jar">

ActiveReports 2.0 Standard User's Guide | 139


<PARAM NAME="cache_version" VALUE="1.0"> <PARAM NAME="CODE" VALUE="com.datadynamics.activereports.ActiveReportsViewer"> <PARAM NAME="CODEBASE" VALUE="."> <PARAM NAME="NAME" VALUE="ArvjName"> <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> <PARAM NAME="scriptable" VALUE="true"> <PARAM NAME="bridgeevents" VALUE="no"> <!-- PARAM NAME="dataPath" VALUE="reports/CustomerLabels.rdf" --> COMMENT> <EMBED type="application/x-java-applet;version=1.3" CODE = "com.datadynamics.activereports.ActiveReportsViewer.class" CODEBASE = "." ARCHIVE = "ARViewer.jar" NAME = "TestApplet" WIDTH = 480 HEIGHT = 640 ALIGN = middle VSPACE = 0 HSPACE = 0 dataPath = "reports/CustomerLabels.rdf" scriptable=true pluginspage="http://java.sun.com/products/plugin/1.3/plugin -installl"> <NOEMBED> </NOEMBED> </EMBED> </COMMENT> </OBJECT></ FORM><!-<APPLET CODE = "com.datadynamics.activereports.ActiveReportsViewer.class" CODEBASE = "." ARCHIVE = "ARViewer.jar" WIDTH = 480 HEIGHT = 640 NAME = "TestApplet" ALIGN = middle VSPACE = 0 HSPACE = 0> <PARAM NAME = "dataPath" VALUE = "reports/CustomerLabels.rdf"> </APPLET> --><!--"END_CONVERTED_APPLET"--></BODY></HTML>

Note: A more detailed explanation for using the JavaViewer can be found in the ..\Help\Java Viewer directory.

Creating a ReportServer with ASP and ActiveReports

Creating a ReportServer with ASP and ActiveReports


Setting up the ReportServer DLL
One possible way to use ActiveReports to serve reports on the web is to create an ActiveX DLL that combines all your reports with a class. The class will then manage running and saving the reports to a selected export filter. The class will create an instance of the requested report and save it to a directory where the ASP script can push it to the client. The most critical part of creating a reporting ActiveX DLL is to not display any type of UI, including message boxes, forms or report preview screens. It is also important to make sure each event in the report has proper error handling. Using "On Error Goto " and the ActiveReport Error event, with the event's CancelDisplay parameter set to True, will help prevent any messages. Any UI appearing in the server DLL will cause the server to lock-up while waiting on input. Errors should be handled and can be logged using the App.LogEvent method. If a report server appears to be locking up, using App.LogEvent will help track down which event is being called last. Once the specific event has been identified, App.LogEvent can be used to track the problem down to a specific line. When using logging and error handling, pay close attention to the following report events: Initialize, DataInitialize, NoData, Error, ReportStart, ReportEnd, and Terminate. The sample code below gives an example for a basic class. In the sample, a specified report, from the Report property, and a specified export filter, from the OutputFormat property, are used to indicate which report to run and which export filter to use when saving the report.
Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" _ (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, _ ByVal lpTempFileName As String) As Long Enum eOutputFormat eRDF ePDF End Enum Enum eReport erptAnnualReports erptCatalog erptCustomerLabels End Enum

ActiveReports 2.0 Standard User's Guide | 140

Public Property Let Report(iRpt As eReport) Dim hr As Long App.LogEvent "Report: " & iRpt Debug.Print "Report: " & iRpt m_iReport = iRpt End Property Public Property Let OutputFormat(iFormat As eOutputFormat) App.LogEvent "OutputFormat: " & iFormat Debug.Print "OutputFormat: " & iFormat m_iFormat = iFormat End Property Public Function StripFileName(path As String) As String Dim iStart As Integer iStart = InStrRev(path, "\") StripFileName = Mid(path, iStart + 1, Len(path) - iStart) End Function Public Property Get FileName() As String App.LogEvent "FileName" Debug.Print "FileName" m_sFName = StripFileName(m_sFName) FileName = m_sFName End Property Public Function RunReport() As Boolean On Error GoTo Errhndl Dim rpt As Object Dim pdf As New ActiveReportsPDFExport.ARExportPDF 'Use App.LogEvents to debug compiled code App.LogEvent "RunReport Started" Debug.Print "RunReport Started" Select Case m_iReport Case erptAnnualReports: Set rpt = New rptAnnualReport Case erptCatalog: Set rpt = New rptCatalog Case erptCustomerLabels: Set rpt = New rptCustomerLabels Case Else RunReport = False Exit Function End Select App.LogEvent "Preparing to Run" Debug.Print "Preparing to Run" rpt.Run False App.LogEvent "Report Ran" Debug.Print "Report Ran" m_sFName = String(255, Chr$(0)) ' GetTempFileName is a Win32 API function, you need ' to add the declaration in one of your modules If Not GetTempFileName(sServerPath, "AR", -1, m_sFName) Then RunReport = False Exit Function End If m_sFName = Left$(m_sFName, InStr(m_sFName, Chr$(0)) - 1) App.LogEvent "File name = " & m_sFName Debug.Print "File name = " & m_sFName If m_iFormat = eRDF Then App.LogEvent "Exporting to RDF" Debug.Print "Exporting to RDF" rpt.Pages.Save m_sFName App.LogEvent "Export to RDF Complete" Debug.Print "Export to RDF Complete" ElseIf m_iFormat = ePDF Then pdf.FileName = m_sFName App.LogEvent "Exporting to PDF" Debug.Print "Exporting to PDF" pdf.Export rpt.Pages App.LogEvent "Export to PDF Complete" Debug.Print "Export to PDF Complete" End If App.LogEvent "RunReport Completed"

ActiveReports 2.0 Standard User's Guide | 141


Debug.Print "RunReport Completed" Exit Function ErrHndl: App.LogEvent "Error Fired in RunReport: " & Err.Number & ":" & Err.Description, 2 Debug.Print "Error Fired in RunReport: " & Err.Number & ":" & Err.Description RunReport = False End Function

Setting up the ASP script


When setting up the ASP page for access on the web, it is very important to verify that the default user for the web site has the necessary permissions to access the page, the report dll, ActiveReports cab file and dll files, and the database. It is also important to make sure the default user has write access to the folder being used for exporting. If a project exhibits problems, such as not initiating the report server dll or failing on the export, the problem will probably be related to permissions. A quick way to rule out a permissions problem is to temporarily add the web site's default user to the administrators group. The ASP script below will set the two properties Report and Output Format and then run the report.
<%@ LANGUAGE="VBSCRIPT" %> <% Dim rptServer Dim fname Set rptServer = CreateObject("ARASPSample.ReportServer") rptServer.Report = Request.Form("cboReport") rptServer.OutputFormat = 1 If rptServer.RunReport() Then fname = rptServer.FileName %> <CENTER> <object ID="arv" classid="clsid:8569D715-FF88-44BA-8D1D-AD3E59543DDE" codebase="arview2.cab" width=% height=70%> </object> </CENTER> <BODY FONT="Arial"> <script LANGUAGE="VBScript"> <!-Sub window_onload() ' set the initial reportsource data path arv.DataPath="Reports/<%Response.Write fname%>" end sub --> </script> <%else%> <BODY> <P> Error: Unable to create report.<BR> Please send email to <A HREF="mailto:ActiveReports.Support@DataDynamics.com">ActiveReports. Support@DataDynamics.com</A><BR> </P> <%end if%> </BODY>

Note: This is a simplified sample demonstrating the techniques used to make reports available on the web. A more detailed sample can be found in the ActiveReports knowledgebase: http://www.datadynamics.comm/kb

Web Server Distribution


To serve reports to clients in a web environment, your web server should have arview2.cab (if using

ActiveReports 2.0 Standard User's Guide | 142 ActiveReports Viewer Control), actrpt2.dll (always) and arpro2.cab (if using the professional editions end user designer). You should also register any export dlls needed.

Support and Licensing

Support and Licensing


Registration Technical Support Data Dynamics Web Site Data Dynamics News Server Upgrades Suggestions Defects Policy License Agreement ActiveReports Error Codes

Production Registration

Product Registration
In order to receive telephone support and product news and upgrade announcements, you must register your product purchase with Data Dynamics. We encourage you to register your purchase as soon as you receive it using any of the following: Fill out the enclosed registration card and mail it to Data Dynamics, 5870 Cleveland Avenue, Columbus, Ohio 43231 or fax it to Data Dynamics at (614) 899-2943. Or, you can use our online registration form on our web site at http://www.datadynamics.com (http://www.datadynamics.com/)

Technical Support

Technical Support
If you are having problems using ActiveReports 2.0, please make sure the control is properly registered by the installation program. If not, use RegSvr32.exe to register the ActRpt2.dll, ARView2.ocx and ARDesign2.DLL files. Note: RegSvr32.EXE is included with the Visual Basic installation. If the problem remains, and no solution is listed on our support web site or newsgroups server, please contact our technical support staff. Note: Telephone support is only available to registered customers. Registered users are allowed up to five support incidents resolved over the telephone. Additional support requests should be directed to our newsgroup. If desired, additional telephone support can be acquired by purchasing any of our support packages. Contact sales@datadynamics.com for details. Be Prepared: When contacting Data Dynamics with support questions, be prepared to provide a serial number, the full version number of ActiveReports, a complete description of the problem, and hardware and operating environment specifications. Web Sites http://www.datadynamics.com (http://www.datadynamics.com/Support/SupportOptions.aspx) the Data Dynamics official web site. A source for patches, updates and product downloads.

ActiveReports 2.0 Standard User's Guide | 143

http://www.datadynamics.com/Support/SupportOptions.aspx - the Data Dynamics Support page with links to the KnowledgeBase and Forums Search the knowledgebase to find help with common problems, "How To" articles and downloadable samples. FTP ftp://ftp.datadynamics.com/activereports2 - the Data Dynamics FTP site. A source for sample projects. Forums http://www.datadynamics.com/Forums - Data Dynamics' Newsgroups. A source for finding out how other ActiveReports developers are using the product. E-mail activereports.support@datadynamics.com Telephone and Fax Fax: 614.899.2943 Telephone: 614.895.3142 (8 a.m. to 7 p.m. EST, M-F)

Web Site

Web Site
Our web site will be updated with the latest product news, white papers, tutorials, report samples and product service packs. Please visit our web site for the latest news about the product before contacting technical support. You will likely find the answers you are seeking. Web server address: http://www.datadynamics.com

NewsGroups

Forums
Use our forums to read and post questions and answers. Communicate tips and tricks with other users and get access to our technical support in an online community forum. Our Support Engineers monitor the forums continually and they will be there to answer questions and assist with any issues you might encounter using the product. Product announcements will also be posted to the forums. Forums can be accessed at: http://www.datadynamics.com/Forums

Product Upgrades

Product Upgrades
Minor upgrades and service packs will be made available for download from our web site free of charge. Major upgrades will carry an upgrade price that is determined separately for each release. You will be entitled to a free major upgrade if you purchased within 30 days of the upgrade release date.

Suggestions

Suggestions
We at Data Dynamics welcome your suggestions for improving ActiveReports. Much of the initial feedback has been included in this version of ActiveReports. Please contact us through any of the above channels to tell us how we can improve.

ActiveReports 2.0 Standard User's Guide | 144

Disk Defects Policy

Media Defects Policy


Data Dynamics is committed to producing a quality product that undergoes an extensive series of tests and refinements at both the manufacturing and development levels. In the unfortunate case that you receive defective media, Data Dynamics will replace your media free of charge. Please contact us at the above address to get your replacement media.

License Agreement and Limited Warranty

License Agreement and Limited Warranty ActiveReports 2.0


Please read carefully before installing this software package. Your installation of the package indicates your acceptance of the terms and conditions of this license agreement. Contact Data Dynamics if you have any questions about this license. The Product (libraries and object code) is proprietary to Data Dynamics, Ltd. and is protected by Federal Copyright Law. Data Dynamics retains the title to and ownership of the Product. You are licensed to use this Product on the following terms and conditions:

LICENSE
The Product is licensed per software application developer (developer). Licensee is defined as the person or entity that pays consideration for the license to use the Product. Data Dynamics hereby grants the Licensee a nonexclusive License authorizing one, and only one, developer at a time to use the Product for development purposes. The Licensee is also permitted to distribute applications containing the files designated below on a royalty free basis. The use of this License does not create any kind of partnership or joint ownership interest in the Licensees proprietary applications. Please contact Data Dynamics if you require additional Licenses. Licensee may incorporate the sample code into Licensees applications. Use of this product by more than one developer at a time terminates, without notification, this License and the right to use this product.

LICENSEE MAY NOT:


Distribute, rent, sub-license or otherwise make available to others the software or documentation or copies thereof, except as expressly permitted in this License without prior written consent from Data Dynamics. In the case of an authorized transfer, the transferee must agree to be bound by the terms and conditions of this License Agreement.

RESTRICTIONS:
Licensee may use this Product in Licensees business application for sale or distribution as long as: 1. The product that Licensee produces and/or distributes is NOT a software development product; a product that is sold primarily to software developers or system integrators or a development environment of any kind. Please contact Data Dynamics, Ltd. for special commercial licensing provisions in these circumstances. 2. The software serial number and Licensee must be registered with Data Dynamics in order to receive support or distribution rights. 3. Licensee may not remove any proprietary notices, labels, trademarks on the software or documentation. 4. Licensee may not modify, de-compile, disassemble, reverse engineer or translate the software.

FILES THAT MAY BE DISTRIBUTED WITH LICENSEES APPLICATION:


Standard Edition License: ACTRPT2.DLL, PDFExpt.DLL, RTFExpt.DLL, ARVIEW2.OCX, ARVIEW2.CAB, HTMLExpt.DLL, TEXTExpt.DLL, TIFFExpt.DLL, and EXCLExpt.DLL. Professional Edition License:

ActiveReports 2.0 Standard User's Guide | 145

ARPRO2.DLL, ARDESPRO2.DLL, WEBCACHE.EXE, and WEBCACHE.DLL.

US GOVERNMENT RESTRICTED RIGHTS


Use, duplication or disclosure by the United States Government is subject to restrictions as set forth under DFARS 252.227-7013 or in FARS 52.227-19 Commercial Computer Software - Restricted Rights.

TERM
Licensee may terminate its License and this Agreement at any time by destroying all copies of the Product and Product Documentation. This License and this Agreement will also terminate automatically if the Licensee fails to comply with any term or condition in this Agreement.

LIMITED WARRANTY
This software and documentation are sold "as is" without any warranty as to their performance, merchantability or fitness for any particular purpose. Licensee assumes the entire risk as to the quality and performance of the software. Data Dynamics warrants that the media on which the Program is furnished will be free from any defects in materials. Exclusive remedy in the event of a defect is expressly limited to the replacement of media. In no event shall Data Dynamics or anyone else who has been involved in the creation, development, production, or delivery of this software be liable for any direct, incidental or consequential damages, such as, but not limited to, loss of anticipated profits, benefits, use, or data resulting from the use of this software, or arising out of any breach of warranty.

ActiveReports Error Codes

ActiveReports Error Codes


Error Code 2000 2001 2002 2003 Description GridX/Y out of range. The valid range is 1 to 48 Section.Name is invalid. Only alphanumeric characters are allowed. Duplicate Name. The Control or Section name already exists Invalid Property Value. The Property value is out of range or incorrect. Object ActiveReport Section Section, Control ActiveReport, CheckBox, Canvas, Field, TOC, Label, OleObject, Printer, RDOControl, Shape, Section, BarCode RDO Data Control RDO Data Control RDO Data Control Printer Printer Printer Printer Printer

2004 2005 2006 2007 2008 2009 2010 2011

RDO control RowsetSize or KeysetSize was set to incorrect value. RDO control resultset was set to invalid object. The control was expecting a valid resultset object. RDO control connection property was set to invalid or empty object. The control was expecting a valid connection object. Printer driver doesn't support PaperBins. Printer driver doesn't support custom PaperSize (256). Printer.StartJob was called multiple times without ending prior job. Printer.EndJob called without a call to Printer.StartJob. Printer.Escape method called but no printer job is active. Call Printer.StartJob to start sending escape codes to printer. Invalid call to Printer.StartPage, EndPage, PrintPage . Print job is not active. Call Printer.StartJob first. Passthrough escape sequences are not supported by the current printer driver Accessing SubReport.Object failed. The object property has not yet been set.

2012 2013 2014

Printer Printer Subreport

ActiveReports 2.0 Standard User's Guide | 146

2015 2016 2017 2018 2019 2020 2021 2100 2101 2102

SubReport.Object property was set to invalid object. The object property only supports a valid ActiveReport instance. Controls.Item or Controls.Remove was called with incorrect index. The control name does not exist in the collection. ReplaceField called with field name that doesn't exist in the RTF document. Margins are too large Page header and footer are too large, can't process report layout RDO (Remote Data Object) is not installed on this machine The filter parameter is not a valid export filter. Duplicate Field name. The report fields collection already has a member with same field name. Report already started processing. Can't change Fields collection at this time. The sections collection of the report has been modified and the section types are incorrect. Please make sure the section order is correct and each header section has a corresponding footer section. ActiveReport.Load failed. MSXML 3.0 is not installed or could not create XMLDOMDocument object. ActiveReport.Load failed. Unknown error due to MSXML. ActiveReport.Load failed. The XML data is incorrect (wrong node hierarchy) or corrupt. XMLControl.Load failed. Error due to empty FileURL property. Field.Text property contains invalid expression. Parsing failure on script. Field script expression failed during execution of report. Can't load RDF file. Invalid password. Please set password property before calling Pages.Load method. GetPagesInRange parameter is invalid. Incorrect page range. Can't modify Pages collection. This Pages collection was obtained using GetPagesInRange method and is read-only. PrintPage was called with invalid Left, Top, Width, Height parameters. Property access failed due to invalid section type. Example: detail sections don't support the GrpKeepTogether property. Method failed due to invalid ADO control properties. Please check Connection string. XML Data Control was expecting a valid XMLDOMNodeList object. Method failed due to empty pages collection. PrintAtBottom is being specified for a section that does not support it, such as a PageHeader or PageFooter. An invalid index has been specified for the Parameters collection. Report processing failed due to error in data source or a serious error. Please see description. Bad parameter value Method failed. Can't create file. Incorrect filename or target file exists or is read-only. See description Method failed. Can't read file. Please check if the file exists and make sure you have access permissions to the file.

Subreport Controls RichEdit ActiveReport ActiveReport ActiveReport Export ActiveReport.Fields ActiveReport.Fields ActiveReport

2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2120 5000 5003 5004 5005

ActiveReport ActiveReport ActiveReport XML Control Field Field Pages Pages Pages Printer Section ADO Control XML Control Pages, Export filters Section Parameters ActiveReport All objects Canvas, Pages Canvas, Pages

ActiveReports 2.0 Standard User's Guide | 147

5006 5007

The RDF file or canvas binary file is corrupt or has incorrect file format. No printer installed. Can't run report. Either install a printer or set the Printer.DeviceName property to empty to use a virtual printer. Report already processing. Can't modify sections collection at this time. Print Job has not yet been started, can't return Printer.hDC property. Printer.Escape method failed. The escape is not supported by driver or printer driver rejected parameters. Value out of range. Printer timeout. Possible reason: network printer is offline. Invalid DataPath property. The URL doesn't exist or failed. Driver reported error when trying to set Printer.Port Invalid printer port name or port name doesn't exist. Subreport failed during processing of report. See description for error. Invalid index provided in Sections.Add method. Can't open ADO connection. Please check ADO connection string. Can't remove section. Section name is incorrect. Can't set Printer.DeviceName. The device doesn't exist Setting ReportSource failed due to incorrect object. Please pass a valid ActiveReport object from the same process. ReportSource failed to respond. ReportSource.GetReport returned incorrect object type.

Canvas, Pages ActiveReport

5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5704 5706 5707 7000 7001 7002

Sections Printer Printer All objects Printer ARViewer Printer Printer ActiveReport Sections ADO Control Sections Printer ARViewer ARViewer ARViewer

ActiveReports 2.0 Standard User's Guide | 148

Reference

Reference
Constants ActiveReports' Architecture Common Properties Common Methods ActiveReport ARViewer Control Border Properties< /P> Canvas Controls Data Controls< /P> History Pages and PageSettings PaperSizes Methods Parameters Printer RptFields Sections TOC Tools and Toolbar

Constants

Constants
ADOLockType
Value -1 1 2 Mnemonic ddADOLockUnspecified ddADOLockReadOnly ddADOLockPessimistic Read-only, you cannot alter the data Record-by-record locking. The provider does what's necessary to ensure successful editing of the records, usually by locking records at the data source immediately upon editing. The provider uses optimistic locking, locking records only when you call the update method. Required for the batch update mode as opposed to immediate update mode. Description

3 4

ddADOLockOptimistic ddADOLockBatchOptimistic

ADOCursorLocation
Value 2 3 Mnemonic ddADOUseServer ddADOUseClient Description Create a server-side cursor. Create a client-side cursor.

ADOCursorType

ActiveReports 2.0 Standard User's Guide | 149

Value 0 1 2 3

Mnemonic ddADOOpenForwardOnly ddADOOpenKeyset ddADOOpenDynamic ddADOOpenStatic

Description Default - Creates a forward-only cursor. Keyset cursor Dynamic Cursor Static cursor

BackStyle
Value 0 1 Mnemonic ddBKTransparent ddBKNormal Description Transparent opaque background, the objects behind the object show through the object. Normal, the object hides all controls behind it.

BarCodeCaptionPosition
Value 0 1 2 Mnemonic ddbcCaptionNone ddbcCaptionAbove ddbcCaptionBelow Description Does not display the barcode's caption. The caption is positioned above the barcode. The caption is positioned below the barcode.

BarCodeDirection
Value 0 1 2 3 Mnemonic ddbcLeftToRight ddbcRightToLeft ddbcTopToBottom ddbcBottomToTop Description Sets the barcode's direction left to right horizontally. Sets the barcode's direction right to left horizontally. Sets the barcode's direction down the page vertically. Sets the barcode's direction up the page vertically

BarCodeStyle
Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 Mnemonic ddbcNone ddbcAnsi39 ddbcAnsi39X ddbcCode_2_of_5 ddbcCode25intlv ddbcCode25mat ddbcCode39 ddbcCode39x ddbcCode_128_A ddbcCode_128_B ddbcCode_128_C ddbcCode_128auto ddbcCode93 ddbcCode93x ddbcMSI ddbcPostNet ddbcCodabar ddbcEAN_8 ddbcEAN_13 Description None ANSI 3 of 9 (Code 39) uses upper case, numbers, - , * $ / + % ANSI Extended 3 of 9 (Extended Code 39) uses the complete ASCII character set 2 of 5 uses only numbers Interleaved 2 of 5 uses only numbers 25 Matrix Code 39 uses numbers, % * $ /. , - +, and upper case. Extended Code 39 uses the complete ASCII character set 128 A uses control characters, numbers, punctuation, and upper case 128 B uses punctuation, numbers, upper case, and lower case 128 C uses only numbers 128 Auto uses complete ASCII character set. Automatically selects between Code 128 A, B, and C to give the smallest barcode. Code 93 uses uppercase, % $ * / , + -, and numbers Extended Code 93 uses the complete ASCII character set MSI Code uses only number PostNet uses only numbers with a check digit Codabar uses A B C D + - : , / and numbers EAN-8 uses only numbers (7 numbers and a check digit) EAN-13 uses only numbers (12 numbers and a check digit)

ActiveReports 2.0 Standard User's Guide | 150

19 20

ddbcUPC_A ddbcUPC_E0

UPC-A uses only numbers (11 numbers and a check digit) UPC-E0 uses only Numbers. Used for zero-compression UPC symbols. For the Caption property you may enter either a six-digit UPC-E code or a complete 11-digit (includes code type, which must be 0 (zero)) UPC-A code. If an 11-digit code is entered, the Barcode control will convert it to a six-digit UPC-E code, if possible. If it is not possible to convert from the 11-digit code to the six-digit code, nothing is displayed UPC-E1 uses only numbers. Used typically for shelf labeling in the Retail environment. The length of the input string for U.P.C. E1 is 6 numeric characters. Royal Mail RM4SCC uses only letters and numbers (with a check digit) This is the barcode used by the Royal Mail in the United Kingdom UCC/EAN 128 uses the complete ASCII character Set. A Special version of Code 128 used in HIBC applications.

21 22 23

ddbcUPC_E1 ddbcRM4SCC ddbcUCCEAN128

BorderLineStyle
Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 Mnemonic ddBLNone ddBLSolid ddBLDash ddBLDot ddBLDashDot ddBLDashDotDot ddBLDouble ddBLThickSolid ddBLThickDash ddBLThickDot ddBLThickDashDot ddBLThickDashDotDot ddBLThickDouble ddBLExtraThickSolid Description Invisible, no border.

ColumnDirections
Value 0 1 Mnemonic ddCDDownAcross ddCDAcrossDown Description Print each section down each column followed by the next column to its right. Print sections right across the first row followed by the second row and so on.

DAOCursorType
Value 0 1 2 Mnemonic ddDAODefaultCursor ddDAOODBCCursor ddDAOServerSideCursor Description Let the ODBC driver select the cursor type. Use the ODBC driver client-side cursor. Let the server manage the cursor

Note: For additional information, refer to your Visual Basic help and documentation.

DAODefaultType
Value 1 Mnemonic ddDAOUseODBC Description Use ODBCDirect to bypass the JET engine and access RDO directly.

ActiveReports 2.0 Standard User's Guide | 151

ddDAOUseJet

Use the Microsoft JET to access your data source.

Note: For additional information, refer to your Visual Basic help and documentation.

DAORecordsetType
Value 0 1 2 Mnemonic ddDAOTable ddDAODynaset ddDAOSnapshot Description Table type recordset object Dynaset type recordset object Snapshot type recordset object

Note: For additional information, refer to your Visual Basic help and documentation.

FindConstants
Value 2 4 8 16 Mnemonic rtfWholeWord rtfMatchCase rtfDown rtfUp Description Find whole word Case sensitive search Search forward in the text stream Search backward in the text stream.

GrpKeepTogether
Value 0 1 2 Mnemonic ddGrpNone ddGrpFirstDetail ddGrpAll Description A page can be broken immediately after a group header. The group header will print with the first detail section on the same page or column. The group header, detail and group footer will print together on the same page.

Job Status
Value 0 1 2 3 Mnemonic ddJSIdle ddJSPrinting ddJSCompleted ddJSAborted Description Indicates that the print job is idle. Indicates that the job is printing. Indicates that the job has completed printing. Indicates that the current print job has been aborted.

LayoutAction
Value 1 2 4 Mnemonic ddLAPrintSection ddLAMoveLayout ddLANextRecord Description Specifies whether a section should be printed Specifies whether ActiveReports should move to the next printing location on the page Specifies whether a section should advance to the next record

LoadSaveConstants
Value 0 1 Mnemonic rtfRTF rtfText Description Save text stream to RTF file. Save text stream to an ASCII text file.

LineStyle
Value 0 1 2 Mnemonic ddLSTransparent ddLSSolid ddLSDash Description No line.

ActiveReports 2.0 Standard User's Guide | 152

3 4 5

ddLSDot ddLSDashDot ddLDDashDotDot

NewPageConstants
Value 0 1 2 3 Mnemonic ddNPNone ddNPBefore ddNPAfter ddNPBeforeAfter Description No page-break before the section. Start printing the section on a new page. Start a new page after printing the section. Start printing the section on a new page and start a new page after printing it.

PictureAlignment
Value 0 1 2 3 4 Mnemonic ddPATopLeft ddPATopRight ddPACenter ddPABottomLeft ddPABottomRight Description Align the picture to the top left corner of the image control area. Align the picture to the top right corner of the image control area. Align the picture in the center of the image control area. Align the picture to the bottom left corner of the image control area. Align the picture to the bottom right corner of the image control area.

PrtCollate
Value -1 0 1 Mnemonic COLLATE_PRINTERDEFAULT COLLATE_FALSE COLLATE_TRUE Description The report will use the setting selected on the default printer Do not collate multiple copies together. Collate multiple copies together. All pages of each copy are printed as a group.

PrtDuplex
Value -1 1 2 3 Mnemonic ddDXPrinterDefault ddDXSimplex ddDXHorizontal ddDXVertical Description The report will use the default setting on the selected printer No duplex printing. Print to both sides of the paper horizontally. Print to both sides of the paper vertically.

PrtOrientation
Value -1 1 2 Mnemonic ddODefault ddOPortrait ddOLandscape Description Uses printer's default orientation setting Print along the width of the paper. Print along the length of the paper.

PrtQuality
Value -1 -2 -3 -4 Mnemonic ddPQDraft ddPQLow ddPQMedium ddPQHigh Description Draft, very low resolution. Low resolution. Medium resolution. High resolution.

ReportStatus

ActiveReports 2.0 Standard User's Guide | 153

Value 0 1 2 3

Mnemonic ddStatIdle ddStatRunning ddStatCompleted ddStatCancelled

Description Indicates the report is idle. Indicates the report is running. Indicates the report is completed Indicates the report was cancelled.

RDOCursorDriver
Value 0 1 2 3 4 Mnemonic ddRDOUseIfNeeded ddRDOUseODBC ddRDOUseServer ddRDOUseClientBatch ddRDOUseNone Description The ODBC Driver will choose the appropriate driver to use. Use the ODBC Driver cursor library. Use server side cursors. Use optimistic client-side cursor Recordset is not returned as a cursor.

Note: For additional information, refer to your Visual Basic help and documentation.

RDOLockType
Value 1 2 3 4 5 Mnemonic ddRDOConcurReadOnly ddRDOConcurLock ddRDOConcurRowVer ddRDOConcurValues ddRDOConcurBatch Description The recordset is read-only (not updateable) Pessimistic concurrency Optimistic concurrency (based on row id) Optimistic concurrency (based on row values) Optimistic concurrency using batch mode. A status is returned for each successful update.

Note: For additional information, refer to your Visual Basic help and documentation.

RDOPrompt
Value 0 Mnemonic ddRDODriverPrompt Description The driver manager displays the ODBC Data Sources dialog box. The connection string used to establish the connection is constructed from the data source name (DSN) selected and completed by the user via the dialog boxes. Or, if no DSN is chosen and the DataSourceName property is empty, the default DSN is used. The driver manager uses the connection string provided in connect. If sufficient information is not provided, the OpenConnection method returns a trappable error. If the connection string provided includes the DSN keyword, the driver manager uses the string as provided in connect; otherwise it behaves as it does when ddRDODriverPrompt is specified. Behaves like ddRDODriverComplete except the driver disables the controls for any information not required to complete the connection.

ddRDODriverNoPrompt

ddRDODriverComplete

ddRDODriverCompleteRequired

Note: For additional information, refer to your Visual Basic help and documentation.

RDOResultsetType
Value 1 3 Mnemonic ddRDOOpenKeySet ddRDOOpenStatic Description Creates a keyset resultset Creates a static resultset

Note: For additional information, refer to your Visual Basic help and documentation.

RepeatStyle
Value Mnemonic Description

ActiveReports 2.0 Standard User's Guide | 154

0 1 2 3 4

ddRepeatNone ddRepeatOnPage ddRepeatOnColumn ddRepeatAll ddRepeatOnPageIncludeNoDetail

Do not reprint the group header. Print the group header at the top of each page within the group's detail sections. Print the group header at the top of each column within the group's detail sections. Print the group header at the top of each column and page within the group's detail sections. Print the group header at the top of each page within the group's detail section even if there is no data in the section.

SaveOptionTypes
Value 1 2 Mnemonic ddSOFile ddSOByteArray Description Save report layout to a file. Save report layout to a byte array.

SectionType
Value 0 1 2 3 4 5 6 Mnemonic ddSTReportHeader ddSTReportFooter ddSTPageHeader ddSTPageFooter ddSTGroupHeader ddSTGroupFooter ddSTDetail Description A section that prints once per report before any other report section is printed. A section that prints once per report, after all detail and group sections are printed. A section that prints once at the top of each page in the report. A section that prints once at the bottom of each page in the report. A section that prints once before detail sections whenever the group value or the group field value changes. A section that prints once after detail sections whenever the group value or the group field value changes. A section that prints once for each record or detail line in the report.

ShapeType
Value 0 1 2 Mnemonic ddSHRectangle ddSHEllipse ddSHRoundRectangle Description Rectangular shape. Elliptical or circular shape. Rectangular shape with rounded corners.

SizeMode
Value 0 1 2 Mnemonic ddSMClip ddSMStretch ddSMZoom Description Displays the picture at its actual size. The picture is clipped (cut off) if it is larger than the controls defined area. Sizes the picture to fit the area of the control. Scales the image to either the height or width of the control to fit it within the specified area without distorting it.

SplitType
Value 0 1 2 3 Mnemonic ddTopSplit ddBottomSplit ddLeftSplit ddRightSplit Description Places the splitter on top Places the splitter on the bottom Places the splitter on the left Places the splitter on the right

SummaryFunctions

ActiveReports 2.0 Standard User's Guide | 155

Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Mnemonic ddSFSum ddSFAvg ddSFCount ddSFMin ddSFMax ddSFVar ddSFVarP ddSFStdDev ddSFStdDevP ddSFDSum ddSFDAvg ddSFDCount ddSFDVar ddSFDVarP ddSFDStdDev ddSFDStdDevP

Description Calculates the total of all values within the specified summary region (group, page report). Calculates the average of all values within the specified summary region (group, page or report). Calculates the count of all values within the specified summary region (group, page or report). Calculates the minimum of all values within the specified summary region (group, page or report). Calculates the maximum of all values within the specified summary region (group, page or report). Calculates the variance of all values within the specified summary region (group, page or report). Calculates the population variance of all values within the specified summary region (group, page or report). Calculates the standard deviation of all values within the specified summary region (group, page or report). Calculates the population standard deviation of all values within the specified summary region (group, page or report). Calculates the total based on the distinct values of another field within the specified summary region (group, page or report). Calculates the average based on the distinct values of another field within the specified summary region (group, page or report). Calculates the distinct count based on the distinct values of another field within the specified summary region (group, page or report). Calculates the variance based on the distinct values of another field within the specified summary region (group, page or report). Calculates the population distinct variance based on the distinct values of another field within the specified summary region (group, page or report). Calculates the standard deviation based on the distinct values of another field within the specified summary region (group, page or report). Calculates the population standard deviation based on the distinct values of another field within the specified summary region (group, page or report).

SummaryRunningType
Value 0 1 2 Mnemonic ddSRNone ddSRGroup ddSRAll Description Do not calculate a running summary. Calculates a running summary (each value is the sum of the current value and all preceding values) within the same group level. Calculates a running summary for all values.

SummaryType
Value 0 1 2 3 4 Mnemonic ddSMNone ddSMGrandTotal ddSMPageTotal ddSMSubTotal ddSMPageCount Description No summarization. Specifies a report level summary, evaluates the summary function for all records in the report. Specifies a page level summary, evaluates the summary function for all records on each page. Specifies a group level summary, evaluates the summary function for all records in each group level. Specifies a Page Count field.

TextAlignment
Value 0 Mnemonic ddTXLeft Description Aligns the text to the left edge of the object area.

ActiveReports 2.0 Standard User's Guide | 156

1 2

ddTXRight ddTXCenter

Aligns the text to the right edge of the object area. Center the text horizontally within the object area.

VerticalTextAlignment
Value 0 1 2 Mnemonic ddTXTop ddTXMiddle ddTXBottom Description Aligns the text to the top of the object area. Centers the text vertically within the object area. Align the text to the bottom of the object area.

ViewerStatus
Value 0 1 Mnemonic ddVStatusIdle ddVStatusReadingData Description Viewer has completed loading the pages into its cache. Viewer is reading report pages into its cache.

ActiveReports' Architecture

ActiveReports' Architecture
Report Sections Report Processing Events Reports Passes Printing Process

Report Sections

Report Sections
A report section contains a group of controls that are processed and printed at the same time as a single unit. ActiveReports defines the following section types:

ActiveReports 2.0 Standard User's Guide | 157

Report Header
An ActiveReport can have a report header section that prints at the beginning of the report. It is generally used to print a report title, a summary table, a chart or any information that needs to appear only once at the beginning of the report. Note: A report header can span multiple pages by inserting a page break control within its content.

Report Footer
An ActiveReport can have a report footer section that prints at the end of the report. It is used to print a summary of the report, grand totals or any information that needs to print once at the end of the report.

Page Header
An ActiveReport can have a page header section that prints once at the top of each page in the report. It is the first section that prints on the page except when the page contains the report header section. The page section is used to print column headers, page number, page title or any information that needs to print once at the beginning of each page.

Page Footer
An ActiveReport can have a page footer section that prints once at the bottom of each page in the report. It is used to print page totals, page numbers or any other information that needs to print once at the bottom of each page.

Group Header, Group Footer


An ActiveReport can have multiple nested groups; each group has a header and a footer section. The header section prints before any detail sections in the group. The footer section prints after all the detail sections in the group. Group sections are inserted immediately before and after the detail section. The number of times that a group section would print depends on how the data is grouped. ActiveReports will start a new group (Header, Detail, and Footer) for each change in the data that binds the group.

Detail

ActiveReports 2.0 Standard User's Guide | 158

The detail section is the body of the report that prints once for each record in the data source.

Report Processing

Report Processing
ActiveReports starts processing the report by initializing the data sources if any, then starts firing events for processing the report header followed by page header, groups, detail and page footer for each page in the report. Report sections are rendered into a drawing object called the Canvas. A canvas represents a single drawing surface that can be used for printing, serialization and remoting of a page. The pages are displayed immediately after they are rendered to the canvas object. ActiveReports continues the processing while caching the pages in its internal page cache. Each canvas object is stored in the Pages collection in the order it was created. The canvas can be accessed and modified through the canvas drawing methods. Canvas objects can be merged (overlaid) and used as form templates. In addition, you can create canvas objects directly (e.g. Dim mypage as Canvas) and draw on them using methods such as DrawText. The preview window of ActiveReports uses the Pages collection to view pages. Therefore, you will need to insert canvas objects you create into the Pages collection. For example, once a report is completed you can parse the table of contents and render it to a canvas object then insert the new canvas as a page at the beginning of the report. To finalize manual changes to the Pages collection call Pages.Commit so that viewers will be updated with new content. The Pages collection allows for complete control over the order and contents of each page in your report. You can modify the contents using the low-level Canvas methods or shuffle the order of the pages before printing or exporting them.

Events

Events
Three events occur for each section regardless of its type or content. The sequence of events depends on the summary objects and their section dependencies. The only guaranteed sequence is that a Format would occur before BeforePrint, which in turn occurs before AfterPrint.

Format
Fired after the data is loaded and bound to the fields, but before the section is laid out for printing. You can use this event to modify the layout of the section or any of the controls on it. This is the only event in which you can modify the height of the section.

BeforePrint
Fired before the section is rendered to the canvas object, you can use this event to modify the values of the controls before they are printed. Any changes that are made here will not effect the height of the section. We recommend that you do NOT access any fields in a data control's recordset in this event. If you need the value of a field in this event you should use a hidden control to store the value temporarily in the format event.

AfterPrint
Fired after the section is rendered to the canvas object. You can use this event to update any counters that you need to use after the report is completed.

Reports Passes

Reports Passes
The speed in processing and output generation of ActiveReports is attributed to its intelligent, multithreaded, single-pass processing. ActiveReports will process and render each page as soon as the page is ready. If ActiveReports is not able to fully render a page because some of its data elements

ActiveReports 2.0 Standard User's Guide | 159 are not known or its layout is not final, it places the page in cache until that data is available. Summary fields and KeepTogether constraints are the two reasons that a page would not be rendered completely. The summary field is not complete until all the data needed for calculation is read from the data source. When a summary field such as a grand -total is placed ahead of its completion level such as placing it in the report header, the report header section and all following sections will be delayed until all the data is read.

Printing Process

Printing Process
ActiveReports output can be printed using different methods. The simplest is to call the PrintReport method. When the PrintReport method is called, ActiveReports checks to determine if the report has been processed earlier. If not, it starts the report processing to create the Pages collection. Then, it starts a new print job and prints each page in the collection. Then, it ends the print job. You can call the Stop or Cancel methods while the report is processing or printing. Both methods will cause the print job to end. The Stop method will continue to print processed pages before closing the print job. The Cancel will immediately close the print job and clear the pages collection. In addition, you can call the Run method to process the report and create the pages collection. Next, start a print job using the Printer.StartJob method. Then, selectively print pages from the collection using the Printer.PrintPage method. Finally, close the print job using the Printer.EndJob method. If you use background printing using Run(True) you will receive PrintProgress events. The Status property is updated while the report is printing in the background. Note: You can call Printer.AbortJob while printing to abort the print job in case of a fatal error.

Common Properties

Common Properties
These properties are shared with several objects in ActiveReports.
Property BackColor BackStyle DataField Font ForeColor Data Type OLE_COLOR BackStyle String stdFont OLE_COLOR Description Sets or returns the background color of the object. Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Sets or returns the database field a control will pull its data from. Sets or returns the font settings for a control or canvas object. Sets or returns the foreground color for a control or the canvas object. Changing the foreground color will change the font color.

BackColor

BackColor (Common Properties)


Description
Sets or returns the background color or fill color for the objects. Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 160

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

BackStyle

BackStyle (Common Properties)


Description
Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the new object's transparent areas. The line in the illustration below is behind both objects. However, it shows through the transparent object but not the normal object.

Data Type
BackStyle

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

DataField

DataField (Common Properties)


Description
Sets or returns the database field a control will pull its data from. When the DataField property is set to a field contained within the DataSource, ActiveReports binds the field's data from each record to the control. The recordset data is first saved into the DataValue property. It then passes through any OutputFormats and is set as the control's text. When using XML the DataField must be set to a valid XPath string. Note: The base path set by the RecordSetPattern is used as the starting node, so if a control needs

ActiveReports 2.0 Standard User's Guide | 161 to use a higher level node, use "../" to move back a node. The DataField property can also be used to perform calculations using scripting expression by stating the property's with an "=". This allows fields to be set up to display calculated results. For example, a field control or a group section's datafield can be set to an expression such as "=UnitPrice * Qty" or "=Trim(CompanyName)" where UnitPrice, Qty and CompanyName are members of the RptFields collection.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub CreateReport() Dim ar As rptTemplate ' rptTemplate is a predefined report ' Template already has a data control named dcRptData ' in the Detail Section Set ar = New rptTemplate With ar.Sections("Detail").Controls ' Add a field to report Set ctl = .Add("DDActiveReports2.Field") ' Set the new field's properties ctl.Name = "CompanyName" ctl.Top = 0 ctl.Left = 0 ctl.Width = 1500 ctl.Height = 285 ' Assign as DataSource and DataField to the field ctl.DataSource = "dcRptdata" ctl.DataField = "CompanyName" ' .. Set up the rest of the fields End With ' Preview the report ar.Show End Sub

Font

Font (Common Properties)


Description
Sets or returns the font settings for a control or canvas object. The font property allows access to font name, size, styles, and effects. By using the Canvas object's font properties and draw methods, text can be written directly to the canvas.

Data Type
stdFont

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline

ActiveReports 2.0 Standard User's Guide | 162


If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor

ForeColor (Common Properties)


Description
Sets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageHeader_Format() ' Paint a Red Confidential in the top-left corner ' of each page and change the totals to a red font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial" Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

Common Methods

Common Methods
Method ZOrder Description Determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Sub ZOrder(Position As Integer)

ZOrder

ZOrder (Common Methods)


Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. ZOrder should not be set after the ReportStart event has fired.

Return Type
None

ActiveReports 2.0 Standard User's Guide | 163

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Position Type Integer Description Sets the position, front or back, for the control.

Settings
Value 0 1 Description Setting the ZOrder to 0 brings the control to the front. Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0 txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _ + txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle End Sub

ActiveReport

ActiveReport
ActiveReport Properties ActiveReport Methods ActiveReport Events

ActiveReport Properties

ActiveReport Properties
Property AllowSplitter Canvas Data Type Boolean Canvas Description Sets or returns whether or not the print preview can be split into two windows. The canvas property provides complete access to each page's drawing

ActiveReports 2.0 Standard User's Guide | 164

surface. The canvas property can be used either before (shows in the background) or after (shows in the foreground) the report's output is rendered to draw text, lines, shapes or images directly onto the page. DocumentName Fields String RptFields Sets or returns the document name for a report. The document name appears in the print spooler and can be used to easily identify the report. Fields is a collection of RptField objects used to bind controls, bind summary fields and group sections to a data source when working with bound or unbound reporting. Gives control over the typical steps ActiveReports follows when laying out a section. Using a combination of layout actions when the report is run, previewed, printed or saved can change how a report is displayed. Sets or returns the maximum number of pages ActiveReports will process. Once the number of maximum pages is reached, ActiveReports will stop processing the report. Sets or returns the border object definitions for the border surrounding the page's printable area. This property can be used to draw a border around each page. Returns the page number the report is currently on. Returns a reference to the pages collection, which contains the canvas objects for all printed pages. Returns a reference to the query parameters collection. Returns a reference to the subreport's parent report object. This allows the subreport to retrieve information from its parent. Returns a reference to the printer object. Sets or returns the report's printable width in twips (1440 twips = 1 inch). Sets or returns whether or not the report's top and side rulers are shown during run-time. Sets or returns a collection of all section objects in a report. The sections collection gives access to removing or adding sections, as well as access to the individual sections within the report. Sets or returns an ActiveScript string to implement at runtime. The scripts can be used to make modifications to the report outside the code written in the report's events. Sets or returns whether or not the report will use an ActiveScript debugger to debug the script code. Sets or returns the scripting language ActiveReports will use to write and interpret the script properties. Sets or returns whether or not alerts and error messages will be shown at runtime. Sets or returns whether or not the query parameters dialog box will appear when the report is run. Returns if the report is running, idle, completed or cancelled. Returns a reference to the report's table of contents object. The TOC object gives access to adding and removing TOC entries as well as methods for navigating through the TOC. Sets or returns whether or not the table of contents tree view is enabled when the report is shown. Sets or returns whether or not the table of contents tree view is displayed in the viewer when the report is shown. Sets or returns the table of contents tree width in twips (1440 twips = 1 inch). Sets or returns whether or not the toolbar is displayed in the preview window. Sets or returns users specified information. Returns the products version and build number. Adds a specified image to the report's background. The watermark image can be positioned, sized, aligned and placed on specified pages by using

LayoutAction

Integer

MaxPages

Long

PageBorder

Border

PageNumber Pages Parameters ParentReport Printer PrintWidth RulerVisible Sections

Long Pages Collection ARParameters Object Printer Single Boolean Sections

Script

String

ScriptDebuggerEnabled ScriptLanguage ShowMessages ShowParameterUI Status TOC

Boolean String Boolean Boolean ReportStatus TOC

TOCEnabled TOCVisible TOCWidth ToolbarVisible UserData Version WaterMark

Boolean Boolean Single Boolean Variant String stdPicture

ActiveReports 2.0 Standard User's Guide | 165

the other watermark properties. WaterMarkAlignment WaterMarkPrintOnPages WaterMarkSizeMode Zoom PictureAlignment String SizeMode Integer Sets or returns the watermark's general vertical and horizontal positions when it is added to the canvas. Sets or returns a value indicating the specific pages the watermark should be added to. Sets or returns how the watermark will be sized when the image is rendered on the canvas. Sets or returns the zoom factor for the displayed page.

AllowSplitter

AllowSplitter (ActiveReport)
Description
Sets or returns whether or not the print preview can be split into two windows. Setting AllowSplitter to False will remove the SplitterBar from the viewer control.

Data Type
Boolean

Availability
Run time Read / Write

Example
Private Sub Form_Load() If mFlagEditor then rptMain.AllowSplitter = True Else rptMain.AllowSplitter=False End If End Sub

Canvas

Canvas
Description
The canvas property provides complete access to each page's drawing surface. Each page in a report is a new canvas object. The report's output is laid out and rendered on each of these canvas objects before it is shown or printed. The canvas property can be used either before (shows in the background) or after (shows in the foreground) the report's output is rendered to draw text, lines, shapes or images directly on the page.

Data Type
Canvas

Availability
Design time Run time N/A Read / Write

Example
' This example uses the DrawText method of the canvas ' to write directly to the page.

ActiveReports 2.0 Standard User's Guide | 166


Private Sub PageHeader_Format() Dim lW As Long, lH As Long With Canvas .Font.Size = 48 .MeasureText "Confidential", lW, lH .ForeColor = &HE0E0E0 .DrawText "Confidential", _ (Me.PrintWidth - lW) / 2, _ (Me.Printer.PaperHeight - lH) / 2, _ 5200, 2400 End With End Sub

DocumentName

DocumentName
Description
Sets or returns the document name for a report. The document name appears in the print spooler and can be used to easily identify the report.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
' Sets a clearly identifiable document name for easy ' identification Private Sub ActiveReport_ReportStart() Me.documentName = "TOL Annual Report Summary" End Sub

Fields

Fields
Description
Fields is a collection of report Field objects used to bind controls, bind summary fields and group sections to a data source when working with bound or unbound reporting. In bound reports, the report's fields collection is initialized to all the fields available in the data control's recordset before the DataInitialize event fires. At run time, calculated fields can be added to the report's fields collection in the DataInitialize event by using the Add method, and their values can be calculated in the FetchData event. In unbound reports, the report's fields collection must be initialized in the DataInitialize event by using the Add method to add one field into the report's fields collection for every field being used from the recordset. After the fields have been added to the report's fields collection, the FetchData event is used to populate the report's fields collection with the Recordset's field data. When using unbound reporting, set the DataField property for the control equal to the name used to add the field to the report's field collection. Note: The ActiveReports fields collection is not the same as the Recordset's fields collection.

Data Type

ActiveReports 2.0 Standard User's Guide | 167

rptField

Availability
Design time Run time N/A Read / Write

Example
Private Sub ActiveReport_DataInitialize() ' Adds fields to the report's fields collection. ' Set the DataField property for the control on your ' report designers equal to the field name added here Fields.Add "OrderID" Fields.Add "ProductID" Fields.Add "ProductName" Fields.Add "Qty" Fields.Add "Price" Fields.Add "Amount" ' iRow is the current record pointer iRow = LBound(arr) End Sub Private Sub ActiveReport_FetchData(eof As Boolean) ' After processing all the elements, exit the event ' by leaving the eof parameter to its default(True) ' value. This will promp AR to end the report If iRow > UBound(arr) Then Exit Sub Fields("OrderID").Value = arr(iRow).OrderNo Fields("ProductID").Value = arr(iRow).ProductID Fields("ProductName").Value = arr(iRow).ProductName Fields("Qty").Value = arr(iRow).Qty Fields("Price").Value = arr(iRow).Price Fields("Amount").Value = arr(iRow).Amount iRow = iRow + 1 ' We must set the eof parameter to True as ' long as there is more data to be processed eof = False End Sub

LayoutAction

LayoutAction
Description
ActiveReports typically performs the following actions for each section: 1. Prints the section. 2. Moves the layout (sets the next position for the rest of the report). 3. Moves to the next record. The LayoutAction property gives control over these steps. Using a combination of layout actions when the report is run, previewed, printed, or saved can change a report's layout. Note: The following table shows the results for setting different LayoutAction setting combinations.
Value 7 3 4 6 2 Print True True False False False Layout True True False True True NextR True False True True False Description (Default) Move to next print location, get next record, and print data. Move to the next print location, don't advance to the next record, but print the data. Skip a record without leaving a blank space on the page. Skip a record and leave a blank space on the page. Leave a blank space without skipping a record.

ActiveReports 2.0 Standard User's Guide | 168

True

False

True

Print the next record on top of the current record (UnderlayNext).

Data Type
Integer

Settings
Value 1 2 4 Mnemonic ddLAPrintSection ddLAMoveLayout ddLANextRecord Description Specifies whether a section should be printed Specifies whether ActiveReports should move to the next printing location on the page Specifies whether a section should advance to the next record

Availability
Design time Run time Read / Write N/A

Example
Dim iSkipLabels As Integer Private Sub Detail_Format() ' Skip 5 labels If iSkipLabels < 5 Then LayoutAction = ddLAMoveLayout End If End Sub

MaxPages

MaxPages
Description
Sets or returns the maximum number of pages ActiveReports will process. Once the number of maximum pages is reached, ActiveReports will stop processing the report. This property can be used to limit the number of output pages when running large reports and distributing the results over a slow connection.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Example
rptSales.MaxPages = 10

PageBorder

PageBorder
Description
Sets or returns the border object definitions for the border surrounding the page's printable area. This property can be used to draw a border around each page.

ActiveReports 2.0 Standard User's Guide | 169

Data Type
Border

Availability
Design time Run time N/A Read / Write

Example
' Set The PageBorder to Single Blue Border PageBorder.BottomColor = vbBlue PageBorder.LeftColor = vbBlue PageBorder.RightColor = vbBlue PageBorder.TopColor = vbBlue PageBorder.BottomStyle = ddBLSolid PageBorder.LeftStyle = ddBLSolid PageBorder.RightStyle = ddBLSolid PageBorder.TopStyle = ddBLSolid

PageNumber

PageNumber (ActiveReport)
Description
Returns the page number the report is currently on. This property allows the viewer host to display the report's progress while it is running in the background. This property should only be used in the BeforePrint event. Using it in any of the other events will result in erroneous data. Note: The PageNumber property should not be used to set up actual page numbering on a report. The Page N of M routines should be handled by the SummaryFunctions.

Data Type
Long

Availability
Design time Run time N/A Read

Example
Private Sub PageFooter_BeforePrint() ' Print page number in the page footer frmProgress.lblPage.Caption = me.PageNumber End Sub

Pages

Pages (ActiveReport)
Description
Returns a reference to the pages collection, which contains the canvas objects for all printed pages. The pages collection can be used to insert additional canvases into the collection or remove canvas from the collection. It can also be used to draw text or set a password on any of the canvas objects within the collection.

ActiveReports 2.0 Standard User's Guide | 170 Note: The Pages collection is zero based.

Data Type
Pages Collection

Availability
Design time Run time N/A Read-Only

Example
Private Sub OverlayForm(cvFormLayout As Canvas) Dim cv As Canvas ' Apply a preprinted canvas object tyo all pages ' in the report For Each cv In Pages cv.Overlay cvFormaLayout Next End Sub Private Sub PrintDuplex(ar As DDActiveReport) Dim I As Integer Printer.StartJob ' print all odd pages, pause, then print all even pages For I = 0 To Pages.Count 1 Step 2 Printer.PrintPage Pages(I) Next I s = "Printed first side, " & _ "turn the pages and click OK to print second side" & _ "or Cancel to abort the print job" If MsgBox(s,vbOKCancel) = vbOk Then For I = 1 To Pages.Count 1 Step 2 Printer.PrintPage Pages(I) Next I End If Printer.EndJob End Sub

Parameters

Parameters (ActiveReport)
Description
Returns a reference to the query parameters collection. The parameters collection will automatically be populated when a report is run. If parameters are specified in the record source or XLSPattern, they will be added to the collection. For example: select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995%># and OrderID><%OrderID|Order ID:|11000%>" This will add Order Date and OrderID to the parameters collection.

Data Type
ARParameters

Availability
Design time Run time N/A Read-Only

Example
Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim myprop As PropNode Dim i As Integer

ActiveReports 2.0 Standard User's Guide | 171

If Cancelled = True Then Me.Cancel Exit Sub End If Form1.EventListBox.Clear For i = 0 To Me.Parameters.Count - 1 Set myprop = New PropNode myprop.Name = Me.Parameters(i).Key myprop.Value = Me.Parameters(i).Value Form1.EventListBox.Properties.Add myprop Next End Sub

ParentReport

ParentReport
Description
Returns a reference to the subreport's parent report object. This allows the subreport to retrieve information from its parent. Note: This property is read-only and available only from the time the Subreport's DataInitialize event fires to the time the ReportEnd event fires. Trying to access ParentReport during the Initialize or Terminate events will return nothing.

Data Type
Object

Availability
Design time Run time N/A Read-Only

Example
Private Sub ActiveReport_ReportStart() Me.fldRefID = Me.ParentReport.fldRefID.Text End Sub

Printer

Printer (ActiveReport)
Description
Returns a reference to the printer object. This property can be used modify printer settings at run time. Note: The Printer object and PageSettings collection share several properties, so whichever property is used last will take precedence.

Data Type
Printer

Availability
Design time Run time N/A Read / Write

ActiveReports 2.0 Standard User's Guide | 172

Example
Private Sub ActiveReport_ReportStart() ' Set the number of copies to print and change ' orientation to landscape me.Printer.Copies = 2 me.Printer.Orientation = ddoLandscape End Sub

PrintWidth

PrintWidth
Description
Sets or returns the report's printable width in twips (1440 twips = 1 inch). The PrintWidth is the amount of physical space to which a report can print. If the size of the report is changed during runtime, the print width will also need to be adjust. This makes sure the report fills the entire printable area. Note: If the margin widths are not taken into consideration when setting the print width, the report may become wider than the paper size. When this happens, a blank page will be printed out after each page in the report and a vertical red dotted line will appear on the right hand side of the page.

Data Type
Single

Default Value
1440 twips = 1 inch

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Set the report width to 6 inches me.PrintWidth = 6 * 1440 End Sub

RulerVisible

RulerVisible (ActiveReports)
Description
Sets or returns whether or not the report's top and side rulers are shown at run time.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 173

Example
Private Sub cmdSetRuler_Click() If not bShowRuler Then me.RulerVisible = False Else me.RulerVisible = True End If End Sub

Sections

Sections (ActiveReport)
Description
Sets or returns a collection of all section objects in a report. The sections collection gives access to removing or adding sections, as well as access to the individual sections within the report. The sections collection can also be used to create dynamic reports. When referring to a section, either the section's string value name or the section's integer position can be used. For example: Sections ("Detail") or Sections(1).

Data Type
Sections collection

Availability
Design time Run time N/A Read / Write

Example
' Set the detail section height to 370 ar.Sections("Detail").Height = 300 ' Add a GroupHeader and Footer to the report rpt.Sections.Add "ghCustomer", 2, ddSTGroupHeader, 370 rpt.Sections.Add "gfCustomer", 4, ddSTGroupFooter, 370

Script

Script (ActiveReport)
Description
Sets or returns an ActiveScript string to implement at run time. The scripts can be used to make modifications to the report outside the code written in the report's events. The scripts run immediately after their matching ActiveReports' events and take precedence over the code inside the project. If reports with scripts are saved to XML, the scripts are incorporated into the XML file. Changes can be made to the XML file scripts and then loaded back into a report project to show the changes. This allows reports to be modified without requiring the project to be recompiled. The report's script property allows access to the following scripting events.
sub OnReportStart() end sub sub OnReportEnd() end sub sub OnPageStart()

ActiveReports 2.0 Standard User's Guide | 174


end sub sub OnPageEnd() end sub sub OnHyperlink() end sub sub OnDataInitialize() end sub sub OnFetchData() end sub sub OnNoData() end sub sub PrintProgress() end sub sub OnError() end sub

Note: When referencing the report in the script, use rpt instead of the report's name or "me". If the script editor is not used, the scripts must use chr(34) to insert double-quotes around strings, section names and control names. More information on scripting can be found on Microsoft's site at http://msdn.microsoft.com/scripting/

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Command1_Click() Dim vbScript As String vbScript = "sub OnFormat" & vbCrLf vbScript = vbScript & "rpt.Sections(" & Chr(34) & _ "Detail" & Chr(34) & ").Controls(" vbScript = vbScript & Chr(34) & "Label1" & Chr(34) & _ ").Caption = " & Chr(34) & "Hello world" & _ Chr(34) & vbCrLf vbScript = vbScript & "end sub" ActiveReport1.Detail.Script = vbScript ActiveReport1.Show End Sub

ScriptDebuggerEnabled

ScriptDebuggerEnabled
Description
Sets or returns whether or not the report will use an ActiveScript debugger to debug errors in the script code. Setting the ScriptDebuggerEnabled to False (default) causes the report to fire an error, which can be handled through code, when there are scripting errors. Setting the ScriptDebuggerEnabled to True will cause an ActiveScript debugger (JIT) to launch when a scripting error occurs. Enabling the script debugger allows for easier script debugging during development, and disabling the script debugger will prevent reports in production from launching the debugger if scripting errors fire.

ActiveReports 2.0 Standard User's Guide | 175

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() Me.ScriptDebuggerEnabled = True End Sub

ScriptLanguage

ScriptLanguage
Description
Sets or returns the scripting language ActiveReports will use to write and interpret the script properties. When the ScriptLanguage is set, the script editor will use the specified scripting language. The ScriptLanguage can be set to any ActiveScript language.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() If myScriptLang = "VB" then Me.ScriptLanguage = "VBScript" Else Me.ScriptLanguage = "JScript" EndIf End Sub

ShowMessages

ShowMessages
Description
Specifies whether ActiveReports should display any run-time error or alert message boxes. Setting this property to False, disables all message boxes. It should be used when the reports are running on a web server where the message box UI would cause the server to lock up. The report's Error event will continue to fire, allowing you to log the errors to the event log or to a fileThis is typically set to False on servers.

DataType
Boolean (Default = True)

Availability

ActiveReports 2.0 Standard User's Guide | 176

Design time Run time

N/A Read / Write

Example
Private Sub ActiveReport_ReportStart() Me.ShowMessages = False End Sub

ShowParameterUI

ShowParameterUI
Description
Sets or returns whether or not the query parameters dialog box will appear when the report is run. Setting the ShowParameterUI to True (default) will cause the query parameter box to appear when the report is run.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() Me.ShowParameterUI = False End Sub

Status

Status (ActiveReport)
Description
Returns if the report is running, idle, completed or cancelled.

Data Type
ReportStatus

Settings
Value 0 1 2 3 Mnemonic ddStatIdle ddStatRunning ddStatCompleted ddStatCancelled Description Indicates the report is idle Indicates the report is running Indicates the report is completed Indicates the report was cancelled

Availability
Design time Run time N/A Read-Only

ActiveReports 2.0 Standard User's Guide | 177

Example
Private Sub Timer1_Timer() Select Case ActiveReport1.Status Case Is = 1 frmMain.Caption = "Running..." Case Is = 2 frmMain.Caption = "Completed" Timer1.Enabled = False End Select End Sub

TOC

TOC (ActiveReport)
Description
Returns a reference to the report's table of contents object. The TOC object gives access to adding and removing TOC entries as well as methods for navigating through the TOC. The table of contents is used as a navigation tree or an index to the report and may contain entries from any page on the report. The TOC entries are indexed by their page numbers and is a zero based collection. When a TOC item is selected, the displayed report will jump to the top of the section where the item was added to the TOC, unless the report is in full page view. For instance, if the entry was added in a GroupFooter, selecting the item from the TOC will take you to the top of the item's GroupFooter. Note: The TOC entries are only available after the report has run.

Data Type
TOC

Availability
Design time Run time N/A Read / Write

Example
Private Sub ghCustomer_AfterPrint() TOC.Add txtCompanyName.Text End Sub Private Sub Detail_AfterPrint() TOC.Add txtCompanyName & "\" & txtOrderID.Text End Sub

TOCEnabled

TOCEnabled (ActiveReport)
Description
Sets or returns whether or not the table of contents tree view is enabled when the report is displayed. Note: The TOC properties and methods can still be used even if the TOC is disabled.

Data Type
Boolean

Availability

ActiveReports 2.0 Standard User's Guide | 178

Design time Run time

Read / Write Read / Write

Example
' Disable the table of contents tree rpt.TOCEnabled = False

TOCVisible

TOCVisible (ActiveReport)
Description
Sets or returns whether or not the table of contents tree view is displayed in the viewer when the report is displayed.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub btnViewReport_Click() Load rptInvoice rptInvoice.TOCVisible = True rptInvoice.Show End Sub

TOCWidth

TOCWidth (ActiveReport)
Description
Sets or returns the table of contents tree width in twips.

Data Type
Single

Availability
Design time Run time N/A Read / Write

Example
rpt.TOCWidth = 2880

ToolbarVisible

ToolbarVisible (ActiveReport)
Description
Sets or returns whether or not the toolbar is displayed in the preview window.

ActiveReports 2.0 Standard User's Guide | 179

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
' Turn the toolbar off Load rptInvoice rptInvoice.ToolbarVisible = False rptInvoice.Show

UserData

UserData
Description
Sets or returns user-specified information. The UserData is similar to Visual Basic's Tag property, but will be exported and saved into the .RPX file. The UserData property can be used to save and load any custom information needed in the report designer.

Data Type
Variant

Availability
Design time Run time Read / Write Read / Write

Example
ActRpt1.UserData = "Annual Report Build 106"

Version

Version (ActiveReport)
Description
Returns the product's version number.

Data Type
String

Availability
Design time Run time Read Read

Example
Private Sub Detail_Format() lblVersion = "Ran on Version: " & Me.Version End Sub

ActiveReports 2.0 Standard User's Guide | 180

WaterMark

WaterMark
Description
Adds a specified image to the report's background. The watermark image can be positioned, sized, aligned and placed on specified pages by using the other watermark properties. Note: The watermark properties must be used in the ReportStart sub. The watermark will be clipped and centered on the page unless the WaterMarkSizeMode and WaterMarkAlignment are specified.

Data Type
stdPicture

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() Me.WatermarkAlignment = ddPATopRight Me.WatermarkPrintOnPages = "1,3,5,7,9" Me.WatermarkSizeMode = ddSMClip Me.Watermark = LoadPicture(App.Path & _ "\WaterMark.jpg") End Sub

WaterMarkAlignment

WaterMarkAlignment
Description
Sets or returns the watermark's general vertical and horizontal positions when it is added to the canvas. Note: The watermark properties should be used in the ReportStart sub. If no WaterMarkAlignment is specified the image will be centered on the page.

Data Type
PictureAlignment

Settings
Value 0 1 2 3 4 Mnemonic ddPATopLeft ddPATopRight ddPACenter (Default) ddPABottomLeft ddPABottomRight Description Aligns the image to the top and left. Aligns the image to the top and right. Aligns the image to the center. Aligns the image to the bottom and left. Aligns the image to the bottom and right.

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 181

Example
Private Sub ActiveReport_ReportStart() Me.WatermarkAlignment = ddPATopRight Me.WatermarkPrintOnPages = "1,3,5,7,9" Me.WatermarkSizeMode = ddSMClip Me.Watermark = LoadPicture(App.Path & _ "\WaterMark.jpg") End Sub

WaterMarkPrintOnPages

WaterMarkPrintOnPages
Description
Sets or returns a value indicating the specific pages to which the watermark should be added. The sytanx can include a single page, page range or a combination of both. For example: 1, 5-8, 9, 10-12. Note: The watermark properties should be used in the ReportStart sub.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() Me.WatermarkAlignment = ddPATopRight Me.WatermarkPrintOnPages = "1,3,5-7,9" Me.WatermarkSizeMode = ddSMClip Me.Watermark = LoadPicture(App.Path & _ "\WaterMark.jpg") End Sub

WaterMarkSizeMode

WaterMarkSizeMode
Description
Sets or returns how the watermark will be sized when the image is rendered on the canvas. The image can be stretch to fill the page, zoomed in on to extended the image to the closest edges, or clipped to keep the image's default size. Note: The watermark properties should be used in the ReportStart sub. If no WaterMarkSizeMode is specified, the SizeMode will be ddSMClip.

Data Type
SizeMode

Settings
Value 0 1 Mnemonic ddSMClip (Default) ddSMStretch Description Clips the image. Stretches the image to fill the print area.

ActiveReports 2.0 Standard User's Guide | 182

ddSMZoom

Zooms in on the image.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() Me.WatermarkAlignment = ddPATopRight Me.WatermarkPrintOnPages = "1,3,5,7,9" Me.WatermarkSizeMode = ddSMClip Me.Watermark = LoadPicture(App.Path & _ "\WaterMark.jpg") End Sub

Zoom

Zoom (ActiveReport)
Description
Sets or returns the zoom factor for the displayed page. The valid zoom range is 10-800. The zoom can also be set to negative one (-1) to fit the PageWidth in the viewer and negative two (-2) to fit the whole page in the viewer.

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

Example
'set the zoom to 75% and preview the report rpt.Zoom = 75 rpt.Show

ActiveReport Methods

ActiveReport Methods
Method About Description Displays information about the product and the build number. Sub About() AddCode Adds specialized code to the script file so special functions can be called from inside the script. Sub AddCode(script As String) AddControlLicense Adds a license key to the report so licensed controls can be added to sections at run time using Controls.Add method. Sub AddControlLicense(progID As String,licenseKey As String) AddNamedItem Adds a named item to the report. Sub AddNamedItem(Name As String, Value As Object)

ActiveReports 2.0 Standard User's Guide | 183

Cancel

Cancels the report's processing or ends an automatic print job. You should unload the report if you want the report window to be closed after being cancelled. Sub Cancel()

Export

Exports the processed pages collection to the specified export object. Sub Export(Export As Object)

LoadLayout

Loads a report layout from an RPX (XML) file or array. Sub LoadLayout(Data)

Localize

Localizes the strings used in the preview window for PageWidth, WholePage and the table of contents caption. Sub Localize(index As Integer, str As String)

PageSetup

Displays the system's standard page setup dialog, giving access to the page size, margins, orientation, source and printer settings. Sub PageSetup(hParentWnd As Long, Flags As Long)

PrintReport

Automatically processes and sends a report to the printer. Sub PrintReport(bDisplayDialog As Boolean)

ResetScripts

Clears the script of the items added by the AddNamedItem method or code added by the AddCode method.
Sub ResetScripts() Resets the database connection properties and re-starts the report. Sub Restart()

Restart

Run

Executes the report and creates the pages collection but does not preview the report or output it to the printer. Sub Run()

SaveLayout

Saves a report layout in the format specified by SerializeOptions. Function SaveLayout(FileName As String, SerializeOptions As SaveOptionTypes)

Stop

Stops the report printing at the current point in processing. Sub Stop()

About

About
Description
Displays the product's information dialog box.

Return Type
None

Syntax
Sub About()

Parameters
None

Example
Private Sub ActiveReport_ReportStart() Me.About End Sub

AddCode

ActiveReports 2.0 Standard User's Guide | 184

AddCode
Description
Adds additional code to the script file so special functions can be called from inside the script. Using AddCode allows fully functionalfunctions to be added to a report's script file at run time. By using AddCode, functions with sensitive information can be added at run time and not be visible in the script. Note: The script string should be in an ActiveScripting language.

Return Type
None

Syntax
Sub AddCode(script As String)

Parameters
Name Script Type String Description An ActiveScript string expression containing the full code to be added.

Example
Private Sub AddSpecialScripts() Dim sScript As String sScript = "Sub SetCnnString " & vbCrLf sScript = sScript & "rpt.sections(" & """ & "Detail" & _ """ & ").controls(" & """ & "DataControl1" & """ & _ ").ConnectionString=" sScript = sScript & "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program _ Files\Microsoft Visual Studio\VB98\NWind.mdb" & vbCrLf sScript = sScript & "End Sub" ActiveReport1.AddCode sScript End Sub

In the Script
Sub OnDataInitialize SetCnnString End Sub

AddControlLicense

AddControlLicense
Description
Adds a license key to the report so licensed controls can be added to sections at run time by using the Controls.Add method.

Return Type
None

Syntax
Sub AddControlLicense(progID As String, licenseKey As String)

Parameters
Name ProgID Type String Description String value indicating the full program ID for the added control

ActiveReports 2.0 Standard User's Guide | 185

LicenseKey

String

String value indicating the full LicenseKey for the added control

Example
Dim rpt As ActiveReport Private Sub genRPT() Dim ctl as Control Set ctl = addLicensedControl "<Program ID>", "<License Key>" End Sub Private Function addLicensedControl(sProgID As String, sLicenseKey As String, sSection As String) Dim ctl as Control rpt.AddControlLicense sProgID, sLicenseKey Set ctl = rpt.Sections(sSection).Controls.Add(sProgID) Set addLicensedControl = ctl End Function

AddNamedItem

AddNamedItem
Description
Adds an object to the script's global namespace. This method allows scripts to become aware of custom classes contained within a project. Once an item has been added, the script can use the Name string to reference the object and the functions contained within the class. In order to use this method, the special properties and functions will need to be contained inside of a class because the added item must be an object.

Return Type
None

Syntax
Sub AddNamedItem(Name As String,Value As Object)

Parameters
Name Name Value Type String Object Description The name of the item being added The value of the item being added

Example
RptMain.addNamedItem "GetCos", new clsMath

In the Script Code


Sub OnReportStart myCos = GetCos.ReturnCos End Sub

Cancel

Cancel
Description
Cancels the report's processing or ends an automatic print job. You should unload the report if you want the report window to be closed after being cancelled. Note: Use this method to cancel a job that was started using the Show or Print methods.

ActiveReports 2.0 Standard User's Guide | 186

Return Type
None

Syntax
Sub Cancel()

Parameters
None

Example
' on a report progress form, place a cancel command Private Sub btnCancel() ar.Cancel Unload ar End Sub Private Sub ProcessReport() Dim ar As rptInvoices Set ar = New rptInvoices ar.PrintReport False ' show the progress window frmProgress.Show End Sub

Export

Export
Description
Exports the report pages collection using the specified export filter object. See the separately included export filters documentation in your installation directory.

Return Type
None

Syntax
Sub Export(Export As Object)

Parameters
Name Export Type Object Description A valid reference to an export filter object

Example
Private Sub ExportToPDF() ' You need to add the PDF Export Filter to your project ' references Dim oPDF As ARExportPDF Set oPDF = New ARExportPDF oPDF.FileName = App.Path & "\Invoice.PDF" rptInvoice.Export oPDF End Sub

LoadLayout

LoadLayout

ActiveReports 2.0 Standard User's Guide | 187

Description
Loads a report layout from either an array or a report saved as an XML file. Tip: This method can be used to load individualized reports on a client machine and also allows reports to be updated inside a report DLL without having to recompile.

Return Type
None

Syntax
Sub LoadLayout(Data)

Parameters
Name Data Type Variant Description Value indicating either a path and file name or a byte array.

Example
Private Sub ActiveReport_ReportStart() Me.LoadLayout (App.Path & "\Mods\Account.RPX") End Sub

Localize

Localize (ActiveReport)
Description
Localizes the strings used in the preview window for PageWidth, WholePage and the table of contents caption. Note: To localize the toolbar captions you can use the Tool.Caption property of each tool in the toolbar object.

Return Type
None

Syntax
Sub Localize(stringid text As String)

Parameters
Name stringid text Type Integer String Description Any of the valid index values. New string to replace the caption at the specified index

Settings
Value 0 1 2 Mnemonic ddLViewerTOCHeader ddLTPageWidth ddLTWholePage Description Changes the Table Of Contents header caption. Changes the "Page Width" caption in the zoom dropdown ComboBox. Changes the "Whole Page" caption in the zoom dropdown ComboBox.

Example
Private Sub ActiveReport_ReportStart() ActiveReport1.Localize 0, "TOC" ActiveReport1.Localize 1, "Page Width"

ActiveReports 2.0 Standard User's Guide | 188


ActiveReport1.Localize 2, "Whole Page" End Sub

PageSetup

PageSetup
Description
Displays the system's standard page setup dialog, giving access to the page size, margins, orientation, source and printer settings. Note: In order to reflect any changes, the report must be run after changes are made to the page setup.

Return Type
Boolean

Syntax
Function PageSetup(hWndParent As Long, Flags As Integer) As Boolean

Parameters
Name hWndParent Flags Type Long Integer Description Optional - Parent window handle. The dialog will be centered within the window. Optional Dialogs flags as described in Settings. You can combine different flags using the Or operator.

Settings
Value &H10 &H20 &H80 &H100 &H200 &H200000 Description Disables the margin controls, preventing the user from setting the margins Disables the Printer button, preventing the user from invoking a dialog box that contains additional printer setup Prevents the system from displaying a warning message when there is no default printer. Disables the orientation controls, preventing the user from setting the page orientation Disables the paper controls, preventing the user from setting page parameters such as the paper size and source Hides and disables the Network button.

Example
Private Sub miFPageSetup() rpt.PageSetup End Sub

PrintReport

PrintReport (ActiveReport)
Description
Automatically processes and sends a report to the printer. When PrintReport is called, ActiveReports starts a new print job, runs the report and sends the completed report to the printer and then closes the print job.

ActiveReports 2.0 Standard User's Guide | 189 Note: PrintReport will automatically run the report if it has not been run already.

Return Type
None

Syntax
Sub PrintReport(bDisplayDialog As Boolean)

Parameters
Name bDisplayDialog Type Boolean Description Determines whether the operating system's printer setup dialog box should be displayed before starting the print job.

Example
Private Sub btnPrint() Load rptInvoice rptInvoice.dcRptData.RecordSource = _ "SELECT * FROM Invoices " & _ "WHERE OrderID = " & Str(lSelectedOrder) rptInvoice.PrintReport False Unload rptInvoice End Sub

ResetScripts

ResetScripts
Description
Clears the script of the items added by the AddNamedItem method or code added by the AddCode method. This does not affect the pre-saved RPX file, and only clears code added from the above methods.

Return Type
None

Syntax
Sub ClearNamedItems()

Example
RptMain.ClearNamedItems

Restart

Restart
Description
Resets the database connection and starts processing the report. When making changes to a reports source, use restart to reflect the new Recordset.

Return Type
None

Syntax
Sub Restart()

Parameters
None

ActiveReports 2.0 Standard User's Guide | 190

Example
Private Sub cmdRunReport_Click() arMain.DataControl1.Source = "Select * from authors where au_id = "& i_ID arMain.Restart arMain.Show End Sub

Run

Run
Description
Executes the report and creates the pages collection but does not preview the report or output it to the printer. Run can be used before an export command or to manipulate the output, such as reordering pages or applying a form template before printing the report.

Return Type
None

Syntax
Sub Run(RunInBackground As Boolean)

Parameters
Name RunInBackground Type Boolean Description Specifies whether the report should execute as a background process in asynchronous mode. When set to True, ActiveReports returns control to the application while it continues to run the report.

Example
Dim pdf As New PDFExport pdf.FileName = App.Path & "sales.pdf" rptSales.Run False rptSales.Export pdf

SaveLayout

SaveLayout
Description
Saves a report layout in the format specified by SerializeOptions. Saved reports can be loaded into a project during design time and run time. Tip: This method can be used to save individualized reports to a client's machine so each machine can have individualized reports. This method also allows reports to be saved and loaded back into a report DLL without having to recompile.

Return Type
None

Syntax
Function SaveLayout(FileName As String, SerializeOptions As SaveOptionTypes)

Parameters

ActiveReports 2.0 Standard User's Guide | 191

Name FileName SerializeOptions

Type String SaveOptionTypes

Description String value indicating the path and filename for saving. Indicates the format the report should be saved as.

Settings
Value 1 2 Mnemonic DdSOFile DdSOByteArray Description Save report layout to a file. Save report layout to a byte array.

Example
Private Sub ActiveReport_ReportEnd() Me.SaveLayout app.path "\Mods\Account.RPX", ddSOXMLFormat End Sub Private Sub ActiveReport_ReportEnd() Dim brpt() as byte Brpt = me.SaveLayout("",ddSOByteArray) End Sub

Stop

Stop
Description
Stop method stops processing the report. All pages that are already processed will be printed or displayed in the preview window. No additional pages will be processed.

Return Type
None

Syntax
Sub Stop()

Parameters
None

Example
Private Sub PageFooter_AfterPrint() ' We need to print only 10 Pages If CurrentPage = 10 Then ' Stop the report rptInvoice.Stop End If End Sub

ActiveReport Events

ActiveReport Events
Event DataInitialize Description Event fired before ReportStart to add custom fields to report fields collection. Sub DataInitialize()

ActiveReports 2.0 Standard User's Guide | 192

Error

Fires as a result of internal error in ActiveReports. Sub Error(Number As Integer, Description As IReturnString,SCode As Long, Source As String, HelpFile As String, HelpContext As Long, CancelDisplay As IReturnBool

FetchData

Event fires every time a new record is processed. Use to set the values of custom fields that were added in the Data Initialize event. Sub FetchData(eof As Boolean

FindProgress

Fires when a search is performed on a report. When a search reaches a report's end or beginning, the event will fire. Sub ActiveReport_FindProgress(ByVal Result As DDActiveReports2.FindResults)

Hyperlink

Fires when a hyperlink is clicked. The event can be used to redirect the hyperlink or prevent a hyperlink from activating. Sub hyperLink(Button As Integer, Link As String)

KeyDown

Fires when a key is pressed down while the viewer has focus. Sub KeyDown(KeyCode As Integer, Shift As Integer)

KeyPress

Fires when a key is pressed and released while the viewer has focus. Sub KeyPress(KeyAscii As Integer)

KeyUp

Fires when a key is released while the viewer has focus. Sub KeyUp(KeyCode As Integer, Shift As Integer)

MouseOver

Fires when the mouse moves over a report page. If the mouse moves over a control with a hyperlink, then the link will be returned. Sub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal hyperLinkAs String)

NoData

Fires when the resultset of a data control does not return any records. Sub NoData()

PageEnd

Fires after processing a page. Sub PageEnd()

PageStart

Fires before ActiveReports starts to process a page. Sub PageStart()

PrintAborted

Called in the PrintReport Method when the user cancels a print job before it finishes. Sub PrintAborted()

PrintProgress

Fires after each page is printed during a print job. Sub PrintProgress(PageNumber As Long)

PromptDialogClosed

Fires after parameter values for a query are entered or the parameters dialog is cancelled. Sub PromptDialogClosed(ByVal Cancelled As Boolean)

ReportEnd

Fires after a report has completed processing. Sub ReportEnd()

ReportStart

Fires before ActiveReports starts processing the report. Sub ReportStart()

TOCClick

Fires on a mouse click in the TOC treeview window. Sub TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long)

TOCSelChange

Fires when the TOC selection changes. Sub TOCSelChange (ByVal ItemIndex As Long)

ToolbarClick

Fires from the Preview window when a toolbar tool is clicked. Sub ToolbarClick(ByVal Tool As DDTool)

ActiveReports 2.0 Standard User's Guide | 193

DataInitialize

DataInitialize
Description
Event fired before ReportStart to add custom fields to report fields collection. Custom fields can be added to a bound report (one that uses a Data Control to connect and retrieve records) or an unbound report (one that does not depend on a data control to get its records). In a bound report, the recordset is opened and the recordset fields are added to the custom Fields collection then the DataInitialize event is fired so that new custom fields can be added.

Syntax
Sub DataInitialize()

Parameters
None

Example
Private Sub ActiveReport_DataInitialize() Fields.Add "OrderID" Fields.Add "ProductID" Fields.Add "ProductName" Fields.Add "Qty" Fields.Add "Price" Fields.Add "Amount" ' iRow is the current record pointer iRow = LBound(arr) End Sub

Error

Error (ActiveReport)
Description
Occurs only as the result of an ActiveReports error that takes place when no Visual Basic code is being executed. Note: If you do not code an event procedure for the Error event, Visual Basic will display the error message.

Syntax
Sub Error(Number As Integer, Description As IReturnString, SCode As Long, Source As String, HelpFile As String, HelpContext As Long, CancelDisplay As IReturnBool)

Parameters
Name Number Description SCode Source HelpFile HelpContext CancelDisplay Description An ActiveReports error number Brief description of the error Subsystem error code Source of the error Help file name and path Context number of the error help topic An action setting corresponding to the action you want to take

Example

ActiveReports 2.0 Standard User's Guide | 194


Private Sub ActiveReport_Error( _ ByVal Number As Integer, _ ByVal Description As DDActiveReports2.IReturnString, _ ByVal Scode As Long, ByVal Source As String, _ ByVal HelpFile As String, _ ByVal HelpContext As Long, _ ByVal CancelDisplay As DDActiveReports2.IReturnBool) If Number <> 5007 Then ' Ignore the no printer warning MsgBox "Error Number: " & Str(Number) & " " & _ Description, vbOKOnly, "Printing Error" End If CancelDisplay = True End Sub

FetchData

FetchData
Description
Event is fired every time a new record is processed. Use to set the values of custom fields that were added in the Data Initialize event.

Syntax
Sub FetchData(eof As Boolean)

Parameters
Name eof Description This parameter is passed by reference and its default Value is True. It has to be explicitly set to False for the report to continue processing more records when the report does not have any data controls. If the report is bound to a data control, the value of the parameter is ignored and instead the report continues until all records are processed.

Example
Private Sub ActiveReport_FetchData(eof As Boolean) ' If we processed all element then we exit the event ' leaving the eof paramter at its default True value ' this will promp AR to end the report If iRow > UBound(arr) Then Exit Sub Fields("OrderID") = arr(iRow).OrderNo Fields("ProductID") = arr(iRow).ProductID Fields("ProductName") = arr(iRow).ProductName Fields("Qty") = arr(iRow).Qty Fields("Price") = arr(iRow).Price Fields("Amount") = arr(iRow).Amount iRow = iRow + 1 ' We must set the eof parameter to False as ' long as there is more data to be processed eof = False End Sub

FindProgress

FindProgress (ActiveReport)
Description
This event fires when a search is performed on a report. When a search reaches a report's end or beginning, the event will fire.

Syntax
Sub ActiveReport_FindProgress(ByVal Result As DDActiveReports2.FindResults)

ActiveReports 2.0 Standard User's Guide | 195

Parameters
Name Type Type FindResults Description An Enumerated list of possible progress results.

Settings
Value 1 2 3 Mnemonic ddFRFound ddFREndofPages ddFRBeginningofPages Description The search found as instance of the string. The search is at the end of the report. The search is at the beginning of the report.

Example
Private Sub ActiveReport_FindProgress(ByVal Result As DDActiveReports2.FindResults) 'If the end of the report is reached show a message If Result = ddFEndofPages Then MsgBox "You have reached the end of the report." End If End Sub

HyperLink

hyperLink (ActiveReport)
Description
This event fires when a hyperlink is clicked. It can be used to redirect a hyperlink or prevent the link from activating.

Syntax
Sub hyperLink(ByVal Button As Integer, Link As String)

Parameters
Name Button Link Type Integer String Description Integer indicating the mouse button used to click on the hyperlink. String value indicating the hyperlink.

Example
Private Sub ActiveReport_hyperLink(ByVal Button As Integer, Link As String) ' Checks which button is used to click on the link. ' If it is not button one, then the link string is ' made empty so no link will be activated. If Button <> 1 Then Link = "" End If End Sub

KeyDown

KeyDown (ActiveReport)
Description
Occurs when the user presses a key while the viewer has focus.

Syntax

ActiveReports 2.0 Standard User's Guide | 196


Sub KeyDown(KeyCode As Integer, Shift As Integer)

Parameters
Name KeyCode Shift Type Integer Integer Description The pressed Key Code from VB object library An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2).

KeyPress

KeyPress (ActiveReport)
Description
Occurs when the user presses and releases an ANSI key.

Syntax
Sub KeyPress(KeyAscii As Integer)

Parameters
Name KeyAscii Type Integer Description The standard numeric ANSI code of the pressed key.

KeyUp

KeyUp (ActiveReport)
Description
Occurs when the user releases a key while the viewer has focus.

Syntax
Sub KeyUp(KeyCode As Integer, Shift As Integer)

Parameters
Name KeyCode Shift Type Integer Integer Description The released Key Code from VB object library An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2).

MouseOver

MouseOver (ActiveReport)
Description
This event fires when the mouse moves over a report's page. If the mouse moves over a control with a hyperlink, the link is returned. The PageX and PageY parameters are twip values and relative to the canvas displayed.

Syntax
Sub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal hyperLink As String)

Parameters
Name PageX PageY Type Long Long Description Value of the X coordinate for the mouse Value of the Y coordinate for the mouse

ActiveReports 2.0 Standard User's Guide | 197

HyperLink

String

String value for the hyperlink

Example
Private Sub ActiveReport_MouseOver(ByVal PageX As Long, _ ByVal PageY As Long, ByVal hyperLink As String) If hyperLink <> "" And Me.Caption <> "Active Link: " & _ hyperLink Then ' If the hyperlink changes and is not blank update the ' caption Me.Caption = "Active Link: " & hyperLink ElseIf hyperLink = "" And Me.Caption <> _ "Annual Report: Fall Quarter" Then ' If the user has just moved off of a link, update ' caption Me.Caption = "Annual Report: Fall Quarter" End If End Sub

NoData

NoData
Description
Occurs when the data control's recordset is empty. There is no data to be processed. Note: You can use this event to either cancel the report or print a page with message informing the user that the report did not return any records to print.

Syntax
Sub NoData()

Example
Private Sub ActiveReport_NoData() Dim sMsg As String sMsg = "Report has no data, " & _ "click Cancel to abort, " & _ "OK to print without data" If MsgBox(sMsg, vbOKCancel, "No Data") = vbCancel Then rptInvoice.Cancel End If End Sub

PageEnd

PageEnd
Description
Occurs after each page in the report is rendered. Note: You can use this event to update any variables that you need for each page when running an unbound report.

Syntax
Sub PageEnd()

Example
Private Sub ActiveReport_PageEnd() ' Update the total number of pages

ActiveReports 2.0 Standard User's Guide | 198


iTotalPages = iTotalPages + 1 End Sub

PageStart

PageStart
Description
During the report's processing, this even Occurs before a page is rendered. Note: You can use this event to initialize any variables that you need for each page when running an unbound report.

Syntax
Sub PageStart()

Example
Private Sub ActiveReport_PageStart() ' Reset the page total lPageTotal = 0 End Sub

PrintAborted

PrintAborted (ActiveReport)
Description
Called in the PrintReport Method when the user cancels a print job before it finishes.

Syntax
Sub PrintAborted()

Example
Private Sub ActiveReport_PrintAborted() bPrintFlag = False End Sub

PrintProgress

PrintProgress
Description
Fired for each page during a print job, you can use this event to update a custom print dialog if the built-in progress dialog is not used.

Syntax
Sub PrintProgress(PageNumber As Long)

Parameters
Name PageNumber Description The current page number being printed.

Example

ActiveReports 2.0 Standard User's Guide | 199


' in your progress dialog form Public bCancelled As Boolean Private Sub btnCancel_Click() bCancelled = True End Sub ' In the report PrintProgress Event Private Sub ActiveReport_PrintProgress(PageNumber As Long) frmProgress.lblCurrPage.Caption = Str(PageNumber) If bCancelled Then rpt.Cancel End Sub

PromptDialogClosed

PromptDialogClosed
Description
Fired after parameter values for a query are entered or the parameters dialog is cancelled.

Syntax
Sub PromptDialogClosed(ByVal Cancelled As Boolean)

Parameters
Name Cancelled Type Boolean Description Returns true if the parameters dialog is cancelled.

Example
Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim i As Integer If Cancelled = True Then Me.Cancel Exit Sub End If 'If date parameter is empty set the default date If Me.Parameters(0).Value = "" Then Me.Parameters(0).Value = "1/1/95" End If 'if orderID parameter is empty set the default to zero If Me.Parameters(1).Value = "" Then Me.Parameters(1).Value = "0" End If End Sub

ReportEnd

ReportEnd
Description
Occurs when report finishes processing. Note: You can use this event to close or free any objects that you were using while running a report in unbound mode, or to display an information message to the end user.

Syntax
Sub ReportEnd()

Example

ActiveReports 2.0 Standard User's Guide | 200


' When Report is completed, close all open recordsets. Private Sub ActiveReport_ReportEnd() rsInvoices.Close Set rsInvoices = Nothing End Sub

ReportStart

ReportStart
Description
Occurs before a report starts processing. Note: You can use this event to initialize any objects or variable that you might need while running a report.

Syntax
Sub ReportStart()

Example
Private Sub ActiveReport_ReportStart() ' Open the recordset for unbound report Set rs = db.OpenRecordset("SELECT * FROM Invoices") End Sub

TOCClick

TOCClick
Description
This event is fired when mouse is clicked inside the table of contents area.

Syntax
Sub TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long)

Parameters
Name Button ItemIndex Flags Type Integer Long Long Description A value specifying the button that was pressed to cause the event. Bits 0, 1, 2 (values 1,2,4) can be set to identify the mouse button left, right and middle respectively. The index of the TOC entry item that was selected. Holds information about the mouse click hit test. See settings for a description of the bit values.

Settings
Value &H1 &H2 &H4 &H8 &H10 &H20 Mnemonic ddHT_NOWHERE ddHT_ONITEMICON ddHT_ONITEMLABEL ddHT_ONITEMINDENT ddHT_ONITEMBUTTON ddHT_ONITEMRIGHT Description In the TOC client area, but below the last item. On the bitmap associated with an item. On the label (caption) associated with an item. In the indentation associated with an item. On the button associated with an item. In the area to the right of an item

TOCSelChange

ActiveReports 2.0 Standard User's Guide | 201

TOCSelChange (ActiveReport)
Description
Fired when the TOC selection changes.

Syntax
Sub TOCSelChange (ByVal ItemIndex As Long)

Parameters
Name ItemIndex Type Long Description The index of the TOC entry item that was selected.

ToolbarClick

ToolbarClick (ActiveReport)
Description
Fired when the user clicks on one of the preview window tools.

Syntax
Sub ToolbarClick(ByVal Tool As DDTool)

Parameters
Name Tool Type DDTool Description A reference to the tool object that specified the clicked tool.

Example
Private Sub ActiveReport_ToolbarClick(ByVal tool As _ DDActiveReports2.DDTool) If tool.Caption = "Printer Setup" Then rpt.Printer.SetupDialog End If End Sub

ARViewer Control

ARViewer Control
ARViewer Properties ARViewer Methods ARViewer Events

ARViewer Properties

ARViewer Properties
Property AllowSplitter BackColor Data Type Boolean OLE_COLOR Description Sets or returns whether or not the viewer can be split into two windows. Sets or returns the background color of the

ActiveReports 2.0 Standard User's Guide | 202

viewer. BorderStyle DataPath Object Pages PaperColor Printer ReportSource RulerVisible Status TOC TOCEnabled TOCVisible TOCWidth Toolbar ToolbarVisible UseSourcePrinter Zoom BorderStyle String Object Pages collection OLE_COLOR Printer Object Boolean ViewerStatus TOC Boolean Boolean Single DDToolbar Boolean Boolean Integer Sets or returns the border style. Report file (RDF) URL for asynchronous downloads. Returns an object in a collection Returns a reference to the current pages collection displayed in the viewer. Sets or returns the paper background color. Returns a reference to the viewer's printer object. Sets or returns a reference to the linked subreport. Sets or returns whether or not the viewer's top and side rulers are shown at run-time. Returns the status of loading pages into the viewer cache. Returns a reference to the table of contents object, Disables or enables the TOC tree. Determines whether the table of contents tree is visible. Sets or returns the width of the TOC tree when displayed. Returns a reference to the built-in toolbar object, Determines whether the built-in toolbar is visible. Sets/return whether the viewer or ReportSource printer is used to print the report. Sets or returns the zoom level of the current page view.

AllowSplitter

AllowSplitter (ARViewer)
Description
Sets or returns whether or not the viewer can be split into two windows. Setting AllowSplitter to False will remove the SplitterBar from the viewer control.

Data Type
Boolean

Availability
Run time Read / Write

Example
Private Sub Form_Load() If mFlagEditor then ARViewer21.AllowSplitter = True Else ARViewer21.AllowSplitter=False End If End Sub

BackColor

ActiveReports 2.0 Standard User's Guide | 203

BackColor (ARViewer)
Description
Sets or returns the background color of the viewer control.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

BorderStyle

BorderStyle
Description
Sets or returns the viewer control's border style.

Data Type
Integer

Settings
Value 0 1 Mnemonic ddBSNone ddBSFixedSingle Description No border is displayed Displays single pixel border around control

Availability
Design time Run time Read / Write Read / Write

DataPath

DataPath
Description
Sets or returns the report file (RDF) URL to download and view in an HTML page.

Data Type
String (URL)

Availability
Run time Read / Write

Example
<script LANGUAGE="VBScript"> <!-Sub window_onload() ' set the initial reportsource data path

ActiveReports 2.0 Standard User's Guide | 204


arv.DataPath="reports/catalog.rdf" End Sub Sub cboReport_OnChange() Select case cboReport.Value Case "optRpt1": arv.DataPath="reports/annualreport.rdf" Case "optRpt2": arv.DataPath="reports/catalog.rdf" Case "optRpt3": arv.DataPath="reports/CustomerLabels.rdf" Case "optRpt4": arv.DataPath="reports/CustomersPhoneBook.rdf" Case "optRpt5": arv.DataPath="reports/EmployeeProfiles.rdf" Case "optRpt6": arv.DataPath="reports/employeesales.rdf" Case "optRpt7": arv.DataPath="reports/EmployeeSalesByCountry.rdf" Case "optRpt8": arv.DataPath="reports/invoice.rdf" Case "optRpt9": arv.DataPath="reports/ProductInventoryByCategory.rdf" Case "optRpt10": arv.DataPath="reports/ProductWeeklySales.rdf" Case "optRpt11": arv.DataPath="reports/top10.rdf" End Select End Sub --> </script>

Object

Object (ARViewer)
Description
Returns an object in a collection.

Data Type
Object

Availability
Run time Read-Only

Pages

Pages (ARViewer)
Description
Returns a reference to the pages displayed in the viewer. Note: The pages collection is zero based.

Data Type
Pages Collection

Availability
Run time Read / Write

Example

ActiveReports 2.0 Standard User's Guide | 205

' Run two or more reports and display both in the viewer by inserting their pages ' into the viewer's pages collection Dim pg As Canvas Report1.Run False Report2.Run False For Each pg In Report1.Pages ARViewer1.Pages.Insert ARViewer1.Pages.Count, pg Next For Each pg In Report2.Pages ARViwer.Pages.Insert ARViewer1.Pages.Count, pg Next

PaperColor

PaperColor
Description
Sets or returns the background color of the paper in the viewer window.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub btnViewReport_Click() Load frmRptViewer ' Change the Paper Color from White to Grey frmRptViewer.arv.PaperColor = &HC0C0C0 ' Set the Table of Contents Tree to Visible frmRptViewer.arv.TOCVisible = True frmRptViewer.arv.ToolBar.Tools.Add "Printer Setup" frmRptViewer.Show End Sub

Printer

Printer (ARViewer)
Description
Returns a reference to the viewer's printer object. You can use this property to set or modify printer settings at run time.

Data Type
Printer

Availability
Run time Read / Write

Example
' Set the number of copies to print Printer.Copies = 2

ActiveReports 2.0 Standard User's Guide | 206

ReportSource

ReportSource
Description
Sets or returns a reference to the linked report object. This property is set to a new instance of the report you want the control to preview.

Data Type
Object

Availability
Run time Read / Write

Example
Private Sub cmdOpenReport_Click() ARViewer1.ReportSource = New rptCustomerInfo End Sub

RulerVisible

RulerVisible (ARViewer)
Description
Sets or returns whether or not the viewer's top and side rulers are shown at run time.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub cmdSetRuler_Click() If ARViewer1.RulerVisible Then cmdSetRuler.Caption = "&Show Ruler" ARViewer1.RulerVisible = False Else cmdSetRuler.Caption = "&Hide Ruler" ARViewer1.RulerVisible = True End If End Sub

Status

Status (ARViewer)
Description
Returns the status of the viewer when loading report pages asynchronously into its internal cache. You can use this property to verify that all report pages have been loaded into the pages collection.

ActiveReports 2.0 Standard User's Guide | 207

When the viewer is connected to a report using the ReportSource property, it creates a proxy of the reports Pages collection locally. It then starts loading the pages into that proxy. This allows you to download pages asynchronously over a slow connection.

Data Type
ViewerStatus

Availability
Design time Run time N/A Read

TOC

TOC (ARViewer)
Description
Returns a reference to the report's table of contents object. The TOC object gives access to adding and removing TOC entries as well as methods for navigating through the TOC. The table of contents is used as a navigation tree or an index to the report and may contain entries from any page on the report. The TOC entries are indexed by their page numbers and is a zero based collection. When a TOC item is selected, the displayed report will jump to the top of the section where the item was added to the TOC, unless the report is in full page view. For instance, if the entry was added in a GroupFooter, selecting the item from the TOC will take you to the top of the item's GroupFooter. Note: The TOC entries are only available after the report has run.

Data Type
TOC

Availability
Design time Run time N/A Read / Write

Example
' Command button implementations of a custom toolbar Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position = 0) btnForward.Enabled = (.Position = .Count) End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position = 0) btnForward.Enabled = (.Position = .Count) End With End Sub

TOCEnabled

TOCEnabled (ARViewer)

ActiveReports 2.0 Standard User's Guide | 208

Description
Enables or disables the table of contents tree.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
' Disable the table of contents tree arv.TOCEnabled = False

TOCVisible

TOCVisible (ARViewer)
Description
Determines whether the viewer's toolbar is displayed in the viewer window.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub btnViewReport_Click() Load frmRptViewer frmRptViewer.arv.TOCVisible = True frmRptViewer.arv.ToolBar.Tools.Add "Printer Setup" frmRptViewer.Show End Sub

TOCWidth

TOCWidth (ARViewer)
Description
Sets or returns the width of the table of contents tree in twips.

Data Type
Single

Availability
Design time N/A

ActiveReports 2.0 Standard User's Guide | 209

Run time

Read / Write

Example
arv.TOCWidth = 2880

ToolBar

Toolbar
Description
Returns a reference to the viewer's toolbar object. The toolbar object allows you modify the toolbar's icons and tools.

Data Type
Toolbar

Availability
Run time Read

Example
Private Sub btnViewReport_Click() Load frmRptViewer frmRptViewer.arv.TOCVisible = True frmRptViewer.arv.ToolBar.Tools.Add "Printer Setup" frmRptViewer.Show End Sub

ToolbarVisible

ToolbarVisible (ARViewer)
Description
Determines whether the viewer's toolbar is displayed in the viewer window.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
' Turn the toolbar off and use our own custom toolbar Load frmViewer frmViewer.arv.ToolbarVisible = False

UseSourcePrinter

UseSourcePrinter

ActiveReports 2.0 Standard User's Guide | 210

Description
Sets or returns whether the viewer's printer (False) or ReportSource printer (True) is used to print the report.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Zoom

Zoom (ARViewer)
Description
Sets or returns the zoom factor of the displayed page.

Data Type
Integer - Valid range is 10-800 or -1 for Fit PageWidth and -2 for Fit Whole Page.

Availability
Design time Run time Read / Write Read / Write

Example
' Load the viewer form and set the zoom to 75% frmViewer.Show frmViewer.arv.Zoom = 75

ARViewer Methods

ARViewer Methods
Method CopyPageToClipboard Description Copies the indicated page to the clipboard. Sub CopyPageToClipboard([Page]) Find Searches a report for a specified string. Sub Find(View As SplitViewTypes, SearchText As String, Direction As SearchDirectionTypes, MatchCase As Boolean, MatchWord As Boolean) Localize Allows modification of the caption of the string used in the preview window. Localize(index As Integer, str As String) MultiplePage Switches the viewer settings so multiple pages can be displayed at one time. Sub MultiplePage(View As SplitViewTypes, rows As Integer, cols As Integer) PrintReport Prints the viewer pages collection to the selected device. Sub PrintReport(bDisplayDialog As Boolean) Refresh Refreshes the viewer control.

ActiveReports 2.0 Standard User's Guide | 211

Sub Refresh() SinglePage Switches the viewer back to displaying a single page. Sub SinglePage(View As SplitViewTypes)

CopyPageToClipboard

CopyPageToClipboard
Description
Copies the indicated page to the clipboard. The page is an integer value indicating the page number, minus 1, you wish to copy. If no page number is indicated, the current page will be copied to the clipboard. Note: The page count begins with 0.

Return Type
None

Syntax
Sub CopyPageToClipboard([Page])

Parameters
Name Page (optional) Type Integer Description Copies the current page to the clipboard, unless a different page is specified.

Example
Private Sub cmdCopy_Click() ARV.CopyPageToClipboard 0 'Copies the first page End Sub

Find

Find (ARViewer)
Description
Searches the report for a specified string.

Return Type
None

Syntax
Sub Find(View As SplitViewTypes, SearchText As String, DirectionAs SearchDirectionTypes, MatchCase As Boolean, MatchWord As Boolean)

Parameters
Name View SearchText Direction MatchCase Type SplitViewTypes String SearchDirectionTypes Boolean Description Determines which split window (top, bottom, or both) to search. The string value being searched for. The direction, either up or down, the search will use to scan the report. Determines whether the search is case sensitive or not.

ActiveReports 2.0 Standard User's Guide | 212

MatchWord

Boolean

Determines whether the search should find only the whole word or not.

Settings
SplitViewTypes
Value 0 1 2 Mnemonic ddSVFirst ddSVSecond ddSVAll Description Only searches the top window if the viewer is split, or the single window if it is not. Only searches the bottom window if the viewer is split, or the single window if it is not. Searches both windows if the viewer is split, or the single window if it is not.

SearchDirectionTypes
Value 0 1 Mnemonic ddSDUp ddSDDown Description Searches from the current page to page 1. Searches from the current page to the end.

Example
Private Sub cmdSearch_Click() ARV.Find ddSVFirst, txtSrch.Text, ddSDDown, False, True End Sub

Localize

Localize (ARViewer)
Description
Allows you to localize the strings used in the viewer window. Note: To localize the toolbar captions, you can use the Tool.Caption property of each tool in the toolbar object.

Return Type
None

Syntax
Sub Localize(Type As LocalizeTypes, text As String)

Parameters
Name Type text Type LocalizeTypes String Description Any of the valid LocalizeType enums. New string to replace the caption at the specified index.

Settings
Value 0 1 2 Mnemonic ddLViewerTOCHeader ddLTPageWidth ddLTWholePage Description Changes the Table Of Contents header caption. Changes the "Page Width" caption in the zoom dropdown ComboBox. Changes the "Whole Page" caption in the zoom dropdown ComboBox.

Example
Private Sub Form_Load()

ActiveReports 2.0 Standard User's Guide | 213


'Change "Page Width" caption arv.Localize ddLTPageWidth, "Largura Da Pgina " 'Change TOC Header caption arv.Localize ddLTViewerTocHeader, "ndice " 'Change "Whole Page" caption arv.Localize ddLTWholePage, "Pgina Inteira " End Sub

MultiplePage

MultiplePage
Description
Switches the viewer settings so multiple pages can be displayed at one time.

Return Type
None

Syntax
Sub MultiplePage(View As SplitViewTypes, rows As Integer, cols As Integer)

Parameters
Name View rows cols Type SplitViewTypes Integer Integer Description Determines which split window (top, bottom, or both) to apply the setting to. Indicates how many rows (horizontal) of pages should be shown. Indicates how many columns (vertical) of pages should be shown.

Settings
Value 0 1 2 Mnemonic ddSVFirst ddSVSecond ddSVAll Description Applies the MultiplePage setting to the top window if the viewer is split, or to the single window if it is not. Applies the MultiplePage setting to the bottom window if the viewer is split, or to the single window if it is not. Applies the MultiplePage setting to both windows if the viewer is split, or to the single window if it is not.

PrintReport

PrintReport (ARViewer)
Description
Prints the viewer pages collection to the selected device.

Return Type
None

Syntax
Sub PrintReport(bDisplayDialog As Boolean)

Parameters
Name bDisplayDialog Type Boolean Description Specifies whether ActiveReports should display the

ActiveReports 2.0 Standard User's Guide | 214

print dialog before printing the report.

Example
' Menu Item Print Private Sub miFPrint_Click() ARViewer1.PrintReport False End Sub

Refresh

Refresh (ARViewer)
Description
Forces the viewer control to repaint itself.

Return Type
None

Syntax
Sub Refesh()

Parameters
None

Example
arv.Refresh

SinglePage

SinglePage
Description
Switches the Viewer back to displaying a single page.

Return Type
None

Syntax
Sub SinglePage(View As SplitViewTypes)

Parameters
Name View Type SplitViewTypes Description Determines which split window (top, bottom, or both) to apply the setting to.

Settings
Value 0 1 2 Mnemonic ddSVFirst ddSVSecond ddSVAll Description Applies the SinglePage setting to the top window of the viewer is split, or the single window if it is not. Applies the SinglePage setting to the bottom window of the viewer is split, or the single window if it is not. Applies the SinglePage setting to both windows if the viewer is split, or the single window if it is not.

ActiveReports 2.0 Standard User's Guide | 215

ARViewer Events

ARViewer Events
Event ControlLoaded (on-line documentation) DblClick Description Used for setting the DataPath in Microsoft Internet Explorer Sub ControlLoaded() Fired when the user double clicks the mouse in the viewer. Sub DblClick() DragDrop (on-line documentation) Fired when a drag-and-drop operation is completed. Sub DragDrop(Source As Control, x As Single, y As Single) Fired when a drag-and-drop operation is in progress. Sub DragOver(Source As Control, x As Single, y As Single, State As Integer) Occurs when an error fires. Sub Error(Number As Integer, ByVal Description As String,ByVal SCode As Long, ByVal Source As String, ByVal HelpFile As String, ByValHelpContext As Long, CancelDisplay As Boolean) FindProgress This event fires when a search is performed on a report loaded into the viewer. When a search reaches a report's end or beginning, the event will fire. Event FindProgress(ByVal Result As DDActiveReortsViewer2Ctl.FindResults) GotFocus (on-line documentation) HyperLink This event fires when an object receives focus. Sub GotFocus() This event fires when a hyperlink is clicked. The event can be used to redirect the hyperlink or prevent the link from activating. Sub Hyperlink(ByVal Button As Integer, Link As String) KeyDown Fired when a key is pressed down while the viewer has focus. Sub KeyDown(KeyCode As Integer, Shift As Integer) KeyPress Fired When a key is pressed and released while the viewer has focus. Sub KeyPress(KeyAscii As Integer) KeyUp Fired when a key is released while the viewer has focus. Sub KeyUp(KeyCode As Integer, Shift As Integer) LoadCompleted Fired when all the pages in the report source have been loaded into the viewer. Sub LoadCompleted() LostFocus (on-line documentation) MouseDown Fired when an object loses focus. Sub LostFocus() Fired when a mouse button is pressed down. Sub MouseDown(Button As Integer, Shift As Integer, X As Single,Y As Single) MouseMove Fired as the mouse moves over the viewer area. Sub MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) MouseOver This event fires when the mouse moves over a report page. If the mouse moves over a control with a hyperlink, then the link will be returned. Sub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal Hyperlink As String) MouseUp Fired when a mouse button is released.

DragOver (on-line documentation)

Error

ActiveReports 2.0 Standard User's Guide | 216

Sub MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) PageModeChanged Fired when the viewer switches between displaying a single page and multiple pages. Sub PageModeChanged(ByVal MultiplePage As Boolean) PrintAborted Called in the PrintReport Method when the user cancels a print job before it finishes. Sub PrintAborted() TOCClick Fired on a mouse click in the TOC treeview window. Sub TOCClick(ByVal Button As Integer, ByVal As Long, ByVal Flags As Long) TOCSelChange Fired when the TOC selection changes. Sub TOCSelChange (ByVal ItemIndex As Long) ToolbarClick Fired when the user clicks on a tool in the viewer toolbar. Sub ToolbarClick(ByVal Tool As DDTool) Validate (on-line documentation) ZoomChanged Fired when a control loses focus to a control that causes validation. Sub Validate(Cancel As Boolean) Fired when the viewer's zoom percentage changes. Sub ZoomChanged()

NOTE: Web environments do not create event handlers automatically, so be sure to add the parameters to the events which match the parameters defined by the controls. If this is not done, the events will never fire.

DblClk

DblClick
Description
Fired when the user double clicks the mouse (left mouse button) in the viewer area. You can use this event to retrieve information about the clicked position and display more detail about it.

Syntax
Sub DblClick()

Parameters
None

Error

Error (ARViewer)
Description
Occurs only as the result of an ActiveReports error that takes place when no Visual Basic code is being executed. Note: If you do not code an event procedure for the Error event, Visual Basic will display the error message.

Syntax
Sub Error (ByVal Number As Integer, ByVal DescriptionAs String, ByVal SCode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

Parameters

ActiveReports 2.0 Standard User's Guide | 217

Name Number Description SCode Source HelpFile HelpContext CancelDisplay

Description An ActiveReports error number. Brief description of the error. Subsystem error code Source of the error Help file name and path Context number of the error help topic An action setting corresponding to the action you want to take.

Example
Private Sub ARViewer1_Error(ByVal Number As Integer, ByVal Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean) CancelDisplay = True App.LogEvent "Error Number: " & str(Number) & " " & _ Description & " Source: " & Source End Sub

FindProgress

FindProgress (ARViewer)
Description
This event fires when a search is performed on a report loaded into the viewer. When a search reaches a report's end or beginning, the event will fire.

Syntax
Sub arv_FindProgress(ByVal Results As DactiveReportsViewer2Ctl.FindResults)

Parameters
Name Type Type FindResults Description An Enumerated list of possible progress results.

Settings
Value 1 2 3 Mnemonic ddFRFound ddFREndofPages ddFRBeginningofPages Description The search found as instance of the string. The search is at the end of the report. The search is at the beginning of the report.

Example
Private Sub arv_FindProgress(ByVal Result As DDActiveReportsViewer2Ctl.FindResults) 'If the end of the report is reached show a message If Result = ddFRNotFount Then MsgBox "No Matching Records" End If End Sub

ActiveReports 2.0 Standard User's Guide | 218

hyperLink

hyperLink (ARViewer)
Description
This event fires when a hyperlink is clicked. The event can be used to redirect the hyperlink or prevent the link from activating.

Syntax
Sub hyperLink(ByVal Button As Integer, Link As String)

Parameters
Name Button Link Type Integer String Description Integer indicating the mouse button used to click on the hyperlink. String value indicating the hyperlink.

Example
Private Sub ARViewer1_hyperLink(ByVal Button As Integer, Link As String) ' Checks which button is used to click on link. ' If it is not button one then the link string is ' made empty so no link will be activated. If Button <> 1 Then Link = "" End If End Sub

KeyDown

KeyDown (ARViewer)
Description
Occurs when the user presses a key while the viewer has focus.

Syntax
Sub KeyDown(KeyCode As Integer, Shift As Integer)

Parameters
Name KeyCode Shift Type Integer Integer Description The pressed Key Code from VB object library An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2).

KeyPress

KeyPress (ARViewer)
Description
Occurs when the user presses and releases an ANSI key.

Syntax
Sub KeyPress(KeyAscii As Integer)

ActiveReports 2.0 Standard User's Guide | 219

Parameters
Name KeyAscii Type Integer Description The standard numeric ANSI code of the pressed key.

KeyUp

KeyUp (ARViewer)
Description
Occurs when the user releases a key while the viewer has focus.

Syntax
Sub KeyUp(KeyCode As Integer, Shift As Integer)

Parameters
Name KeyCode Shift Type Integer Integer Description The released Key Code from VB object library An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2).

LoadCompleted

LoadCompleted
Description
LoadCompleted is fired when all the pages from the ReportSource are loaded into the viewer control.

Syntax
Sub LoadCompleted()

Parameters
None

Example
' Update a PageCount label and enable the TOC button ' when all pages are loaded Private Sub LoadCompleted() lblPages.Caption = Str(arv.Pages.Count) arv.TOCEnabled = True End Sub

MouseDown

MouseDown
Description
Fired when the user presses one of the mouse buttons in the viewer area.

Syntax
Sub MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Parameters

ActiveReports 2.0 Standard User's Guide | 220

Name Button

Type Integer

Description A value specifying the button that was pressed to cause the event. Bits 0, 1, 2 (values 1,2,4) can be set to identify the mouse button left, right and middle respectively. An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2) at the time of the mouse down event. The mouse coordinates (in pixels) within the viewer control area.

Shift

Integer

X,Y

Single

MouseMove

MouseMove
Description
Occurs when the user moves the mouse over the viewer control area.

Syntax
Sub MouseMove( Button As Integer, Shift As Integer, X As Single, Y As Single)

Parameters
Name Button Type Integer Description A value specifying the button that is pressed while moving the mouse. Bits 0, 1, 2 (values 1,2,4) can be set to identify the mouse button left, right and middle respectively. An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2) at the time of the mouse move event. The mouse coordinates (in pixels) within the viewer control area.

Shift

Integer

X,Y

Single

MouseOver

MouseOver (ARViewer)
Description
This event fires when the mouse moves over a report page in the viewer. If the mouse moves over a control with a hyperlink, the link will be returned. The PageX and PageY parameters are twip values relative to the canvas displayed.

Syntax
Sub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal hyperLinkAs String)

Parameters
Name PageX PageY HyperLink Type Long Long String Description Value of the X coordinate for the mouse Value of the Y coordinate for the mouse String value for the hyperlink

Example
Private Sub ActiveReport_MouseOver(ByVal PageX As Long, _ ByVal PageY As Long, ByVal hyperLink As String)

ActiveReports 2.0 Standard User's Guide | 221


If hyperLink <> "" And arv1.Caption <> "Active Link:" &_ hyperLink Then ' If the hyperlink changes and is not blank update the ' caption arv1.Caption = "Active Link: " & hyperLink ElseIf hyperLink = "" And Me.Caption <> _ "Annual Report: Fall Quarter" Then ' If the user has just moved off of a link, update ' caption arv1.Caption = "Annual Report: Fall Quarter" End If End Sub

MouseUp

MouseUp
Description
Fired when the user releases the pressed mouse button in the viewer area.

Syntax
Sub MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Parameters
Name Button Type Integer Description A value specifying the button that was released to cause the event. Bits 0, 1, 2 (values 1,2,4) can be set to identify the mouse button left, right and middle respectively. An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2) at the time of the mouse up event. The mouse coordinates (in pixels) within the viewer control area.

Shift

Integer

X,Y

Single

PageModeChanged

PageModeChanged
Description
Fired when the viewer switches between displaying a single page and multiple pages.

Syntax
Sub PageModeChanged(ByVal MultiplePage As Boolean)

Parameters
Name MultiplePage Type Boolean Description Returns true if the viewer's page mode switches to displaying multiple pages and false if the viewer only displays a single page.

PrintAborted

PrintAborted (ARViewer)
Description
Called in the PrintReport Method when the user cancels a print job before it finishes.

ActiveReports 2.0 Standard User's Guide | 222

Syntax
Sub PrintAborted()

Example
Private Sub ARViewer21_PrintAborted() bPrintFlag = False End Sub

TOCClick

TOCClick
Description
This event is fired when mouse is clicked inside the table of contents area.

Syntax
Sub TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal FlagsAs Long)

Parameters
Name Button Type Integer Description A value specifying the button that was pressed to cause the event. Bits 0, 1, 2 (values 1,2,4) can be set to identify the mouse button left, right and middle respectively. The index of the TOC entry item that was selected. Holds information about the mouse click hit test. See settings for a description of the bit values.

ItemIndex Flags

Long Long

Settings
Value &H1 &H2 &H4 &H8 &H10 &H20 Mnemonic ddHT_NOWHERE ddHT_ONITEMICON ddHT_ONITEMLABEL ddHT_ONITEMINDENT ddHT_ONITEMBUTTON ddHT_ONITEMRIGHT Description In the TOC client area, but below the last item. On the bitmap associated with an item. On the label (caption) associated with an item. In the indentation associated with an item. On the button associated with an item. In the area to the right of an item

NOTE: Web environments do not create event handlers automatically, so be sure to add the parameters to the events which match the parameters defined by the controls. If this is not done, the events will never fire.

TOCSelChange

TOCSelChange (ARViewer)
Description
Fired when the TOC selection changes.

Syntax
Sub TOCSelChange (ByVal ItemIndex As Long)

Parameters

ActiveReports 2.0 Standard User's Guide | 223

Name ItemIndex

Type Long

Description The index of the TOC entry item that was selected.

ToolbarClick

ToolbarClick (ARViewer)
Description
Fired when the user clicks on one of the viewer's toolbar tools.

Syntax
Sub ToolbarClick(ByVal Tool As DDTool)

Parameters
Name Tool Type DDTool Description A reference to the tool object that specified the clicked tool.

Example
Private Sub arv_ToolbarClick(ByVal tool As _ DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

NOTE: Web environments do not create event handlers automatically, so be sure to add the parameters to the events which match the parameters defined by the controls. If this is not done, the events will never fire.

ZoomChanged

ZoomChanged
Description
Fired when the viewer's zoom percentage changes.

Syntax
Sub ZoomChanged()

Border Properties

Border Properties
Property BottomColor BottomStyle LeftColor LeftStyle RightColor> RightStyle Data Type OLE_COLOR BorderLineStyle OLE_COLOR BorderLineStyle OLE_COLOR BorderLineStyle Description The line color of the bottom edge. The line style of the bottom edge. The line color of the left edge. The line style of the left edge. The line color of the right edge. The line style of the right edge.

ActiveReports 2.0 Standard User's Guide | 224

Shadow TopColor TopStyle

Boolean OLE_COLOR BorderLineStyle

Determines whether to draw a shadow around the control or not. The line color of the top edge. The line style of the top edge.

BottomColor, LeftColor, RightColor, TopColor

BottomColor, LeftColor, RightColor, TopColor


Description
Sets or returns the color of the line drawn at the specified edge.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write (Borders Property Sheet) Read / Write

Example
' Set The PageBorder to Single Blue Border PageBorder.BottomColor = vbBlue PageBorder.LeftColor = vbBlue PageBorder.RightColor = vbBlue PageBorder.TopColor = vbBlue PageBorder.BottomStyle = ddBLSolid PageBorder.LeftStyle = ddBLSolid PageBorder.RightStyle = ddBLSolid PageBorder.TopStyle = ddBLSolid

BottomStyle, LeftStyle, RightStyle, TopStyle

BottomStyle, LeftStyle, RightStyle, TopStyle


Description
Sets or returns the line style at the specified edge.

Data Type
BorderLineStyle

Availability
Design time Run time Read / Write (Borders Property Sheet) Read / Write

Example
' Set The PageBorder to Single Blue Border PageBorder.BottomColor = vbBlue PageBorder.LeftColor = vbBlue PageBorder.RightColor = vbBlue PageBorder.TopColor = vbBlue PageBorder.BottomStyle = ddBLSolid PageBorder.LeftStyle = ddBLSolid

ActiveReports 2.0 Standard User's Guide | 225


PageBorder.RightStyle = ddBLSolid PageBorder.TopStyle = ddBLSolid

Shadow

Shadow
Description
Determines whether to draw a shadow around the control.

Data Type
Boolean

Availability
Design time Run time Read / Write (Borders Property Sheet) Read / Write

Example
Private Sub Detail_Format() If txtSlaes.Datavalue > 10000 Then txtCompanyName.Border.Shadow = True End If End Sub

Canvas

Canvas Object
Canvas Properties Canvas Methods

Canvas Properties

Canvas Properties
Property Alignment BackColor BackStyle Font ForeColor Height Orientation PenStyle PenWidth Tag TextAngle Data Type Integer OLE_COLOR BackStyle StdFont OLE_COLOR Long PrtOrientation Integer Integer Variant Long Description Controls how the DrawText method aligns the text. Sets the background color of the following non-transparent (BackStyle = 1) output. Sets the BackStyle to either transparent or solid fill. Sets the font of the following DrawText output. Sets the foreground color of the following output, Sets or returns the vertical drawing area for the canvas. Sets the page orientation of the canvas. Sets the drawing pen style Sets the drawing pen width Sets or returns a user defined value associated with the page. Sets the angle of the text printed using the DrawText method.

ActiveReports 2.0 Standard User's Guide | 226

VerticalAlignment Width

Integer Long

Sets the vertical alignment of the text printed using the DrawText method. Sets or returns the horizontal drawing area for the canvas.

Alignment

Alignment (Canvas)
Description
Sets or returns the horizontal alignment of the text drawn using DrawText method.

Data Type
Integer

Settings
Value 0 1 2 Mnemonic ddTXLeft ddTXRight ddTXCenter Description Aligns the text to the left edge of the object area. Aligns the text to the right edge of the object area. Center the text horizontally within the object area.

Availability
Design time Run time N/A Read / Write

Example
Private Sub PageHeader_Format()< ' Draw a round rectangle with Top Secret centered With Canvas .DrawRoundRect 100, 100, 1500, 300, 10, 10 .Alignment = ddTXCenter .DrawText "Top Secret", 100, 100, 1500, 300 End With End Sub

BackColor (Canvas)

BackColor (Canvas)
Description
Sets or returns the background color or fill color for the objects. Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example

ActiveReports 2.0 Standard User's Guide | 227


' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

BackStyle (Canvas)

BackStyle (Canvas)
Description
Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the new object's transparent areas. The line in the illustration below is behind both objects. However, it shows through the transparent object but not the normal object.

Data Type
BackStyle

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

Font (Canvas)

Font (Canvas)
Description
Sets or returns the font settings for a control or canvas object. The font property allows access to font name, size, styles, and effects. By using the Canvas object's font properties and draw methods, text can be written directly to the canvas.

Data Type
stdFont

Availability
Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 228

Run time

Read / Write

Example
Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor (Canvas)

ForeColor (Canvas)
Description
Sets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageHeader_Format() ' Paint a Red Confidential in the top-left corner ' of each page and change the totals to a red font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial" Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

Height

Height (Canvas)
Description
Sets or returns the vertical drawing area for the canvas in twips.

Data Type
Long

Availability
Design time Run time N/A Read / Write

ActiveReports 2.0 Standard User's Guide | 229

Example
Private Sub ActiveReport_PageStart() 'sets the canvas to be 4in X 5in and draws red box 'on top of it. Me.Canvas.BackColor = vbRed Me.Canvas.BackStyle = 1 Me.Canvas.Width = 4 * 1440 Me.Canvas.Height = 5 * 1440 Me.Canvas.DrawRect 0, 0, Canvas.Width, Canvas.Height End Sub

Orientation

Orientation (Canvas)
Description
Sets or returns the orientation of the canvas object. This property should be used when working with, or adding, individual canvases. The canvas orientation is separate from changing the PageSettings' or printer's orientation because it only affects the specified page. By using Canvas.Orientation, a project can be set up to manipulate the individual page's orientation. After manipulating the canvas orientation, the canvas' width and height must also be specified to reflect the correct page size. Note: Setting a page's canvas orientation will not set the PageSettings' or Printer's orientation for that page.

Data Type
PrtOrientation

Availability
Run time Read / Write

Example
Private Sub CreateCoverSheet() ' Add a new page to a viewer control and set its ' orientation to Landscape regardless of what the ' other pages are set to ARViewer1.Pages.InsertNew(0) ARViewer1.Pages(0).Orientation = ddPOLandscape ' draw text on the page. End Sub

PenStyle

PenStyle
Description
Sets the pen style that is used to draw lines and shapes to the canvas.

Data Type
Integer

Settings
Value 0 Mnemonic ddLSTransparent Description No line.

ActiveReports 2.0 Standard User's Guide | 230

1 2 3 4 5

ddLSSolid ddLSDash ddLSDot ddLSDashDot ddLDDashDotDot

Availability
Design time Run time N/A Read / Write

Example
Private Sub PageHeader_Format() ' Draw a round rectangle with Top Secret centered With Canvas .PenStyle = ddLSSolid .PenWidth = 2 .DrawRoundRect 100, 100, 1500, 300, 10, 10 .Alignment = ddTXCenter .DrawText "Top Secret", 100, 100, 1500, 300 End With End Sub

PenWidth

PenWidth
Description
Sets or returns the line weight used to draw lines and shapes to the canvas object.

Data Type
Integer (line width 1lw=10 twips)

Availability
Design time Run time N/A Read / Write

Example
Private Sub PageHeader_Format() ' Draw a round rectangle with Top Secret centered With Canvas .PenStyle = ddLSSolid .PenWidth = 2 .DrawRoundRect 100, 100, 1500, 300, 10, 10 .Alignment = ddTXCenter .DrawText "Top Secret", 100, 100, 1500, 300 End With End Sub

Tag

ActiveReports 2.0 Standard User's Guide | 231

Tag (Canvas)
Description
Sets or returns a user-defined value associated with the canvas object. You can use this property to store information about the page that you might want to retrieve later from the Pages collection.

Data Type
Variant

Availability
Design time Run time N/A Read / Write

Example
Private Sub ghCustomer_AfterPrint() 'Set the tag to the customer fax number 'Use it later to change printer settings to send the fax Canvas.Tag = txtCustomerFax.DataValue End Sub

TextAngle

TextAngle
Description
Sets or returns the clock-wise angle used to rotate the text drawn to the canvas object. Note: Units are in 1/10 of a degree. For example, 900 units = 90 degrees clock-wise.

Data Type
Long

Availability
Design time Run time N/A Read / Write

Example
' Draw Confidential Message at 45 degree angle Canvas.TextAngle = 450 Canvas.Font.Name = "Arial" Canvas.Font.Size = 48 Canvas.DrawText("Confidential", _ 3*1440, 2*1440, 3*1440, 4*1440)

VerticalAlignment

VerticalAlignment (Canvas)
Description
Sets or returns the vertical position of the text relative to the containing area.

ActiveReports 2.0 Standard User's Guide | 232

Data Type
Integer

Settings
Value 0 1 2 Mnemonic ddTXTop ddTXMiddle ddTXBottom Description Aligns the text to the top of the object area. Centers the text vertically within the object area. Align the text to the bottom of the object area.

Availability
Design time Run time N/A Read / Write

Example
Canvas.VerticalAlignment = ddTXTop

Width

Width
Description
Sets or returns the horizontal drawing area for the canvas in twips.

Data Type
Long

Availability
Design time Run time N/A Read / Write

Example
Private Sub ActiveReport_PageStart() 'sets the canvas to be 4in X 5in and draws red box 'on top of it. Me.Canvas.BackColor = vbRed Me.Canvas.BackStyle = 1 Me.Canvas.Width = 4 * 1440 Me.Canvas.Height = 5 * 1440 Me.Canvas.DrawRect 0, 0, Canvas.Width, Canvas.Height End Sub

Canvas Methods

Canvas Methods
Method Clear Description Clear the canvas object. Sub Clear() DrawEllipse Draws an elliptical shape to the canvas at the specified

ActiveReports 2.0 Standard User's Guide | 233

coordinates. Sub DrawEllipse(left As Long, top As Long, width As Long, height As Long) DrawLine Draws a line to the canvas at the specified coordinates. The line width and style depend on the PenWidth and PenStyle property settings. Sub DrawLine( x1 As Long , y1 As Long , x2 As Long , y2 As Long ) DrawPicture Draws a picture to the canvas at the specified coordinates. Sub DrawPicture(hPic As StdPicture, left As Long, top As Long, width As Long, height As Long) DrawPictureLink Draws the specified picture, with a hyperlink, to the canvas surface at the specified coordinates. Sub DrawPictureLink( Picture as stdPicture , Left As Long , Top As Long , Width As Long , Height As Long , HyperLink As String ) DrawRect Draws a rectangular shape to the canvas at the specified coordinates. The line width and style depend on the PenWidth and PenStyle property settings. Sub DrawRect(left As Long, top As Long, width As Long, height As Long) DrawRoundRect Draws a round rectangular shape to the canvas at the specified coordinates. The line width and style depend on the current PenWidth and PenStyle property settings. Sub DrawRoundRect( left As Long , top As Long , width As Long , height As Long , w As Long , h As Long) DrawText Prints a text string to the canvas. The font and color of the printed text depend on the current Font, BackColor, BackStyle and ForeColor property settings. The text is clipped to the specified coordinates. Sub DrawText( text As String , x As Long , y As Long , width As Long , height As Long ) DrawTextLink Prints a text string with a hyperlink to the canvas. The font and color of the printed text depend on the current Font, BackColor, BackStyle and ForeColor property settings. The text is clipped to the specified coordinates. Sub DrawTextLink( Text As String , X As Long , Y As Long , Width As Long , Height As Long , Hyperlink As String ) FillRect Fills the rectangle at the specified coordinates with solid ForeColor. Sub FillRect( left As Long , top As Long , width As Long , height As Long ) IntersectClipRect Creates a clipping rectangle. All drawing will be clipped to the new clipping rectangle. Sub IntersectClipRect( x As Long , y As Long , w As Long , h As Long ) Load Loads a previously saved canvas object from the specified file. Sub Load( FileName As String ) MeasureParagraphHeight Returns the height of a formatted paragraph string with the specified width. Function MeasureParagraphHeight( text As String , width As Long ) As Long MeasureText Returns the width and height of a text string when printed to the canvas with the current font settings. Sub MeasureText( text As String , width As Long , height As Long ) Overlay Overlays the specified canvas object on top of the canvas object. Sub Overlay( Canvas As Canvas ) PopClipRect Restores the previous clipping rectangle.

ActiveReports 2.0 Standard User's Guide | 234

Sub PopClipRect() PushClipRect Saves the current clipping rectangle. This method should be called before calling IntersectClipRect to save the current clipping rectangle. Sub PushClipRect() Save Saves the canvas object to the specified file. Sub Save(FileName As String ) TextOut Prints a text string at the specified coordinates. The font and color depend on the current Font and color properties. Sub TextOut( text As String , x As Long , y As Long )

Clear

Clear (Canvas)
Description
Clears the canvas of all prior output

Return Type
None

Syntax
Sub Clear()

Parameters
None

Example
Dim cv As New Canvas cv.TextOut "Sales Report", 1440, 1000 'Add this page to the pages collection rpt.Pages.Insert rpt.Pages.Count, cv cv.Clear 'Create the second page

DrawEllipse

DrawEllipse
Description
DrawEllipse method draws an elliptical shape to the canvas object at the specified coordinates.

Return Type
None

Syntax
Sub DrawEllipse(left As Long, top As Long, width As Long, height As Long)

Parameters
Name Left Top Type Long Long Description Left coordinate of the ellipse shape (Twips). Top coordinate of the ellipse shape (Twips)

ActiveReports 2.0 Standard User's Guide | 235

Width Height

Long Long

Width of the ellipse shape (Twips) Height of the ellipse shape (Twips)

Example
Canvas.DrawEllipse 1440, 1440, 1440, 2880

DrawLine

DrawLine
Description
DrawLine method draws a line to the canvas at the specified coordinates. The line width and style depend on the PenWidth and PenStyle property settings.

Return Type
None

Syntax
Sub DrawLine(x1 As Long, y1 As Long, x2 As Long, y2 As Long)

Parameters
Name x1, y1 x2, y2 Type Long Long Description Coordinates of the line's starting point (Twips). Coordinates of the line's ending point (Twips).

Example
Canvas.PenWidth = 2 Canvas.DrawLine 0, 1440, PrintWidth, 1440

DrawPicture

DrawPicture
Description
Draws the specified picture to the canvas surface at the specified coordinates.

Return Type
None

Syntax
Sub DrawPicture(hPic As stdPicture, left As Long, top As Long, width As Long, height As Long)

Parameters
Name hPic left, top width, height Type StdPicture Long Long Description Picture object to be drawn to the canvas Coordinates of the picture. Dimensions of the picture.

Example
Dim pic As StdPicture

ActiveReports 2.0 Standard User's Guide | 236


Set pic = LoadPicture App.Path & "\TopSecret.WMF" Canvas.DrawPicture pic, 0,0,Canvas.Width, Canvas.Height

DrawPictureLink

DrawPictureLink
Description
Draws the specified picture, with an embedded hyperlink, to the canvas surface at the coordinates indicated.

Return Type
None

Syntax
Sub DrawPictureLink(Picture As stdPicture, Left As Long, Top As Long, Width As Long, Height As Long, Hyperlink As String)

Parameters
Name Picture Left, Top Width, Height Hyperlink Type stdPicture Long Long String Description Picture object to be drawn to the canvas Coordinates of the picture. Dimensions of the picture. String indicating the URL for the hyperlink

Example
Private Sub ActiveReport_PageStart() Dim pic As StdPicture Dim str As String 'Set the picture to load for DrawPictureLink Set pic = LoadPicture(App.Path & "\ARLogo.jpg") 'Set the text to use with DrawTextLink str = "Link To DataDynamics Web Page" 'Draw image to canvas and attach a hyperlink Canvas.DrawPictureLink pic, 1 * 1440, 1 * 1440, _ 2 * 1440, 2 * 1440, "www.datadynamics.com" 'Set a font name and size to use on the canvas Canvas.Font.Name = "Arial" Canvas.Font.Size = 18 'Draw text to canvas and attach a hyperlink Canvas.DrawTextLink str, 1 * 1440, 4 * 1440, _ 3 * 1440, 4 * 1440, "www.datadynamics.com" End Sub

DrawRect

DrawRect
Description
DrawRect method draws a rectangular shape to the canvas object at the specified coordinates. The line width and style depend on the PenWidth and PenStyle property settings.

Return Type
None

ActiveReports 2.0 Standard User's Guide | 237

Syntax
Sub DrawRect(left As Long, top As Long, width As Long, height As Long)

Parameters
Name Left Top Width Height Type Long Long Long Long Description Left coordinate of the rectangle shape (Twips). Top coordinate of the rectangle shape (Twips) Width of the rectangle (Twips) Height of the rectangle (Twips)

Example
For i = 1440 to 3 * 1440 Step 300 Canvas.DrawRect 100, I, PrintWidth 200, 300 Next i

DrawRoundRect

DrawRoundRect
Description
DrawRoundRect method draws a round rectangular shape to the canvas at the specified coordinates. The line width and style depend on the current PenWidth and PenStyle property settings.

Return Type
None

Syntax
Sub DrawRoundRect(Left As Long, Top As Long, Width As Long, Height As Long, w As Long, h As Long)

Parameters
Name Left Top Width Height W H Type Long Long Long Long Long Long Description Left coordinate of the rectangle shape (Twips). Top coordinate of the rectangle shape (Twips) Width of the rectangle (Twips) Height of the rectangle (Twips) Width of the rounded angle (Twips) Height of the rounded angle (Twips)

Example
Private Sub PageHeader_Format() ' Draw a round rectangle with Top Secret centered With Canvas .PenStyle = ddLSSolid .PenWidth = 2 .DrawRoundRect 100, 100, 1500, 300, 10, 10 .Alignment = ddTXCenter .DrawText "Top Secret", 100, 100, 1500, 300 End With End Sub

ActiveReports 2.0 Standard User's Guide | 238

DrawText

DrawText
Description
DrawText prints a text string to the canvas using the current font and color settings. It wraps the text to fit within the bounds of the specified coordinates. Note: If the text is too large, it will be clipped to the specified region.

Return Type
None

Syntax
Sub DrawText(Text As String, x As Long, y As Long, Width As Long, Height As Long)

Parameters
Name Text X Y Width Height Type String Long Long Long Long Description String to be printed to the Canvas Left coordinate of the text area (Pixels). Top coordinate of the text area (Pixels) Width of the text area (Pixels) Height of the text area (Pixels)

Example
' Draw Confidential Message at 45 degree angle Canvas.TextAngle = 450 Canvas.Font.Name = "Arial" Canvas.Font.Size = 48 Canvas.DrawText("Confidential", _ 3*1440, 2*1440, 3*1440, 4*1440)

DrawTextLink

DrawTextLink
Description
DrawTextLink uses the canvas's current font and color settings to print a text string, with embedded hyperlink, to the canvas at the indicated coordinates. It wraps the text to fit within the bounds of the specified coordinates. Note: If the text is too large, it will be clipped to the specified region.

Return Type
None

Syntax
Sub DrawTextLink(Text As String, x As Long, y As Long, Width As Long, Height As Long, Hyperlink As String)

Parameters
Name Text Type String Description String to be printed to the Canvas

ActiveReports 2.0 Standard User's Guide | 239

X Y Width Height Hyperlink

Long Long Long Long String

Left coordinate of the text area (Pixels). Top coordinate of the text area (Pixels) Width of the text area (Pixels) Height of the text area (Pixels) String indicating the URL for the hyperlink

Example
Private Sub ActiveReport_PageStart() Dim pic As StdPicture Dim str As String 'Set the picture to load for DrawPictureLink Set pic = LoadPicture(App.Path & "\ARLogo.jpg") 'Set the text to use with DrawTextLink str = "Link To DataDynamics Web Page" 'Draw image to canvas and attach a hyperlink Canvas.DrawPictureLink pic, 1 * 1440, 1 * 1440, _ 2 * 1440, 2 * 1440, "www.datadynamics.com" 'Set a font name and size to use on the canvas Canvas.Font.Name = "Arial" Canvas.Font.Size = 18 'Draw text to canvas and attach a hyperlink Canvas.DrawTextLink str, 1 * 1440, 4 * 1440, _ 3 * 1440, 4 * 1440, "www.datadynamics.com" End Sub

FillRect

FillRect
Description
FillRect fills the rectangle at the specified coordinates with solid ForeColor. Note: FillRect does not draw a border around the rectangle.

Return Type
None

Syntax
Sub FillRect(left As Long, top As Long, width As Long, height As Long)

Parameters
Name Left Top Width Height Type Long Long Long Long Description Left coordinate of the rectangle (Pixels). Top coordinate of the rectangle (Pixels) Width of the rectangle (Pixels) Height of the rectangle (Pixels)

Example
rptSales.Pages(0).ForeColor = vbBlue rptSales.Pages(0).FillRect 1440, 1440, 2880, 720

ActiveReports 2.0 Standard User's Guide | 240

IntersectClipRect

IntersectClipRect
Description
Sets a clipping rectangle on the canvas at the specified coordinates. All drawing methods will be clipped to the new clipping region. Note: To remove the current clipping rectangle, Call the method with 1 value for all parameters. You should use the PushClipRect to save the current clipping rectangle before setting a new one.

Return Type
None

Syntax
Sub IntersectClipRect(x As Long, y As Long, w As Long, h As Long)

Parameters
Name x y w h Type Long Long Long Long Description Left coordinate of the clipping rectangle area (Pixels). Top coordinate of the clipping rectangle area (Pixels) Width of the clipping rectangle area (Pixels) Height of the clipping rectangle area (Pixels)

Example
Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.DrawText "Clipping regon set to 1000,1000,5000,5000. The two lines (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800< cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.DrawText "Clipping regon set to 500,500,3000,3000. The two lines (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.PushClipRect cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.PopClipRect cnv.DrawText "Clipping region set back to 500,500,3000,3000. The two lines (H and V) should be crop to fit in this box.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = Nothing

Load

Load (Canvas)
Description

ActiveReports 2.0 Standard User's Guide | 241

Loads the contents of a canvas object from the specified file.

Return Type
None

Syntax
Sub Load(FileName As String)

Parameters
Name filename Type String Description A valid filename that contains a previously saved canvas object

Example
Private Sub OverlayForm() Dim cv As New Canvas Dim pg As Canvas ' Load a saved canvas file cv.Load App.Path "\InvoiceForm.cnv" ' overlay it on all report pages For Each pg In rpt.Pages Pg.Overlay cv Next End Sub

MeasureParagraphHeight

MeasureParagraphHeight
Description
Returns the height a formatted paragraph string would have based off of a specified width. Note: When using MeasureParagraphHeight, the canvas font needs to match the controls font.

Return Type
Long

Syntax
Function MeasureParagraph(Text As String, Width As Long) As Long

Parameters
Name Text Width Type String Long Description The text string to be measured Specified the width of the paragraph text string (in twips)

Remarks
When using this function to size a field control or a label to its contents, you should account for the internal margins of the controls. The margin values are 40 horizontally and 30 vertically.

Example
Private Sub Detail_Format() Dim str As String 'Set string to use for the field str = "This is a string that will be used to measure the paragraph height"

ActiveReports 2.0 Standard User's Guide | 242

'Set the canavs font the same as the field being 'used to make sure the measurements are correct Canvas.Font = Field1.Font 'Set field1's height based off of the measurement With Field1 .Height = Canvas.MeasureParagraphHeight(str, _ .Width - 40) + 30 End With Field1.Text = str End Sub

MeasureText

MeasureText
Description
Returns the width and height of a text string when printed on the canvas with the current font settings. The Width and Height parameters are now of the type Variant to allow this function to work in the script editor.

Return Type
None

Syntax
Sub MeasureText(Text As String, Width As Variant, Height As Variant)

Parameters
Name Text Width Height Type String Variant Variant Description The text string to be measured Returns the width of the text string (in twips) Returns the minimum height of the text string (in twips)

Example
Dim w, h rpt.Pages(0).MeasureText "Confidential", w, h rpt.Pages(0).DrawText "Confidential", 1440, 1440, w, h

Overlay

Overlay
Description
Overlays (layers) the specified canvas object on top of the canvas object. You can use this method to layer a form template or letterhead on top of pages in your report.

Return Type
None The two canvas objects will be merged.

Syntax
Sub Overlay(Canvas As Canvas)

Parameters
Name Type Description

ActiveReports 2.0 Standard User's Guide | 243

Canvas

Canvas

A valid pointer to the overlay canvas object

Example
Private Sub OverlayForm() Dim cv As New Canvas Dim pg As Canvas ' Run the report to create the pages collection rptInvoice.Run ' Load a saved canvas file cv.Load App.Path & "\InvoiceForm.cnv" ' overlay it on all report pages For Each pg In rptInvoice.Pages Pg.Overlay cv Next End Sub

PopClipRect

PopClipRect
Description
Restores the previous clipping rectangle. You should call the PushClipRect before creating a new clipping rectangle using IntersectClipRect. Then, call PopClipRect to restore the original clipping rectangle.

Return Type
None

Syntax
Sub PopClipRect()

Parameters
NoneSample

Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.DrawText "Clipping regon set to 1000,1000,5000,5000. _ The two lines (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.DrawText "Clipping regon set to 500,500,3000,3000. The two lines _ (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.PushClipRect cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.PopClipRect cnv.DrawText "Clipping region set back to 500,500,3000,3000. The two _ lines (H and V) should be crop to fit in this box.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height

ActiveReports 2.0 Standard User's Guide | 244


mPages.Insert mPages.Count, cnv Set cnv = Nothing

PushClipRect

PushClipRect
Description
Saves the current clipping rectangle. You should call this method before creating a new clipping rectangle using the IntersectClipRect method. When setting a clipping rectangle, any items drawn on the canvas will only show up in the designated clipping region.

Return Type
None

Syntax
Sub PushClipRect()

Parameters
None

Example
Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.DrawText "Clipping regon set to 1000,1000,5000,5000. _ The two lines (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.DrawText "Clipping regon set to 500,500,3000,3000. The two lines _ (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.PushClipRect cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.PopClipRect cnv.DrawText "Clipping region set back to 500,500,3000,3000. The two _ lines (H and V) should be crop to fit in this box.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = Nothing

Save

Save (Canvas)
Description
Saves the canvas object to the specified file.

Return Type
None The canvas object will be persisted to the specified file.

ActiveReports 2.0 Standard User's Guide | 245

Syntax
Sub Save(FileName As String)

Parameters
Name filename Type String Description A valid filename where the canvas object will be saved

Example
Private Sub CreateFormTemplate() Dim cv As New Canvas ' Draw the form on the canvas using drawing methods ' Save the canvas object for later use cv.Save App.Path & "\InvoiceForm.cnv" End Sub

TextOut

TextOut
Description
TextOut method prints a text string to the canvas object at the specified coordinates. This method uses the current Canvas font and color settings. The printed string will not be wrapped or clipped. Note: DrawText should be used instead of TextOut.

Return Type
None

Syntax
Sub TextOut(Text As String, x As Long, y As Long)

Parameters
Name Text x, y Type String Long Description The text string to be printed The left and top coordinates where the text should be printed (in pixels).

Example
Dim cv As New Canvas cv.TextOut "Sales Report", 1440, 1000 'Add this page to the pages collection rpt.Pages.Insert rpt.Pages.Count, cv cv.Clear 'Create the second page 'Commit the changes rpt.Pages.Commit

Controls

Controls
Controls Methods BarCode Control Properties

ActiveReports 2.0 Standard User's Guide | 246

Checkbox Properties Field Control Properties Frames and Panes Image Properties Label Control Properties Line Properties OLE Control PageBreak Control Properties RTF Text Control Shape Control Properties Subreport Control Properties

Controls Methods

Controls Methods
Method Add Description Adds a new control to the collection. Function Add(ProgID As String) As Object Count Returns the number of controls in the collection. Function Count() As Integer Item Returns the control object at the specified index. Function Item(Index As Variant) As Object Remove Removes the specified control from the report. Sub Remove(index As Variant) RemoveAll Removes all of the controls from the collection. Sub RemoveAll()

Add

Add (Controls)
Description
Add method adds a new control of the specified ProgID to the collection.

Return Type
Control object

Syntax
Function Add(ProgID As String) As Object

Parameters
Name ProgID Type String Description The ProgID of the control to be added.

Settings
Internal controls have the following ProgID names:

ActiveReports 2.0 Standard User's Guide | 247

Control Label Field Image RichEdit Frame Checkbox PageBreak Line Shape OLE Object BarCode Subreport ADO Data Control DAO Data Control RDO Data Control XML Data Control

ProgID DDActiveReports2.Label DDActiveReports2.Field DDActiveReports2.Image DDActiveReports2.RichEdit DDActiveReports2.Frame DDActiveReports2.Checkbox DDActiveReports2.PageBreak DDActiveReports2.Line DDActiveReports2.Shape DDActiveReports2.OLE DDActiveReports2.BarCode DDActiveReports2.Subreport DDActiveReports2.DataControl DDActiveReports2.DAODataControl DDActiveReports2.RDODataControl DDActiveReports2.XMLDataControl

Example
Private Sub CreateNewReport() Dim rpt As New rptTemplate Dim ctl As Object ' Create report data source control With rpt.Sections("Detail").Controls Set ctl = .Add("DDActiveReports2.DAODataControl") ctl.Name = "dcRptData" ctl.DatabaseName = App.Path & "\MyDB.mdb" ctl.Recordsource = "SELECT * FROM Customers" ctl.Left = 4 * 1440 ctl.Top = 0 End With ' Create the rest of the controls ' Run the report End Sub

Count

Count (Controls)
Description
Count method returns the number of controls in the collection.

Return Type
Integer

Syntax
Function Count() As Integer

Parameters
None

Example
Private Sub Detail_BeforePrint()

ActiveReports 2.0 Standard User's Guide | 248


Dim ctrl As Control Dim sec As Section Set sec = ActiveReport1.Sections("Detail") For Y = 0 To sec.Controls.Count - 1 If TypeOf sec.Controls(Y) Is DDActiveReports2.Field Then If sec.Controls(Y).DataValue = 0 Then sec.Controls(Y).Visible = False Else sec.Controls(Y).Visible = True End If End If Next Y End Sub

Item

Item (Controls)
Description
The Item method returns a reference to the control object at the specified index.

Return Type
Section object

Syntax
Function Item(Index As Variant) As Object

Parameters
Name Index Type Variant Description The index of the control in the collection or unique name of the control.

Remove

Remove (Controls)
Description
The Remove method removes the control at the specified index from the controls collection.

Return Type
None

Syntax
Sub Remove(index As Variant)

Parameters
Name Index Type Variant Description The index of the control in the collection or unique name of the control.

RemoveAll

RemoveAll (Controls)
Description
The RemoveAll method removes all control objects within the section specified.

ActiveReports 2.0 Standard User's Guide | 249

Return Type
Integer

Syntax
Sub RemoveAll()

Parameters
None

Example
Private Sub ActiveReport_ReportStart() Me.Detail.Controls.RemoveAll End Sub

BarCode Control Properties

BarCode Control Properties


Property Alignment Data Type TextAlignment Description Sets or returns the position the barcode's readable caption will have relative to the barcode's left, center and right edges. Sets or returns the barcode's background color or fill color. Sets or returns the width, in pixels, for the barcode's narrow bars. Sets or returns the barcode's caption. Sets or returns the type of vertical alignment the barcode's caption will have. Sets or returns the field the control will be bound to. Sets or returns the barcode's direction horizontally or vertically. Sets or returns if checksum value is used when rendering barcode. Sets or returns the font properties used to print the caption. Sets the font color used to print the barcode. Sets or returns the type of code, or symbology, the barcode control will use to generate the barcodes.

BackColor BarWidth Caption CaptionPosition DataField Direction EnableCheckSum Font ForeColor Style

OLE_COLOR Integer String BarCodeCaptionPosition String BarCodeDirection Bool StdFont OLE_COLOR BarCodeStyle

Alignment

Alignment (BarCode)
Description
Sets or returns the position the barcode's readable caption will have relative to the barcode's left, center and right edges.

ActiveReports 2.0 Standard User's Guide | 250

Data Type
TextAlignment

Settings
Value 0 1 2 Mnemonic ddTXLeft ddTXRight ddTXCenter Description Aligns the text to the left edge of the object area. Aligns the text to the right edge of the object area. Center the text horizontally within the object area.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() ActiveReport1.Barcode1.Alignment = ddTXCenter End Sub

BackColor

BackColor (BarCode)
Description
Sets or returns the barcode's background color or fill color.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
' Mark the outstanding sales in red background Private Sub Detail_Format() If fieldID = "1400" then Barcode1.BackColor = vbRed Else Barcode1.BackColor = vbBlue End If End Sub

BarWidth

ActiveReports 2.0 Standard User's Guide | 251

BarWidth
Description
Sets or returns the width for the Barcode's narrow bars. Setting the width to 0 expands the barcode to fit the control and the width ratio is 1 to 15 twips. So setting the BarWidth to 2 will have a value of 30 twips.

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() Barcode1.BarWidth = 10 End Sub

Caption

Caption (BarCode)
Description
Sets or returns the barcode's caption. Note: The caption is limited to the specified style's character set symbology. If an unsupported character is used, it will not be displayed.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Barcode1.caption = fldItemName End Sub

CaptionPosition

CaptionPosition
Description
Sets or returns the type of vertical alignment the barcode's caption will have.

Data Type

ActiveReports 2.0 Standard User's Guide | 252

BarCodeCaptionPosition

Settings
Value 0 1 2 Mnemonic ddbcCaptionNone ddbcCaptionAbove ddbcCaptionBelow Description Does not display the barcode's caption. The caption is positioned above the barcode. The caption is positioned below the barcode.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Barcode1.Caption = fldItemName Barcode1.CaptionPosition = ddbcCaptionBelow End Sub

DataField

DataField (BarCode)
Description
Sets or returns the field from which a bound control will pull its data. When the DataField property is set to a field name contained within the DataSource, ActiveReports binds the field's data from each record to the control. It then loads the field's value into the DataValue property and formats it into the Text property based on the OutputFormat property. When using XML, the DataField must be set to a valid XPath string. Note: The base path set by the RecordSetPattern is used as the starting node. So if a control needs to use a higher level node, use "../" to move back a node.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_DataInitialize() Fields.Add "ItemCode" Barcode1.DataField = "ItemCode" End Sub

Direction

Direction

ActiveReports 2.0 Standard User's Guide | 253

Description
Sets or returns the barcode's direction, horizontally or vertically.

Data Type
BarCodeDirection

Settings
Value 0 1 2 3 Mnemonic ddbcLeftToRight ddbcRightToLeft ddbcTopToBottom ddbcBottomToTop Description Sets the barcode's direction left to right horizontally. Sets the barcode's direction right to left horizontally. Sets the barcode's direction down the page vertically. Sets the barcode's direction up the page vertically

Availability
Design time Run time Read/Write Read / Write

Example
Private Sub Detail_Format() Barcode1.Direction = ddbcTopToBottom End Sub

EnableCheckSum

EnableCheckSum
Description
Sets or returns if checksum value is used when rendering barcode. Setting EnableCheckSum to false will only affect codes with checksum values.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() Barcode1.EnableCheckSum = True Barcode2.EnableCheckSum = False End Sub

Font (BarCode)

Font (BarCode)

ActiveReports 2.0 Standard User's Guide | 254

Description
Sets or returns the font settings for a control or canvas object. The font property allows access to font name, size, styles, and effects. By using the Canvas object's font properties and draw methods, text can be written directly to the canvas.

Data Type
stdFont

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor (BarCode)

ForeColor (BarCode)
Description
Sets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageHeader_Format() ' Paint a Red Confidential in the top-left corner ' of each page and change the totals to a red font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial" Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

Style

Style (BarCode)

ActiveReports 2.0 Standard User's Guide | 255

Description
Sets or returns the type of code, or symbology, the barcode control will use to generate the barcodes.

Data Type
BarCodeStyle

Settings
Value 0 1 2 3 4 5 6 7 8 9 10 11 Mnemonic ddbcNone ddbcAnsi39 ddbcAnsi39X ddbcCode_2_of_5 ddbcCode25intlv ddbcCode25mat ddbcCode39 ddbcCode39x ddbcCode_128_A ddbcCode_128_B ddbcCode_128_C ddbcCode_128auto Description None ANSI 3 of 9 (Code 39) uses upper case, numbers, - , * $ / + % ANSI Extended 3 of 9 (Extended Code 39) uses the complete ASCII character set 2 of 5 uses only numbers Interleaved 2 of 5 uses only numbers 25 Matrix Code 39 uses numbers, % * $ /. , - +, and upper case. Extended Code 39 uses the complete ASCII character set 128 A uses control characters, numbers, punctuation, and upper case 128 B uses punctuation, numbers, upper case, and lower case 128 C uses only numbers 128 Auto uses complete ASCII character set. Automatically selects between Code 128 A, B, and C to give the smallest barcode. Code 93 uses uppercase, % $ * / , + -, and numbers Extended Code 93 uses the complete ASCII character set MSI Code uses only numbers PostNet uses only numbers with a check digit Codabar uses A B C D + - : , / and numbers EAN-8 uses only numbers (7 numbers and a check digit) EAN-13 uses only numbers (12 numbers and a check digit) UPC-A uses only numbers (11 numbers and a check digit) UPC-E0 uses only Numbers. Used for zero-compression UPC symbols. For the Caption property, you may enter either a sixdigit UPC-E code or a complete 11-digit (includes code type, which must be 0 (zero)) UPC-A code. If an 11-digit code is entered, the Barcode control will convert it to a six-digit UPC-E code, if possible. If it is not possible to convert from the 11digit code to the six-digit code, nothing is displayed UPC-E1 uses only numbers. Used typically for shelf labeling in the Retail environment. The length of the input string for U.P.C. E1 is 6 numeric characters. Royal Mail RM4SCC uses only letters and numbers (with a check digit) This is the barcode used by the Royal Mail in the United Kingdom. UCC/EAN 128 uses the complete ASCII character set. A special version of Code 128 used in HIBC applications.

12 13 14 15 16 17 18 19 20

ddbcCode93 ddbcCode93x ddbcMSI ddbcPostNet ddbcCodabar ddbcEAN_8 ddbcEAN_13 ddbcUPC_A ddbcUPC_E0

21

ddbcUPC_E1

22

ddbcRM4SCC

23

ddbcUCCEAN128

Availability
Design time Run time Read/Write Read / Write

ActiveReports 2.0 Standard User's Guide | 256

Example
Private Sub ActiveReport_ReportStart() Barcode1.Style = ddbcUPC_A End Sub

Checkbox Properties

Checkbox Properties
Property Alignment BackColor Data Type TextAlignment OLE_COLOR Description Sets or returns the alignment of text within the object area. Sets or returns the background color of the object. This property is ignored if the BackStyle is set to transparent. Sets or returns the object transparency setting. Sets or returns the printed caption of the checkbox. Sets or returns the font properties of the object. Sets or returns the foreground color of the print font. Sets or returns a style string for the specified checkbox. The style string can be used override a global style or set a particular style for the specified checkbox. Sets or returns the value of the checkbox, checked or not checked.

BackStyle Caption Font ForeColor Style

Integer String StdFont OLE_COLOR String

Value

Boolean

Alignment

Alignment (Checkbox)
Description
Alignment property determines where the checkbox caption should be printed relative to the left, center and right edges of the text field area.

Data Type
TextAlignment

Settings
Value 0 1 2 Mnemonic ddTXLeft ddTXRight ddTXCenter Description Aligns the text to the left edge of the object area. Aligns the text to the right edge of the object area. Center the text horizontally within the object area.

Availability

ActiveReports 2.0 Standard User's Guide | 257

Design time Run time

Read / Write Read / Write

Example
rptMain.chkPassed.Align = ddTXRight

BackColor (Checkbox)

BackColor (Checkbox)
Description
Sets or returns the background color or fill color for the objects. Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

BackStyle (Checkbox)

BackStyle (Checkbox)
Description
Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the new object's transparent areas. The line in the illustration below is behind both objects. However, it shows through the transparent object but not the normal object.

Data Type
BackStyle

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 258

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

Caption

Caption (Checkbox)
Description
Caption property sets or returns the text string to be printed with the checkbox.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
rptMain.chkPassed.Caption = "Passed"

Font (Checkbox)

Font (Checkbox)
Description
Sets or returns the font settings for a control or canvas object. The font property allows access to font name, size, styles, and effects. By using the Canvas object's font properties and draw methods, text can be written directly to the canvas.

Data Type
stdFont

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ActiveReports 2.0 Standard User's Guide | 259

ForeColor (Checkbox)

ForeColor (Checkbox)
Description
Sets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageHeader_Format() ' Paint a Red Confidential in the top-left corner ' of each page and change the totals to a red font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial" Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

Style

Style (Checkbox)
Description
Sets or returns a style string for the specified field. The style string can be used to override a global style or set a particular style for the specified field. Note: If an invalid CSS style string is used, the style string will be ignored.

DataType
String

Availability
Design time Run time Read/Write Read / Write

Example
Private Sub Detail_Format() 'If the balance isPositive is false then the font 'is red and bold. If isPositive is true then the 'font is black and normal If isPositive = False Then txtBalance.Style = "font-family: SimSun; fontweight:bold; text-align: center; color: rgb(255,0,0)" ElseIf isPositive = True Then txtBalance.Style = "font-family: SimSun; fontweight: normal; text-align: center;

ActiveReports 2.0 Standard User's Guide | 260


color: rgb(0,0,0)" End If End Sub

Value

Value (Checkbox)
Description
Value property sets or returns whether the checkbox is checked or not checked.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() If txtGrade.DataValue > 60 Then chkPassed.Value = 1 End If End Sub

Field Control Properties

Field Control Properties


Property Alignment Data Type TextAlignment Description Determines how the value should be printed relative the left, center and right edges of the field. Sets or returns the background fill color of the field. Sets or returns the transparency of the field. When set to True, the field area will grow vertically to fit the text. Otherwise, the text will be clipped to the preset size of the field. When set to True, the field will shrink to fit the text. Sets or returns the controls global style. The global styles are specified in the styles drop-down window. Sets or returns a value indicating whether null values are counted in averages and count totals for the field. Sets or returns the name of the bound field. Sets or returns the value of a field before formatting is applied.

BackColor BackStyle CanGrow

OLE_COLOR Integer Boolean

CanShrink ClassName

Boolean String

CountNullValues ('CountNullValues (Field)' in the on-line documentation) DataField DataValue

Boolean

String Variant

ActiveReports 2.0 Standard User's Guide | 261

Font ForeColor hyperLink

StdFont OLE_COLOR String

Sets or returns the font properties used to print the value of the field. Sets the font color used to print the value of the field. Sets or returns a hyperlink for a field. Once a hyperlink is set, users can follow the specified link by clicking on the field at run time. Determines whether the contents of the field are printed on a single line or multiple lines. Sets or returns the formatting string used to translate the data value of the field to its printed text value. Sets or returns a style string for the field. The style string can be used to specify a particular appearance for each field. Sets the field name that should be used in calculating distinct summary functions. Sets a value that is used to calculate unbound distinct summary functions. Sets the type of summarization to be calculated for the specified field. Specifies the summarization group level. This property is ignored if the SummaryType is not a group level summary. Specifies the type of running summarization to be used. Specifies the level of summarized to be used. Sets or returns the formatted value of the field to be printed. Determines how the value should be printed relative to the top, middle, and bottom of the field. Sets or returns whether or not a field's text will wrap. Sets or returns the order, front or back, for the controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

Multiline

Boolean

OutputFormat

String

Style

String

SummaryDistinctField

String

SummaryDistinctValue SummaryFunc SummaryGroup

String SummaryFunctions String

SummaryRunning SummaryType Text VerticalAlignment

SummaryRunningType SummaryType String VerticalTextAlignment

WordWrap ZOrder

Boolean Integer

Alignment

Alignment (Field)
Description
Alignment property determines where the Text value should be printed relative to the left, center and right edges of the text field area.

Data Type

ActiveReports 2.0 Standard User's Guide | 262

TextAlignment

Settings
Value 0 1 2 Mnemonic ddTXLeft ddTXRight ddTXCenter Description Aligns the text to the left edge of the object area. Aligns the text to the right edge of the object area. Center the text horizontally within the object area.

Availability
Design time Run time Read / Write Read / Write

Example
rptInvestments.fldName.Alignment = ddTXRight

BackColor (Field)

BackColor (Field)
Description
Sets or returns the background color or fill color for the objects. Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

BackStyle (Field)

BackStyle (Field)
Description
Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the new object's transparent areas. The line in the illustration below is behind both objects. However, it shows through the transparent object but not the normal object.

ActiveReports 2.0 Standard User's Guide | 263

Data Type
BackStyle

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

CanGrow

CanGrow (Field)
Description
CanGrow property determines whether ActiveReports should increase the height of the field based on its value. When set to False, ActiveReports clips the text to fit within the control's predefined height. When set to True, ActiveReports increases the height of the controls and shifts all controls below it to account for the increase in height. Note: The increase in height might cause the section height to increase. The section's CanGrow property should be set to True to avoid clipping the section.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
rptInvestments.fldName.CanGrow = True rptInvestments.fldName.CanShrink = False

CanShrink

CanShrink (Field)
Description
CanShrink property determines whether ActiveReports should decrease the height of the control based on the value of the field. When set to False, the field will take the exact area defined by its preset coordinates. When set to True, ActiveReports will decrease the height of the field to exactly fit

ActiveReports 2.0 Standard User's Guide | 264 the contents and shift the control below it upward to account for the decrease in height.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
rptInvestments.fldName.CanGrow = True rptInvestments.fldName.CanShrink = False

ClassName

ClassName (Field)
Sets or returns the controls global style. The global styles are specified in the styles drop -down window.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() fldID.ClassName = "Heading2" End Sub

DataField (Field)

DataField (Field)
Description
Sets or returns the database field a control will pull its data from. When the DataField property is set to a field contained within the DataSource, ActiveReports binds the field's data from each record to the control. The recordset data is first saved into the DataValue property. It then passes through any OutputFormats and is set as the control's text. When using XML the DataField must be set to a valid XPath string. Note: The base path set by the RecordSetPattern is used as the starting node, so if a control needs to use a higher level node, use "../" to move back a node. The DataField property can also be used to perform calculations using scripting expressions by stating the properties with an "=". This allows fields to be set up to display calculated results. For example, a field control or a GroupHeader's DataField property can be set to an expression such as "=UnitPrice * Qty" or "=Trim(CompanyName)" where UnitPrice, Qty and CompanyName are members of the report's Fields collection. To display the current date and time in a field, set its DataField property to "=now".

Data Type

ActiveReports 2.0 Standard User's Guide | 265

String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub CreateReport() Dim ar As rptTemplate ' rptTemplate is a predefined report ' Template already has a data control named dcRptData ' in the Detail Section Set ar = New rptTemplate With ar.Sections("Detail").Controls ' Add a field to report Set ctl = .Add("DDActiveReports2.Field") ' Set the new field's properties ctl.Name = "CompanyName" ctl.Top = 0 ctl.Left = 0 ctl.Width = 1500 ctl.Height = 285 ' Assign as DataSource and DataField to the field ctl.DataSource = "dcRptdata" ctl.DataField = "CompanyName" ' .. Set up the rest of the fields End With ' Preview the report ar.Show End Sub

DataValue

DataValue
Description
DataValue property is populated at runtime with the value of the bound field as retrieved from the data source. You can set the DataValue of calculated fields at runtime. ActiveReports will format the value and place the result in the text property.

Data Type
Variant

Availability
Run time Read/Write

Example
Private Sub ghCountry_BeforePrint() ' Set the datavalue of the calculated field. ' The datavalue will be formatted based on outputFormat ' and the result will be in .text txtPctTotal.DataValue = txtSales.DataValue / _ txtGrandTotal.DataValue End Sub

Font (Field)

ActiveReports 2.0 Standard User's Guide | 266

Font (Field)
Description
Sets or returns the font settings for a control or canvas object. The font property allows access to font name, size, styles, and effects. By using the Canvas object's font properties and draw methods, text can be written directly to the canvas.

Data Type
stdFont

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor (Field)

ForeColor (Field)
Description
Sets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageHeader_Format() ' Paint a Red Confidential in the top-left corner ' of each page and change the totals to a red font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial" Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

hyperLink

ActiveReports 2.0 Standard User's Guide | 267

hyperLink (Field)
Description
Sets or returns a hyperlink for a field. Once a hyperlink is set, users can follow the specified link by clicking on the field at run time. Note: The hyperlink can link to TOC entries, other reports, and any other properly formatted HTML links.

DataType
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() fldLink.hyperLink = "www.datadynamics.com" fldLink.Text = "fldLink's Hyperlink is: " & _ fldLink.hyperLink End Sub

Multiline

Multiline (Field)
Description
Determines whether the contents of the field should wrap across multiple lines. When set to False, the field text is limited to a single line regardless of the height or CanGrow properties.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
RptInvestments.fldName.MultiLine = True rptInvestments.fldName.CanGrow = True rptInvestments.fldName.CanShrink = False

OutputFormat

OutputFormat
Description
OutputFormat sets or returns the mask string used to format the DataValue into the Text property. It uses the Visual Basic Format function settings.

ActiveReports 2.0 Standard User's Guide | 268

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
rptInvestments.fldName.OutputFormat = "$###0.00"

Style

Style (Field)
Description
Sets or returns a style string for the specified field. The style string can be used to override a global style or set a particular style for the specified field. Note: If an invalid CSS style string is used, the style string will be ignored.

DataType
String

Availability
Design time Run time Read/Write Read / Write

Example
Private Sub Detail_Format() 'If the balance isPositive is flse then the font 'is red and bold. If isPositive is true then the 'font is black and normal If isPositive = False Then txtBalance.Style = "font-family: SimSun; fontweight:bold; text-align: center; color: rgb(255,0,0)" ElseIf isPositive = True Then txtBalance.Style = "font-family: SimSun; fontweight: normal; text-align: center; color: rgb(0,0,0)" End If End Sub

SummaryDistinctField

SummaryDistinctField
Description
SummaryDistinctField property sets or returns the name of the field used in a distinct summary function. The summary function will process DataField values based on the distinct value of this field. Note: This property is used only when the SummaryFunc value is one of Distinct Summary Functions. When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

ActiveReports 2.0 Standard User's Guide | 269

Data Type
String

Availability
Design time Run time Read / Write Read / Write

SummaryDistinctValue

SummaryDistinctValue
Description
SummaryDistinctValue allows processing distinct summary function where the distinct value is unbound. You can set the property for each record at run-time. The changes in the value will decide how the summarized data will be calculated. Note: When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

SummaryFunc

SummaryFunc
Description
Sets the type of the summary function used to process the DataField values. You can use this function to create sub totals, grand totals and other summary values. Note: When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type
SummaryFunctions

Settings
Value 0 1 2 3 4 5 Mnemonic ddSFSum ddSFAvg ddSFCount ddSFMin ddSFMax ddSFVar Description Calculates the total of all values within the specified summary region (group, page report). Calculates the average of all values within the specified summary region (group, page or report). Calculates the count of all values within the specified summary region (group, page or report). Calculates the minimum of all values within the specified summary region (group, page or report). Calculates the maximum of all values within the specified summary region (group, page or report). Calculates the variance of all values within the specified

ActiveReports 2.0 Standard User's Guide | 270

summary region (group, page or report). 6 7 8 9 ddSFVarP ddSFStdDev ddSFStdDevP ddSFDSum Calculates the population variance of all values within the specified summary region (group, page or report). Calculates the standard deviation of all values within the specified summary region (group, page or report). Calculates the population standard deviation of all values within the specified summary region (group, page or report). Calculates the total based on the distinct values of another field within the specified summary region (group, page or report). Calculates the average based on the distinct values of another field within the specified summary region (group, page or report). Calculates the distinct count based on the distinct values of another field within the specified summary region (group, page or report). Calculates the variance based on the distinct values of another field within the specified summary region (group, page or report). Calculates the population distinct variance based on the distinct values of another field within the specified summary region (group, page or report). Calculates the standard deviation based on the distinct values of another field within the specified summary region (group, page or report). Calculates the population standard deviation based on the distinct values of another field within the specified summary region (group, page or report).

10

ddSFDAvg

11

ddSFDCount

12

ddSFDVar

13

ddSFDVarP

14

ddSFDStdDev

15

ddSFDStdDevP

Availability
Design time Run time Read / Write Read / Write

SummaryGroup

SummaryGroup
Description
SummaryGroup property sets or returns the name of the group header section that will reset the summarized field value. For example, setting a sum of price for an order group header, will reset the sum to zero for each order group. This property is valid when the SummaryType is set to 3-SubTotal. Note: When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

SummaryRunning

SummaryRunning

ActiveReports 2.0 Standard User's Guide | 271

Description
SummaryRunning determines whether the summarization will be accumulated or reset for each level (detail, group or page). Setting this property ddSRGroup or ddSRAll will make ActiveReports print a running summary of the field at the group or report level. Note: When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type
SummaryRunningType

Settings
Value 0 1 Mnemonic ddSRNone ddSRGroup Description Do not calculate a running summary. Calculates a running summary (each value is the sum of the current value and all preceding values) within the same group level. Calculates a running summary for all values.

ddSRAll

Availability
Design time Run time Read / Write Read / Write

SummaryType

SummaryType
Description
SummaryType determines the type of summarization on the field if any. ActiveReports can summarize the field as: Sub total (group level; reset for each group), Grand total (report level; do not reset until all records are processed), Page total (page level; reset for each page), Or a page count, which is the total number of pages printed. Note: If the summarized field is placed ahead of it summary level, (for example, placing a page total in the page header or a report grand total in the report header), the containing section and the following sections will not be printed until the summary value is resolved (calculated). When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type
SummaryType

Settings
Value 0 1 2 3 Mnemonic ddSMNone ddSMGrandTotal ddSMPageTotal ddSMSubTotal Description No summarization. Specifies a report level summary, evaluates the summary function for all records in the report. Specifies a page level summary, evaluates the summary function for all records on each page. Specifies a group level summary, evaluates the summary function for all records in each group level.

ActiveReports 2.0 Standard User's Guide | 272

ddSMPageCount

Specifies a Page Count field.

Availability
Design time Run time Read / Write Read / Write

Text

Text (Field)
Description
Sets or returns the text string to be displayed in the field.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() If fldItem.Text = "" then fldItem.Text = "None" End If End Sub

VerticalAlignment

VerticalAlignment (Field)
Description
VerticalAlignment property determines where the Text value should be printed relative to the top, middle and bottom edges of the text field area.

Data Type
VerticalTextAlignment

Settings
Value 0 1 2 Mnemonic ddTXTop ddTXMiddle ddTXBottom Description Aligns the text to the top of the object area. Centers the text vertically within the object area. Aligns the text to the bottom of the object area.

Availability
Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 273

Run time

Read / Write

Example
rptRPW.fldArable.VerticalAlignment = ddTXMiddle

WordWrap

WordWrap (Field)
Description
Sets or returns whether or not the label's caption will wrap. When WordWrap is set to False, "whitespace:nowrap" will appear in the Style property window. If the caption is longer than the label, setting WordWrap to false will truncate the caption at the end of the label instead of the truncating the caption after the last full word. Note: When setting WordWrap to true, Multiline must also be set to true. Setting WordWrap to false will negate the Multiline property.

DataType
Boolean

Availability
Design time Run time Read/Write Read / Write

Example
Private Sub Detail_Format() Field1.WordWrap = False End Sub

ZOrder (Field)

ZOrder (Field)
Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Zorder should not be set after the ReportStart event has fired.

Return Type
None

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Position Type Integer Description Sets the position, front or back, for the control.

Settings
Value 0 Description Setting the ZOrder to 0 brings the control to the front.

ActiveReports 2.0 Standard User's Guide | 274

Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0 txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _ + txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle End Sub

Frames and Panes

Frames and Panes


Frame Control Properties Panes

Frame Control Properties

Frame Control Properties


Property BackColor CanGrow Data Type OLE_COLOR Boolean Description Sets or returns the background fill color of the frame. When set to True, the frame area will grow vertically to fit the text. Otherwise, the text will be clipped to the preset size of the frame. When set to True, the frame will shrink to fit the text. Sets or returns if the border is closed A collection of the pane objects appearing in the frame Sets or returns the order, front or back, for the controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

CanShrink CloseBorder Panes ZOrder

Boolean Boolean Pane Integer

BackColor

ActiveReports 2.0 Standard User's Guide | 275

BackColor (Frame)
Description
Sets or returns the background color or fill color of the objects. Note: The BackColor property is effective only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read/Write Read / Write

Example
' Mark the outstanding sales in red background Private Sub Detail_Format() If frameMain.panes.count > 3 then frameMain.BackColor = vbRed Else frameMain.BackStyle = ddBKTransparent End If End Sub

CanGrow

CanGrow (Frame)
Description
CanGrow property determines whether ActiveReports should increase the height of the frame based on its value. When set to False, ActiveReports clips the frame to fit within the control's predefined height. When set to True, ActiveReports increases the height of the controls and shift all controls below it to account for the increase in height. Note: The increase in height might cause the section height to increase. The section's CanGrow property should be set to True to avoid clipping the section.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() frameMain.CanGrow = False frameMain.CanShrink = False End Sub

CanShrink

ActiveReports 2.0 Standard User's Guide | 276

CanShrink (Frame)
Description
CanShrink property determines whether ActiveReports should decrease the height of the control based on the frame's content. When set to False, the frame will take the exact area defined by its preset coordinates. When set to True, ActiveReports will decrease the height of the frame to exactly fit the contents and shift the control below it upward to account for the decrease in height.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() frameMain.CanGrow = False frameMain.CanShrink = False End Sub

CloseBorder

CloseBorder (Frame)
Description
Set or returns whether or not the bottom border line will be displayed if the frame spans across multiple pages.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
FrameMain.CloseBorder = False

Panes

Panes (Frame)
Description
Returns a collection of the panes displayed on the frame.

Data Type
Panes

Availability

ActiveReports 2.0 Standard User's Guide | 277

Run time

Read / Write

Example
Private Sub Detail_Format() FrameMain.Panes(0).BackColor = vbRed FrameMain.Panes(0).BackStyle = 1 End Sub

ZOrder (Frame)

ZOrder (Frame)
Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Zorder should not be set after the ReportStart event has fired.

Return Type
None

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Position Type Integer Description Sets the position, front or back, for the control.

Settings
Value 0 1 Description Setting the ZOrder to 0 brings the control to the front. Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0 txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _ + txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle

ActiveReports 2.0 Standard User's Guide | 278


End Sub

Panes

Panes Collection
Pane Properties Pane Methods

Pane Properties

Pane Properties
Property BackColor BackStyle Border CloseBorder Data Type OLE_COLOR Integer Border Boolean Description Sets or returns the pane's background color or fill color. Sets or returns whether the pane is rendered in transparent (opaque) or normal mode. Set or returns the pane's border settings. Set or returns whether or not the bottom border line will be displayed if the pane spans across multiple pages. Returns a collection of controls displayed on the frame

Controls

PaneControls

BackColor

BackColor (Pane)
Description
Sets or returns the background color or fill color of the objects. Note: The BackColor property is effective only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time N/A Read / Write

Example
Private Sub Detail_Format() fAuto.Panes(0).BackColor = vbYellow fAuto.Panes(0).BackStyle = ddBKNormal End Sub

BackStyle

BackStyle

ActiveReports 2.0 Standard User's Guide | 279

Description
Sets or returns whether the pane is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the transparent areas of the new objects. The line in the illustration below is behind both objects. It shows through the transparent object, but the normal object overlays it.

Data Type
BackStyle

Availability
Design time Run time N/A Read / Write

Example
Private Sub Detail_Format() fAuto.Panes(0).BackColor = vbYellow fAuto.Panes(0).BackStyle = ddBKNormal End Sub

Border

Border
Description
Set or returns the pane's border settings.

Data Type
Border

Availability
Design time Run time N/A Read-Only

Example
Private Sub Detail_Format() fAuto.Panes(0).Border.BottomColor = vbRed fAuto.Panes(0).Border.BottomStyle = ddBLExtraThickSolid fAuto.Panes(0).Border.RightColor = vbRed fAuto.Panes(0).Border.RightStyle = ddBLThickSolid fAuto.Panes(0).Border.TopColor = vbBlue fAuto.Panes(0).Border.TopStyle = ddBLExtraThickSolid fAuto.Panes(0).Border.LeftColor = vbBlue fAuto.Panes(0).Border.LeftStyle = ddBLSolid fAuto.Panes(0).Border.Shadow = True End Sub

CloseBorder

ActiveReports 2.0 Standard User's Guide | 280

CloseBorder (Pane)
Description
Set or returns whether or not the bottom border line will be displayed if the pane spans across multiple pages.

Data Type
Boolean

Availability
Design time Run time N/A Read / Write

Example
Private Sub ActiveReport_ReportStart() FrameMain.CloseBorder = False FrameMain.Panes(0).CloseBorder = False End Sub

Controls

Controls (Pane)
Description
Returns a collection of controls on the pane

Data Type
PaneControls

Availability
Design time Run time N/A Read / Write

Pane Methods

Pane Methods
Method Add Description Adds a new pane to the panes collection. Sub Add(ParentName As String, Split As SplitTypes, [NewPaneName]) Count Returns the number of panes in the panes collection. Function Count() As Integer Item Returns a reference to the pane object at the specified collection. Function Item(Index As Integer) As Pane Remove Removes a pane from the panes collection. Sub Remove(Index)

Add

ActiveReports 2.0 Standard User's Guide | 281

Add (Pane)
Description
Adds a new pane to the panes collection.

Return Type
None

Syntax
Sub Add(ParentName As String, Split As SplitTypes, [NewPaneName])

Parameters
Name ParentName Split NewPaneName Type String SplitTypes String Description The parent pane's name. Indicates the type of split to use Name for the new pane

SplitType
Value 0 1 2 3 Mnemonic ddTopSplit ddBottomSplit ddLeftSplit ddRightSplit Description Places the splitter on top Places the splitter on the bottom Places the splitter on the left Places the splitter on the right

Example
Private Sub ActiveReport_ReportStart() FrameMain.Panes.Add "Pane0", ddLeftSplit, "Pane1" FrameMain.Panes.Add "Pane0", ddBottomSplit, "Pane2" End Sub

Count

Count (Pane)
Description
Returns the number of panes in the collection.

Return Type
Integer

Syntax
Function Count() As Integer

Parameters
None

Example
If FrameM.Panes.Count < 3 Then FrameM.Panes.Add "Pane0", ddRightSplit, "Pane" & _

ActiveReports 2.0 Standard User's Guide | 282


FrameM.Panes.Count End If

Item

Item (Pane)
Description
Returns a reference to the pane object at the specified index.

Return Type
Pane

Syntax
Function Item(Index As Integer) As Pane

Parameters
Name Index Type Integer Description Index of the pane to return

Example
Private Sub Detail_Format() FrameMain.Panes.Item(0).BackColor = vbRed FrameMain.Panes.Item(0).BackStyle = ddBKNormal End Sub

Remove

Remove (Pane)
Description
Removes a pane's object with the specified index.Return Type None

Syntax
Sub Remove(Index)

Parameters
Name Index Type Integer Description Index of the pane to remove

Example
If Ingredients = "" Then FrameMain.Panes.Remove 0 End If

Image Properties

ActiveReports 2.0 Standard User's Guide | 283

Image Properties
Property BackColor Data Type OLE_COLOR Description Sets or returns the background color of the object. This property is ignored if the BackStyle is set to transparent. Sets or returns the object transparency setting. Sets or returns the foreground color of the object. Sets or returns a hyperlink for an image. Once a hyperlink is set, users can follow the specified link by clicking on the image at run-time. Sets or returns the line color of the border around the object. Sets or returns the line style of the border around the object. Sets or returns the line thickness of the border around the object. Sets or returns the image object to be printed. Sets or returns the alignment of the picture within the object area. Sets or returns the sizing and clipping setting of the picture when the object dimensions change. Sets or returns the order, front or back, for the controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

BackStyle ForeColor Hyperlink

Integer OLE_COLOR String

LineColor LineStyle LineWeight Picture PictureAlignment SizeMode ZOrder

OLE_COLOR LineStyle Single StdPicture Integer Integer Integer

BackColor (Image)

BackColor (Image)
Description
Sets or returns the background color or fill color for the objects. Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

ActiveReports 2.0 Standard User's Guide | 284

BackStyle (Image)

BackStyle (Image)
Description
Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the new object's transparent areas. The line in the illustration below is behind both objects. However, it shows through the transparent object but not the normal object.

Data Type
BackStyle

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

ForeColor (Image)

ForeColor (Image)
Description
Sets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageHeader_Format() ' Paint a Red Confidential in the top-left corner ' of each page and change the totals to a red font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial"

ActiveReports 2.0 Standard User's Guide | 285


Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

hyperLink

hyperLink (Image)
Description
Sets or returns a hyperlink for the image. Once a hyperlink is set, users can follow the specified link by clicking on the image at run time. Note: The hyperlink can link to TOC entries, other reports, and any other properly formatted HTML links.

DataType
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Image1.Picture = _ LoadPicture(app.path & "\Logo.jpg") Image1.Hyperlink = _ "www.datadynamics.com" End Sub

LineColor

LineColor (Image)
Description
LineColor property sets or returns the pen color used to draw the shape's border.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
rptShows.imgPoster.LineWeight = 2 rptShows.imgPoster.LineStyle = ddLSSolid rptShows.imgPoster.LineColor = vbRed

LineStyle

ActiveReports 2.0 Standard User's Guide | 286

LineStyle (Image)
Description
LineStyle property sets or returns the pen style used to draw the shape's border.

Data Type
LineStyle

Settings
Value 0 1 2 3 4 5 Mnemonic ddLSTransparent ddLSSolid ddLSDash ddLSDot ddLSDashDot ddLDDashDotDot Description No line.

Availability
Design time Run time Read / Write Read / Write

Example
rptShows.imgPoster.LineWeight = 2 rptShows.imgPoster.LineStyle = ddLSSolid rptShows.imgPoster.LineColor = vbRed

LineWeight

LineWeight (Image)
Description
LineWeight property sets or returns the width of the image's border in line weight units (1lw=10 twips).

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

Example
rptShows.imgPoster.LineWeight = 2 rptShows.imgPoster.LineStyle = ddLSSolid rptShows.imgPoster.LineColor = vbRed

ActiveReports 2.0 Standard User's Guide | 287

Picture

Picture
Description
Picture property sets or return a picture handle displayed in the image control.

Data Type
StdPicture

Availability
Design time Run time Read / Write Read / Write

Example
rptShows.imgPoster.Picture = LoadPicture(app.path &"\Posters\LesMis.jpg")

PictureAlignment

PictureAlignment (Image)
Description
PictureAlignment property determines how the picture is displayed within the image drawing area.

Data Type
PictureAlignment

Settings
Value 0 1 2 3 4 Mnemonic ddPATopLeft ddPATopRight ddPACenter ddPABottomLeft ddPABottomRight Description Align the picture to the top left corner of the image control area. Align the picture to the top right corner of the image control area. Align the picture in the center of the image control area. Align the picture to the bottom left corner of the image control area. Align the picture to the bottom right corner of the image control area.

Availability
Design time Run time Read / Write Read / Write

Example
rptShows.imgPoster.PictureAlignment = ddPACenter

SizeMode

ActiveReports 2.0 Standard User's Guide | 288

SizeMode (Image)
Description
SizeMode property determines how the picture is sized to fit within the image area.

Data Type
SizeMode

Settings
Value 0 1 2 Mnemonic ddSMClip ddSMStretch ddSMZoom Description Displays the picture at its actual size. The picture is clipped (cut off) if it is larger than the controls defined area. Sizes the picture to fit the area of the control. Scales the image to either the height or width of the control to fit it within the specified area without distorting it.

Availability
Design time Run time Read / Write Read / Write

Example
RptShows.imgPoster.SizeMode = ddSMZoom

ZOrder (Image)

ZOrder (Image)
Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Zorder should not be set after the ReportStart event has fired.

Return Type
None

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Position Type Integer Description Sets the position, front or back, for the control.

Settings
Value 0 1 Description Setting the ZOrder to 0 brings the control to the front. Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0 txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub

ActiveReports 2.0 Standard User's Guide | 289

Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _ + txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle End Sub

Label Control Properties

Label Control Properties


Property Alignment Data Type TextAlignment Description Determines where the caption should be printed relative the left, center and right edges of the label. Sets or returns the angle (slope) of the printed value. 1 = 1/10 degree. Sets or returns the background fill color of the label. Sets or returns the transparency of the label. Sets the value to be printed. Sets or returns the controls global style. The global styles are specified in the styles dropdown window. Sets or returns the font properties used to print the value of the label. Sets the font color used to print the value of the label. Sets or returns a hyperlink for a label. Once a hyperlink is set, users can follow the specified link by clicking on the label at run-time. Determines whether the label prints as a single line or expands to multiple lines. Sets or returns a style string for a label. The style string can be used to specify a particular appearance for each label. Determines how the value should be printed relative to the top, middle, and bottom of the label. Sets or returns whether or not the label's caption will wrap. When WordWrap is set to False, "white-space:nowrap" will appear in the Style property window. If the label's caption is longer than the label's width, the text will be truncated. Sets or returns the order, front or back, for the

Angle BackColor BackStyle Caption ClassName

Integer OLE_COLOR Integer String String

Font ForeColor Hyperlink

StdFont OLE_COLOR String

Multiline Style

Boolean String

VerticalAlignment

VerticalTextAlignment

WordWrap

Boolean

ZOrder

Integer

ActiveReports 2.0 Standard User's Guide | 290

controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

Alignment

Alignment (Label)
Description
Alignment property determines where the caption should be printed relative to the left, center and right edges of the label area.

Data Type
TextAlignment

Settings
Value 0 1 2 Mnemonic ddTXLeft ddTXRight ddTXCenter Description Aligns the text to the left edge of the object area. Aligns the text to the right edge of the object area. Center the text horizontally within the object area.

Availability
Design time Run time Read / Write Read / Write

Example
rptInvestments.lblName.Alignment = ddTXRight

Angle

Angle
Description
Angle property sets or returns the angle (slope) of the printed value (1 = 1/10 degree).

Data Type
Integer

Availability
Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 291

Run time

Read / Write

Example
rptInvestments.lblIndex.Angle = 900

BackColor (Label)

BackColor (Label)
Description
Sets or returns the background color or fill color for the objects. Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

BackStyle (Label)

BackStyle (Label)
Description
Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the new object's transparent areas. The line in the illustration below is behind both objects. However, it shows through the transparent object but not the normal object.

Data Type
BackStyle

Availability
Design time Run time Read / Write Read / Write

Example

ActiveReports 2.0 Standard User's Guide | 292


' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

Caption

Caption (Label)
Description
Sets or returns the text string to be printed.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageFooter_Format() If Not dcRptData.Recordset.EOF Then lblContinued.Caption = "Continued" Else lblContinued.Caption = "" End If End Sub

ClassName

ClassName (Label)
Sets or returns the controls global style. The global styles are specified in the styles dropdown window.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() lblID.ClassName = "Heading2" End Sub

ActiveReports 2.0 Standard User's Guide | 293

Font (Label)

Font (Label)
Description
Sets or returns the font settings for a control or canvas object. The font property allows access to font name, size, styles, and effects. By using the Canvas object's font properties and draw methods, text can be written directly to the canvas.

Data Type
stdFont

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor (Label)

ForeColor (Label)
Description
Sets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageHeader_Format() ' Paint a Red Confidential in the top-left corner ' of each page and change the totals to a red font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial" Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

ActiveReports 2.0 Standard User's Guide | 294

hyperLink

hyperLink (Label)
Description
Sets or returns a hyperlink for the label. Once a hyperlink is set, users can follow the specified link by clicking on the label at run-time. Note: The hyperlink can link to TOC entries, other reports, and any other properly formatted HTML links.

DataType
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() lblLink.hyperLink = _ "ftp.datadynamics.com/activereports/samples" lblLink.Caption = "lblLink's Hyperlink is: " & _ lblLink.hyperLink End Sub

Multiline

Multiline (Label)
Description
Determines whether the contents of the label should wrap across multiple lines. When set to False, the label caption is limited to a single line regardless of its height.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
rptInvestments.lblDescription.MultiLine = True

Style

Style (Label)
Description
Sets or returns a style string for the specified label. The style string can be used to override a global style or set a particular style for the specified label.

ActiveReports 2.0 Standard User's Guide | 295 Note: If an invalid CSS style strings is used, the style string will be ignored.

DataType
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() 'If the balance isPositive is flse then the font 'is red and bold. If isPositive is true then the 'font is black and normal If isPositive = False Then lblBalance.Style = "font-family: SimSun; fontweight:bold; text-align: center; color: rgb(255,0,0)" ElseIf isPositive = True Then lblBalance.Style = "font-family: SimSun; fontweight: normal; text-align: center; color: rgb(0,0,0)" End If End Sub

VerticalAlignment

VerticalAlignment (Label)
Description
VerticalAlignment property determines where the caption should be printed relative to the top, middle and bottom edges of the label area.

Data Type
VerticalTextAlignment

Settings
Value 0 1 2 Mnemonic ddTXTop ddTXMiddle ddTXBottom Description Aligns the text to the top of the object area. Centers the text vertically within the object area. Align the text to the bottom of the object area.

Availability
Design time Run time Read / Write Read / Write

Example
rptPets.lblType.VerticalAlignment = ddTXBottom

WordWrap

ActiveReports 2.0 Standard User's Guide | 296

WordWrap (Label)
Description
Sets or returns whether or not the label's caption will wrap. When WordWrap is set to False, "whitespace:nowrap" will appear in the Style property window. If the caption is longer than the label, setting WordWrap to false will truncate the caption at the end of the label instead of the truncating the caption after the last full word. Note: When setting WordWrap to true, Multiline must also be set to true. Setting WordWrap to false will negate the Multiline property.

DataType
Boolean

Availability
Design time Run time Read/Write Read / Write

Example
Private Sub Detail_Format() Label1.WordWrap = False End Sub

ZOrder (Label)

ZOrder (Label)
Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Zorder should not be set after the ReportStart event has fired.

Return Type
None

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Position Type Integer Description Sets the position, front or back, for the control.

Settings
Value 0 1 Description Setting the ZOrder to 0 brings the control to the front. Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0

ActiveReports 2.0 Standard User's Guide | 297


txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _ + txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle End Sub

Line Properties

Line Properties
Property LineColor LineStyle LineWeight X1 X2 Y1 Y2 ZOrder Data Type OLE_COLOR LineStyle Single Single Single Single Single Integer Description Sets or returns the drawing color. Sets or returns the style color. Sets or returns the thickness of the line. Sets the horizontal coordinate of the line's starting point. Sets or returns the horizontal coordinate of the line's ending point. Sets or returns the vertical coordinate of the line's starting point. Sets or returns the vertical coordinate of the line's ending point. Sets or returns the order, front or back, for the controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

LineColor

LineColor (Line)
Description
LineColor property sets or returns the pen color used to draw the line.

Data Type
OLE_COLOR

Availability
Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 298

Run time

Read / Write

Example
rptBooks.lnLeft.LineColor = vbYellow rptBooks.lnLeft.LineStyle = ddLSDot

LineStyle

LineStyle (Line)
Description
LineStyle property sets or returns the pen style used to draw the line.

Data Type
LineStyle

Settings
Value 0 1 2 3 4 5 Mnemonic ddLSTransparent ddLSSolid ddLSDash ddLSDot ddLSDashDot ddLDDashDotDot Description No line.

Availability
Design time Run time Read / Write Read / Write

Example
rptBooks.lnLeft.LineColor = vbYellow rptBooks.lnLeft.LineStyle = ddLSDot rptBooks.lnLeft.LineWeight = 3

LineWeight

LineWeight (Line)
Description
LineWeight property sets or returns the width of the line in line weight units (1lw=10 twips).

Data Type
Integer

Availability
Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 299

Run time

Read / Write

Example
rptBooks.lnLeft.LineColor = vbYellow rptBooks.lnLeft.LineStyle = ddLSDot rptBooks.lnLeft.LineWeight = 3

X1

X1
Description
Sets or returns the horizontal coordinate of the line's starting point. The coordinates are relative to the section's top-left corner.

Data Type
Single

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() rptBooks.lnHz.X1 = 0 rptBooks.lnHz.X2 = Me.PrintWidth rptBooks.lnHz.Y1 = 500 rptBooks.lnHz.Y2 = 500 End Sub

X2

X2
Description
Sets or returns the horizontal coordinate of the line's ending point. The coordinates are relative to the section's top-left corner.

Data Type
Single

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() rptBooks.lnHz.X1 = 0 rptBooks.lnHz.X2 = Me.PrintWidth

ActiveReports 2.0 Standard User's Guide | 300


rptBooks.lnHz.Y1 = 500 rptBooks.lnHz.Y2 = 500 End Sub

Y1

Y1
Description
Sets or returns the vertical coordinate of the line's starting point. The coordinates are relative to the section's top-left corner.

Data Type
Single

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() rptBooks.lnHz.X1 = 0 rptBooks.lnHz.X2 = Me.PrintWidth rptBooks.lnHz.Y1 = 500 rptBooks.lnHz.Y2 = 500 End Sub

Y2

Y2
Description
Sets or returns the vertical coordinate of the line's ending point. The coordinates are relative to the section's top-left corner.

Data Type
Single

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() rptBooks.lnHz.X1 = 0 rptBooks.lnHz.X2 = Me.PrintWidth rptBooks.lnHz.Y1 = 500 rptBooks.lnHz.Y2 = 500 End Sub

ZOrder (Line)

ActiveReports 2.0 Standard User's Guide | 301

ZOrder (Line)
Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Zorder should not be set after the ReportStart event has fired.

Return Type
None

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Position Type Integer Description Sets the position, front or back, for the control.

Settings
Value 0 1 Description Setting the ZOrder to 0 brings the control to the front. Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0 txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _ + txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle End Sub

OLE Control

OLE
OLE Object Properties OLE Object Methods

ActiveReports 2.0 Standard User's Guide | 302

OLE Object Properties

OLE Object Properties


Property BackColor Data Type OLE_COLOR Description Sets or returns the background color of the object. This property is ignored if the BackStyle is set to transparent. Sets or returns the transparency of the object. Sets or returns the ProgID of the OLE object. Sets or returns an OLE object that is bound to the control. Sets or returns the alignment for the OLE object. Sets or Returns the size mode for the OLE object. Returns the number of verbs available for the ole object. Sets or returns the order, front or back, for the controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

BackStyle Class Object PictureAlignment SizeMode VerbCount ZOrder

Integer String Object PictureAlignment SizeMode Long Integer

BackColor (OLE)

BackColor (OLE)
Description
Sets or returns the background color or fill color for the objects. Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

BackStyle (OLE)

BackStyle (OLE)
Description

ActiveReports 2.0 Standard User's Guide | 303

Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the new object's transparent areas. The line in the illustration below is behind both objects. However, it shows through the transparent object but not the normal object.

Data Type
BackStyle

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

Class

Class
Description
Class property sets or returns the ProgID of the OLE object.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
OLE1.Class = "Word.Document.8"

Object

Object (OLE)
Description
Object property returns a reference to the OLE object instance that is bound to the control. You can use this property to set the object's properties or call its methods.

Data Type
Object

ActiveReports 2.0 Standard User's Guide | 304

Availability
Run time Read

Example
Private Sub ActiveReport_ReportStart() lblCaption.Caption = OLE1.object.Name End Sub

PictureAlignment

PictureAlignment (OLE)
Description
Sets or returns the type of positioning the OLE's object will have inside the OLE container. Note: If the object is the same size as the container, the PictureAlignment will be ignored.

Data Type
PictureAlignment

Settings
Value 0 1 2 3 4 Mnemonic ddPATopLeft ddPATopRight ddPACenter ddPABottomLeft ddPABottomRight Description Aligns the image to the top and left. Aligns the image to the top and right. Aligns the image to the center. Aligns the image to the bottom and left. Aligns the image to the bottom and right.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Centers the OLE object OLE1.PictureAlignment = ddPACenter ' Stretch the OLE object to fill the entire container OLE1.SizeMode = ddSMStretch End Sub

SizeMode

SizeMode (OLE)
Description
Determines how the OLE object will be sized inside the OLE container.

Data Type
SizeMode

ActiveReports 2.0 Standard User's Guide | 305

Settings
Value 0 1 2 Mnemonic DdSMClip (Default) ddSMStretch ddSMZoom Description Clips the image. Stretches the image to fill OLE Container. Zooms in on the image.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Centers the OLE object OLE1.PictureAlignment = ddPACenter 'Stretch the OLE object to fill the entire container OLE1.SizeMode = ddSMStretch End Sub

VerbCount

VerbCount
Description
Populates the verbs array and returns a verb count available for the OLE object. VerbCount must be called before accessing the other GetVerb methods.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub CheckVerbs() Dim sVName As String Dim vCnt, i OLE1.CreateEmbedded "c:\test.rtf" vCnt = OLE1.VerbCount For i = 0 To vCnt - 1 OLE1.GetVerbName i, sVName Debug.Print "VerbName = " & sVName Debug.Print "VerbID = " & OLE1.GetVerbID(i) Next OLE1.DoVerb 0 End Sub

ZOrder (OLE)

ZOrder (OLE)

ActiveReports 2.0 Standard User's Guide | 306

Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Zorder should not be set after the ReportStart event has fired.

Return Type
None

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Position Type Integer Description Sets the position, front or back, for the control.

Settings
Value 0 1 Description Setting the ZOrder to 0 brings the control to the front. Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0 txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _ + txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle End Sub

OLE Object Methods

OLE Object Methods


Method CreateEmbedded DoVerb GetUserType Description Created an embedded OLE object from a source document. Sub CreateEmbedded(FileName As String) Performs a specified action for the OLE object.Sub DoVerb(ID As Long) Returns the name of the specified OLE object's user type. Function

ActiveReports 2.0 Standard User's Guide | 307

GetUserType(Type As Integer) As String GetVerbID GetVerbName InsertObject Returns the ID for the specified verb.Function GetVerbID(Index As Long) As Long Returns the name of the specified verb. Sub GetVerbName(Index As Long, Name As String) Inserts an object into the OLE control.Sub InsertObject()

CreateEmbedded

CreateEmbedded
Description
Created an embedded OLE object from a source document.

Syntax
Sub CreateEmbedded(FileName As String)

Parameters
Name FileName Type String Description The name of the source document used as a template to create the embedded object.

Remarks
To create the new OLE type object, the program associated with the class name must be correctly installed and registered with the operating system. For instance, you can not create the word.document if the operating system does not recognize the class type because it is not found in the registry.

Example
Private Sub ActiveReport_ReportStart() ' OLE1 is an existing OLE control in the report OLE1.Class = "Word.Document.8" OLE1.CreateEmbedded App.Path & "\TestDocument.Doc" End Sub

DoVerb

DoVerb
Description
Opens an OLE object so an operation, such as edit or replace, can be performed.

Syntax
Sub DoVerb(ID As Long)

Parameters
Name ID Type Long Description The ID number for the verb to activate

Example

ActiveReports 2.0 Standard User's Guide | 308


Private Sub CheckVerbs() Dim sVName As String Dim vCnt, i> OLE1.CreateEmbedded "c:\test.rtf" vCnt = OLE1.VerbCount For i = 0 To vCnt - 1 OLE1.GetVerbName i, sVName Debug.Print "VerbName = " & sVName Debug.Print "VerbID = " & OLE1.GetVerbID(i) Next OLE1.DoVerb 0 End Sub

GetUserType

GetUserType
Description
Returns the name of the specified OLE object's user type.

Syntax
Sub GetUserType(Type As Integer)As String

Parameters
Name Type Type Integer Description Integer value specifying the type to return the name for.

GetVerbID

GetVerbID
Description
Returns the ID for the specified verb. Note: VerbCount must be called before using GetVerbID.

Syntax
Function GetVerbID(Index As Long) As Long

Parameters
Name Index Type Long Description Integer value indicating the index number of the verb.

Example
Private Sub CheckVerbs() Dim sVName As String Dim vCnt, i OLE1.CreateEmbedded "c:\test.rtf" vCnt = OLE1.VerbCount For i = 0 To vCnt - 1 OLE1.GetVerbName i, sVName Debug.Print "VerbName = " & sVName Debug.Print "VerbID = " & OLE1.GetVerbID(i) Next OLE1.DoVerb 0 End Sub

ActiveReports 2.0 Standard User's Guide | 309

GetVerbName

GetVerbName
Description
Returns the name of the specified verb. Note: VerbCount must be called before using GetVerbName.

Syntax
Sub GetVerbName(Index As Long, Name As String)

Parameters
Name Index Name Type Long String Description Integer value indicating the index number of the verb. String value indicating the name of the verb.

Example
Private Sub CheckVerbs() Dim sVName As String Dim vCnt, i OLE1.CreateEmbedded "c:\test.rtf" vCnt = OLE1.VerbCount For i = 0 To vCnt - 1 OLE1.GetVerbName i, sVName Debug.Print "VerbName = " & sVName Debug.Print "VerbID = " & OLE1.GetVerbID(i) Next OLE1.DoVerb 0 End Sub

InsertObject

InsertObject
Description
Causes the InsertObject dialog box to pop up so that the end user can insert an object into the OLE control.

Syntax
Sub InsertOjbect()

Example
Private Sub Detail_Format() Call OLE1.InsertObject End Sub

PageBreak Control Properties

PageBreak Control Properties

ActiveReports 2.0 Standard User's Guide | 310

Property Enabled

Data Type Boolean

Description Sets or returns whether or not the page break is activated

Enabled

Enabled (PageBreak)
Description
Sets or returns whether or not the PageBreak control will be activated on the current page.

DataType
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PageHeader_Format() Static x As Long x = x + 1 'Disables the page break for all but the first page If x > 1 Then Me.PageBreak1.Enabled = False End If End Sub

RTF Text Control

RTF
RTF Text Control Properties RTF Text Control Methods

RTF Text Control Properties

RTF Text Control Properties


Property BackStyle BulletIndent Data Type BackStyle Integer Description Sets or returns the transparency for the RichEdit control. Returns or sets the amount of indent used in a RichEdit control when SelBullet is set to True Determines whether the rich edit print area grows as needed to contain the text. Determines whether the rich edit print area shrinks to fit the contents of the RichEdit control. Returns the tab position at the specified index. Sets the maximum number of characters

CanGrow CanShrink

Boolean Boolean

GetTab MaxLength

Long Long

ActiveReports 2.0 Standard User's Guide | 311

allowed in the control. Multiline SelAlignment SelBold SelBullet SelCharOffset SelColor SelFontName SelFontSize SelHangingIndent SelIndent SelItalic SelLength SelProtected SelRightIndent SelStart SelStrikeThru SelTabCount SelTabs SelText SelTextBackColor SelUnderline Tag Text TextRTF ZOrder Boolean SelAlignmentConstants Variant Variant Variant OLE_COLOR String Long Long Long Variant Long Variant Long Long Variant Long Variant String OLE_COLOR Variant String String String Integer Determines whether the rich edit prints Multiline text or single line. Sets or returns the alignment of the current selection. Sets or returns the bold style setting of the current selection. Sets or returns the bulleted list style of the current selection. Sets or returns the character offset from the base line. Sets or returns the text color of the current selection. Sets or returns the font of the current selection. Sets or returns the point size of the current selection. Sets or returns the first line left margin within the current selection. Sets or returns the left margin of the current selection. Sets or returns the Italic style of the current selection. Sets or returns the number of characters in the current selection. Determines whether the current selection can be modified. Sets or returns the right margin of the current selection. Sets or returns the beginning position of the current selection. Sets or returns the strikethru style setting of the current selection. Sets or returns the number of tab stop position within the current selection. Sets or returns the tab positions within the current selection. Sets or returns the string of selected text. Sets or returns the background color of the selected text. Sets or returns the underline style of the current selection. Sets or returns a user defined value associated with the control. Returns the contents of the RichEdit control as a text string Sets or returns the RTF text of the RichEdit control. Sets or returns the order, front or back, for the controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

BackStyle

BackStyle (RTF)

ActiveReports 2.0 Standard User's Guide | 312

Description
Determines whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the transparent areas of the new objects. The line in the illustration below is behind both objects. It shows through the transparent object, but the normal object overlays it.

Data Type
BackStyle

Availability
Design time Run time Read/Write Read / Write

Example
' Sets the Richedit background to red Private Sub Detail_Format() If setColor = true then RichEdit1.BackStyle = ddBKNormal RichEdit1.BackColor = vbRed Else RichEdit1.BackStyle = ddBKTransparent End If End Sub

BulletIndent

BulletIndent
Description
Returns or sets the amount of indent used in a RichEdit control when SelBullet is set to True.

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

CanGrow

CanGrow (RTF)
Description
Determines whether the rich edit print area grows as needed to contain the text. When the control grows, the controls directly below it will be pushed downwards.

Data Type
Boolean

ActiveReports 2.0 Standard User's Guide | 313

Availability
Design time Run time Read / Write Read / Write

Example
Me.rtfRecalls.CanGrow = False Me.rtfEcalls.CanShrink = False

CanShrink

CanShrink (RTF)
Description
Determines whether the rich edit print area shrinks to fit the contents of the RichEdit control.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Me.rtfRecalls.CanGrow = False Me.rtfEcalls.CanShrink = False

GetTab

GetTab
Description
GetTab property returns the tab position setting at the specified index.

Data Type
Long

Availability
Design time Run time N/A Read-Only

MaxLength

MaxLength
Description
Specifies the maximum number of characters a user can enter in the control. The default for

ActiveReports 2.0 Standard User's Guide | 314 MaxLength is 0, indicating that the text is limited only by available system resources. Any number greater than 0 indicates the maximum number of characters.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Example
' Set the RTF MaxLength and Load the letter txtLetter.MaxLength = 2000 txtLetter.Text = _ dcRptData.RecordSet.Fields("LetterText").Value

Multiline

Multiline (RTF)
Description
Determines whether the RichEdit prints multiple lines or single line. When set to False the control is limited to single lines.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
rtfLetter.Multiline = True

SelAlignment

SelAlignment
Description
Returns or sets the selected text alignment. A value of 3 (rtfAlignmentNone) indicates that the selection spans paragraphs with different alignment settings.

Data Type
SelAlignmentConstantsselAlignmentConstants
Value 0 1 2 3 Mnemonic rtfLeft rtfRight rtfCenter rtfAlignmentNone Description Align left Align right Align center None

Availability

ActiveReports 2.0 Standard User's Guide | 315

Design time Run time

N/A Read / Write

Example
rtfLetter.SelAlignment = rtfLeft

SelBold

SelBold
Description
Sets or returns the font bold style of the currently selected text. A null value indicates that the current selection has mixed bold styles.

Data Type
Variant

Availability
Design time Run time N/A Read / Write

Example
rtfLetter.SelBold = True

SelBullet

SelBullet
Description
Sets or returns a value that specified whether the selected text has a bullet list style. A value of null indicates that the selection spans over text that has mixed bullet styles.

Data Type
Variant

Availability
Design time Run time N/A Read / Write

Example
rtfLetter.SelText = "Unit Price" & vbCRLF & "Cost" rtfLetter.SelBullet = True

SelCharOffset

SelCharOffset
Description
Sets or returns a value that specifies the offset of characters from the baseline: A positive integer prints the selected text as superscript above the baseline;

ActiveReports 2.0 Standard User's Guide | 316

A negative integer prints the text as subscript below the baseline; 0 value prints selected text on the baseline (normal) A Null value indicates mixed character offset setting within the selection.

Data Type
Variant

Availability
Design time Run time N/A Read / Write

Example
rtfLetter.SelText = "TM" rtfLetter.SelCharOffset = 10

SelColor

SelColor
Description
Sets or returns a value indicating the text ForeColor of the current selection. You can use RGB values or system color values. Returns Null if the selection ForeColor is mixed.

Data Type
Variant

Availability
Run time Read / Write

Example
rtfLetter.SelColor = vbRed rtfLetter.SelText = "$2000.00" rtfLetter.SelColor = vbBlack

SelFontName

SelFontName
Description
Sets or returns the font used to print the current text selection. Returns Null if the selection font is mixed.

Data Type
Variant

Availability
Run time Read / Write

Example

ActiveReports 2.0 Standard User's Guide | 317

rtfLetter.SelFontName = "Arial" rtfLetter.SelFontSize = 10 rtfLetter.SelBold = True

SelFontSize

SelFontSize
Description
Sets or returns an integer value specifying the font size of the current selection. Returns NULL if the selection contains mixed font sizes. The units are in Twips (1pt=20 Twips).

Data Type
Variant

Availability
Run time Read / Write

Example
rtfLetter.SelFontName = "Arial" rtfLetter.SelFontSize = 10 * 20 ' 10 pts rtfLetter.SelBold = True

SelHangingIndent

SelHangingIndent
Description
Sets or returns the distance between the left margin of the first line in the selected paragraph and the left margin indent of the following lines.

Data Type
Long

Availability
Run time Read / Write

Example
rtfLetter.SelIndent = 720 ' inch in twips rtfLetter.SelHangingIndent = 1440 ' 1 inch in twips rtfLetter.SelRightIndent = 720

SelIndent

SelIndent
Description
Sets or returns the left margin of the selected paragraph.

ActiveReports 2.0 Standard User's Guide | 318

Data Type
Long

Availability
Run time Read / Write

Example
rtfLetter.SelIndent = 720 ' inch in twips rtfLetter.SelHangingIndent = 1440 ' 1 inch in twips rtfLetter.SelRightIndent = 720

SelItalic

SelItalic
Description
Sets or returns the font Italic style of the currently selected text. A null value indicates that the current selection has mixed italic styles.

Data Type
Variant

Availability
Run time Read / Write

Example
rtfLetter.SelItalic = True

SelLength

SelLength
Description
Sets or returns the length (number of characters) of the current selection.

Data Type
Positive Long or 0

Availability
Run time Read / Write

Example
rtfLetter.SelStart = 10 rtfLetter.SelLength = Len(sMsg) rtfLetter.SelBold = True

SelProtected

ActiveReports 2.0 Standard User's Guide | 319

SelProtected
Description
Determines whether the characters in the current selection are protected (cannot be modified by the end user). A Null value indicated mixed protection settings within the selection.

Data Type
Variant

Availability
Run time Read / Write

Example
rtfLetter.SelLength = Len(sComapnyname) rtfLetter.SelProtected = True

SelRightIndent

SelRightIndent
Description
Sets or returns the distance from the right edge of the rich edit control and the right edge of the selected text.

Data Type
Long

Availability
Design time Run time N/A Read / Write

Example
rtfLetter.SelIndent = 720 ' inch in twips rtfLetter.SelHangingIndent = 1440 ' 1 inch in twips rtfLetter.SelRightIndent = 720

SelStart

SelStart
Description
Sets or returns the beginning position of the current selection or the insertion point. Valid values are 0 to the length of text in the control.

Data Type
Long

Availability

ActiveReports 2.0 Standard User's Guide | 320

Design time Run time

N/A Read / Write

Example
rtfLetter.SelStart = 10 rtfLetter.SelLength = Len(sMsg) rtfLetter.SelBold = True

SelStrikeThru

SelStrikeThru
Description
Sets or returns the font strikethru style of the currently selected text. A Null value indicates that the current selection has mixed strikethru styles.

Data Type
Variant

Availability
Design time Run time N/A Read / Write

Example
rtfLetter.SelStrikeThru = True

SelTabCount

SelTabCount
Description
Returns the number of tab stops within the current selection.

Data Type
Long

Availability
Run time Read / Write

SelTabs

SelTabs
Description
Returns the absolute tab position at the specified index.

Data Type
Integer

Availability

ActiveReports 2.0 Standard User's Guide | 321

Run time

Read / Write

Example
Dim arrTabs(5) As Integer arrTabs(0) = 5 arrTabs(1) = 10 arrTabs(2) = 15 arrTabs(3) = 20 arrTabs(4) = 25 arrTabs(5) = 30 rtfLetter.SelTabs = arrTabs

SelText

SelText
Description
Sets or returns the string of the current selected text. Returns an empty string if no text is selected.

Data Type
String

Availability
Run time Read / Write

Example
rtfLetter.SelColor = vbRed rtfLetter.SelText = "$2000.00" rtfLetter.SelColor = vbBlack

SelTextBackColor

SelTextBackColor
Description
Sets or returns the background color of the selected text. Returns Null when the selection background color is mixed.

Data Type
Variant

Availability
Run time Read / Write

Example
rtf.SetTextBackcolor = vbRed rtf.SelText = "ActiveReports"

SelUnderline

ActiveReports 2.0 Standard User's Guide | 322

SelUnderline
Description
Sets or returns the font underline style of the currently selected text. A Null value indicates that the current selection has mixed underline styles.

Data Type
Variant

Availability
Run time Read / Write

Example
rtfLetter.SelUnderline = False

Tag

Tag (RTF)
Description
Sets or returns a user defined value associated with the specified RTF control.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Text

Text (RTF)
Description
Sets or returns the RichEdit control's contents as a text string.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Me.RichEdit1.Text = "RichEdit Text"

TextRTF

TextRTF

ActiveReports 2.0 Standard User's Guide | 323

Description
Sets or returns the RTF contents of the RichEdit control as a text string.

Data Type
String

Availability
Design time Run time N/A Read / Write

Example
RichEdit1.TextRTF = "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}\viewkind4\uc1\pard\lang1033\f0\fs17 Rich Text\par }"

ZOrder (RTF)

ZOrder (RTF)
Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Zorder should not be set after the ReportStart event has fired.

Return Type
None

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Position Type Integer Description Sets the position, front or back, for the control.

Settings
Value 0 1 Description Setting the ZOrder to 0 brings the control to the front. Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0 txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _

ActiveReports 2.0 Standard User's Guide | 324


+ txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle End Sub

RTF Text Control Methods

RTF Text Control Methods


Method Clear Copy Cut DeleteField Description Clears the current selection. Sub Clear() Copies the current selection to the clipboard.Sub Copy() Cuts the current selection to the clipboard. Sub Cut() Deletes the field at the specified index.Sub DeleteField (szFieldName As String, nPos As Long, bDeleteAll As Boolean) As Boolean Finds a text string within the RTF text. Sub Find( szText As String, nStart As Long, nEnd As Long, fcType As FindConstants, pnEnd As Long) As Long Inserts a merge field at the specified position.Sub InsertField (szFieldName As String, nPos As Long) As Boolean Loads the contents of a file into the control. Sub LoadFile (szPathName As String, isFileType As LoadSaveConstants) Pastes the contents of the clipboard into the control at the current position.Sub Paste() Replaces a merge field with a value. Sub ReplaceField(bstrField As String, bstrValue As String) Stores the contents of the control to the specified file.Sub SaveFile (szPathName As String, isFileType As LoadSaveConstants) Selects a specified field in the RTF Content.Function SelectField (FieldName As String, Index As Long) As Boolean

Find

InsertField LoadFile Paste ReplaceField SaveFile SelectField

Clear

Clear (RTF)
Description
Clear method deletes the current selection.

Return Type
None

Syntax
Sub Clear()

Parameters
None

Copy

Copy

ActiveReports 2.0 Standard User's Guide | 325

Description
Copy method copies the current selection to the clipboard. The clipboard contents are set to RTF.

Return Type
None

Syntax
Sub Copy()

Parameters
None

Cut

Cut
Description
Cut method cuts (copies then deletes) the current selection to the clipboard. The clipboard contents are set to RTF.

Return Type
None

Syntax
Sub Cut()

Parameters
None

DeleteField

DeleteField
Description
DeleteField method deletes a merge field with the specified name at the specified position in the RTF stream. A field named FieldName must exist at the specified position. If a field is not found the method will return False.

Return Type
Boolean

Syntax
Sub DeleteField(szFieldName As String, nPos As Long, bDeleteAll As Boolean) As Boolean

Parameters
Name szFieldName NPos Type String Long Description Specifies the field name to be deleted. Specifies the position within the RTF stream where the field is located. A 1 value deletes all occurrences of the field within the stream. When set to True it deletes all occurrences of the field within the stream.

bDeleteAll

Boolean

Find

ActiveReports 2.0 Standard User's Guide | 326

Find (RTF)
Description
Find method searches the RTF stream for the first occurrence of the text string within the specified region.Return Type Long Start position of the search string within the text stream, -1 if the string is not found.

Syntax
Function Find(szText As String, nStart As Long, nEnd As Long, fcType As FindConstants, pnEnd As Long) As Long

Parameters
Name szText nStart nEnd fcType pnEnd Type String Long Long FindConstants Long Description Text string to search for. Starting position of the search range, -1 to start at the beginning of the RTF text stream. End position of the search range, -1 to stop at the end of the RTF text stream. Type of search, whole word, case sensitive, forward or backward search. Return value, position of the text string end within the stream.

InsertField

InsertField
Description
InsertField method inserts a new merge field into the RTF stream at the specified position. You can use the ReplaceField method to merge field values into the RTF stream.Return Type Boolean True, if the insertion is successful.

Syntax
Function InsertField(szFieldName As String, nPos As Long)As Boolean

Parameters
Name szFieldName nPos Type String Long Description Name of the field Field position within the text stream

Example
Private Sub ActiveReport_ReportStart() ' Set up the letter merge fields rtfLetter.InsertField("CustomerName", 0) rtfLetter.SetText = vbCRLF rtLetter.InsertField("Address", rtfLetter.SelStart) End Sub

LoadFile

LoadFile

ActiveReports 2.0 Standard User's Guide | 327

Description
LoadFile method loads an ASCII or RTF formatted text file into the control.

Return Type
None

Syntax
Sub LoadFile(szFileName As String, isFileType As LoadSaveConstants)

Parameters
Name FileName FileType Type String LoadSaveConstants Description Name of the input file. File format (RTF or ASCII)

Example
Private Sub ActiveReport_ReportStart() ' Load formatted letter from file rtfLetter.Load App.Path & "\LetterTemplate.RTF", rtfRTF End Sub

Paste

Paste
Description
Paste method pastes contents of the clipboard into the RTF stream at the current position.

Return Type
None

Syntax
Sub Paste()

Parameters
None

ReplaceField

ReplaceField
Description
ReplaceField merges the contents of the RTF stream with the field values specified. You can use this method to create mail merge RTF content in your report. The control will replace all occurrences of the field with the specified value.

Return Type
None

Syntax
Sub ReplaceField(bstrFiel As String, bstrValue As String)

Parameters
Name Type Description

ActiveReports 2.0 Standard User's Guide | 328

bstrField bstrFieldValue

String String

The name of the field to be replaced. The value used to replace the field name.

Example
Private Sub Detail_Format() ' Merge the letter fields in the RTF control rtfLetter.ReplaceField("CustomerName", txtCustomer.Text) End Sub

SaveFile

SaveFile
Description
SaveFile method saves the RTF text stream to the specified file name in ASCII or RTF format.

Return Type
None

Syntax
Sub SaveFile(szPathName As String, isFileType As LoadSaveConstants)

Parameters
Name szPathName IsFileType Type String LoadSaveConstants Description Name of the output file. File format ASCII or RTF

Example
Private Sub Detail_Format() rtfLetter.ReplaceField "CustomerName", _ dcRptData.Recordset.Fields("CustomerName").Value ' Replace merge fields ' Save the result to a file rtfLetter.Save App.Path & "\" & _ txtCustomerName.Text & ".RTF", 0 End Sub

SelectField

SelectField
Description
Selects a specified field in the RTF control.

Return Type
Boolean

Syntax
Function SelectField(FieldName As String, Index As Long) As Boolean

Parameters

ActiveReports 2.0 Standard User's Guide | 329

Name FieldName Index

Type String Long

Description Name of the field to select Index for the specified field.

Shape Control Properties

Shape Properties
Property BackColor Data Type OLE_COLOR Description Sets or returns the background color of the object. This property is ignored if the BackStyle is set to transparent. Sets or returns the transparency of the object. Sets or returns the line color of the border around the object. Sets or returns the line style of the border around the object. Sets or returns the line thickness of the border around the object. Sets or returns the shape type, ellipse, rectangle or rounded rectangle.

BackStyle LineColor LineStyle LineWeight Shape

BackStyle OLE_COLOR LineStyle Single ShapeType

BackColor (Shape)

BackColor (Shape)
Description
Sets or returns the background color or fill color for the objects. Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

BackStyle (Shape)

BackStyle (Shape)

ActiveReports 2.0 Standard User's Guide | 330

Description
Sets or returns whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the new object's transparent areas. The line in the illustration below is behind both objects. However, it shows through the transparent object but not the normal object.

Data Type
BackStyle

Availability
Design time Run time Read / Write Read / Write

Example
' Highlight the outstanding sales with a red background Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

LineColor

LineColor (Shape)
Description
LineColor property sets or returns the pen color used to draw the shape's border.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Shape1.Shape = ddSHRoundRect Shape1.LineColor = vbGreen Shape1.LineStyle = ddLSDashDotDot Shape1.LineWeight = 4 End Sub

LineStyle

ActiveReports 2.0 Standard User's Guide | 331

LineStyle (Shape)
Description
LineStyle property sets or returns the pen style used to draw the shape's border.

Data Type
LineStyle

Settings
Value 0 1 2 3 4 5 Mnemonic ddLSTransparent ddLSSolid ddLSDash ddLSDot ddLSDashDot ddLDDashDotDot Description No line

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Shape1.Shape = ddSHRoundRect Shape1.LineColor = vbGreen Shape1.LineStyle = ddLSDashDotDot Shape1.LineWeight = 4 End Sub

LineWeight

LineWeight (Shape)
Description
LineWeight property sets or returns the width of the shape's border in line weight units 1lw = 10 twips.

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Shape1.Shape = ddSHRoundRect Shape1.LineColor = vbGreen Shape1.LineStyle = ddLSDashDotDot

ActiveReports 2.0 Standard User's Guide | 332


Shape1.LineWeight = 4 End Sub

Shape

Shape
Description
Shape property determines the type of the shape to draw using the control.

Data Type
ShapeType

Settings
Value 0 1 2 Mnemonic ddSHRectangle ddSHEllipse ddSHRoundRectangle Description Rectangular shape Elliptical or circular shape Rectangular shape with rounded corners

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Shape1.Shape = ddSHRoundRect Shape1.LineColor = vbGreen Shape1.LineStyle = ddLSDashDotDot Shape1.LineWeight = 4 End Sub

SubReport Control Properties

Subreport Properties
Property CanGrow CanShrink DataField Object ReportName ZOrder Data Type Boolean Boolean String Object String Integer Description Determines whether the subreport print area grows as needed. Determines whether the subreport's print area shrinks to fit its contents. Sets or returns the name of the bound appended child recordset. Sets or returns a reference to the ActiveReport object to be used as a subreport. Sets or returns the name of the report object which is the source of the subreport. Sets or returns the order, front or back, for the controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

ActiveReports 2.0 Standard User's Guide | 333

CanGrow

CanGrow (SubReport)
Description
Determines whether the subreport print area grows as needed. When the subreport grows, the controls directly below it will be pushed downwards.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Set the subreport control's object to the sub report Set SubRpt.object = New rptOrders SubRpt.CanGrow = False SubRpt.CanShrink = False End Sub

CanShrink

CanShrink (SubReport)
Description
Determines whether the subreport's print area shrinks to fit its contents.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Set the subreport control's object to the sub report Set SubRpt.object = New rptOrders SubRpt.CanGrow = False SubRpt.CanShrink = False End Sub

DataField

DataField (SubReport)
Description

ActiveReports 2.0 Standard User's Guide | 334

When using shaped or hierarchical recordsets, DataField defines the source of data for the SubReport control to use. When the DataSource is set and the DataField property is set to a valid appended child group from the data source, ActiveReports binds the subreport to an appended child recordset. When using XML, setting the DataField property to a valid node list will also allow the subreport to bind to the child node list. Note: Setting the DataField property will only work with shaped and hierarchical recordsets, or a valid node list. Setting the DataField to a single field will not return any data.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_DataInitialize() 'Connects the report's datacontrol to the database de.cnnNWind.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & GetVBPath() & "\NWIND.MDB;Persist Security Info=False" de.rsCustomers.Open Set dc.Recordset = de.rsCustomers Set srpt.object = New rptOrders 'Sets subreport control datasource to the report's 'datacontrol(dc) srpt.DataSource = "dc" 'Sets the SubReport control's datafield to an 'appended child recordset srpt.DataField = "Orders" End Sub

Object

Object (SubReport)
Description
Sets or returns a reference to the ActiveReport object to be used as a subreport. The object should be set in the ReportStart event. Note: You must set this property to link your subreport to an instance of the child report.

Data Type
Object

Availability
Run time Read / Write

Example
Dim i_CID As String Private Sub ActiveReport_FetchData(EOF As Boolean) 'Gets the current records customer ID i_CID = me.DataControl1.Recordset!customerID End Sub Private Sub ActiveReport_ReportEnd()

ActiveReports 2.0 Standard User's Guide | 335


'Set the subreport control's object to nothing Unload SubRpt.object Set SubRpt.object = Nothing End Sub Private Sub ActiveReport_ReportStart() 'Set the subreport control's object to the sub report Set SubRpt.object = New rptOrders End Sub Private Sub Detail_Format() 'Sets the subreport's recordset for the new customer ID SubRpt.object.DataControl1.Source = "Select * from orders where customerid = '" & i_CID & "'" End Sub

ReportName

ReportName
Description
Sets or returns the name of the linked report object.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Set the subreport control's object to the sub report Set SubRpt.object = New rptOrders SubRpt.CanGrow = False SubRpt.CanShrink = False SubRpt.ReportName = "Customer Orders" End Sub

ZOrder (SubReport)

ZOrder (SubReport)
Description
This method determines the control's order, front or back, on the canvas. Changing the control's ZOrder allows controls to be positioned in front of or behind other controls. Zorder should not be set after the ReportStart event has fired.

Return Type
None

Syntax
Sub Zorder(Position As Integer)

Parameters
Name Type Description

ActiveReports 2.0 Standard User's Guide | 336

Position

Integer

Sets the position, front or back, for the control.

Settings
Value 0 1 Description Setting the ZOrder to 0 brings the control to the front. Setting the ZOrder to 1 sends the control to the back.

Example
Private Sub ActiveReport_ReportStart() txtHeadNote.ZOrder 0 txtEndNote.ZOrder 0 txtDescription.ZOrder 1 End Sub Private Sub Detail_BeforePrint() ' Positions the head note at the top ' of the description and brings it in ' front of the descripton txtHeadNote.Top = txtDescription.Top txtHeadNote.Left = txtDescription.Left txtHeadNote.Width = txtDescription.Width ' Positions the end note at the bottom ' of the description and brings it in ' front of the descripton txtEndNote.Top = (txtDescription.Top _ + txtDescription.Height) - txtEndNote.Height txtEndNote.Left = txtDescription.Left txtEndNote.Width = txtDescription.Width ' Sets the vertical alignment to middle and ' Positions the description behind the ' Head and End note text fields. txtDescription.VerticalAlignment = ddTXMiddle End Sub

Data Controls

Data Controls
ADO DAO RDO XML

ADO

ADO
ADO Data Control Properties ADO Data Control Methods

ADO Data Control Properties

ADO Data Control Properties


Property Data Type Description

ActiveReports 2.0 Standard User's Guide | 337

CommandTimeOut

Long

Sets or returns the period of time (in seconds) to wait for a command to execute before returning a timeout error. Sets or returns the ADO connection object associated with the data control. Sets or returns the string of parameters used to open the connection. Sets or returns the period of time (in seconds) to wait for a connection before terminating and returning an error. Sets or returns the location of the cursor that ActiveReports should created when creating the recordset Specifies the type of cursor that should be used when opening the recordset. Sets or returns the data source name for the connection. Sets or returns the name of the default database to use from the provider. Sets or returns the type of record locking to be used while reading from or writing to the data source.

Connection ConnectionString ConnectionTimeOut

Object String Long

CursorLocation

ADOCursorLocation

CursorType DataSourceName DefaultDatabase LockType

ADOCursorType String String Long

MaxRows

Long

Sets or returns the number of records to return from the record set for processing in the detail section.
Returns the number of records in the current recordset. Sets or returns the data source password. Sets or returns the name of the OLEDB provider for the data source. The Provider property is read/write when the connection is closed and read -only when it is open. Sets or returns a reference to the recordset object. Sets or returns the SQL source or table name for the recordset object. Sets the user id used to open the data source.

NRecords Password Provider

Long String String

RecordSet Source UserID

Object String String

CommandTimeOut

CommandTimeOut
Description
Sets or returns the period of time (in seconds) to wait for a command to execute before returning a timeout error.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Example

ActiveReports 2.0 Standard User's Guide | 338

Private Sub CreateReport() Dim rpt As New rptTemplate Dim ctl As Object ' Create an ADO Data data source control With rpt.Sections("Detail").Controls Set ctl = .Add("DDActiveReports2.DataControl") End With ctl.Provider = "MSDASQL" ctl.ConnectionString = "driver={SQL Server};" & _ ctl.Source = "SELECT * FROM RoySched" ctl.ConnectionTimeOut = 20 ctl.CommandTimeout = 20 ctl.MaxRows = 20 ctl.LockType = 0 ' ReadOnly ' Create Additional Controls ' Run and Preview the report output rpt.Show End Sub

Connection

Connection (ADO)
Description
Sets or returns the ADO connection object associated with the data control. The connection property allows you to share the ADO connection in your application with the report.

Data Type
Object

Availability
Run time Read / Write

Example
Dim rpt As New rptSales Set rpt.dc.Connection = cnnAppConnection RptSales.Show

ConnectionString

ConnectionString
Description
Sets or returns the string of parameters used to open the connection. ADO uses the following connection parameters:
Argument Provider= Data Source= User ID= Password= File Name= Remote Provider= Description Specifies the name of a provider to use for the connection. Specifies the name of a data source for the connection For example, a SQL Server database registered as an ODBC data source. Specifies the user name to use when opening the connection. Specifies the password to use when opening the connection. Specifies the name of a provider-specific file, such as a persisted data source object, containing preset connection information. Specifies the name of a provider to use when opening a client-side connection. (Remote Data Service only.)

ActiveReports 2.0 Standard User's Guide | 339

Remote Server=

Specifies the pathname of the sever to use when opening a client-side connection. (Remote Data Service only.)

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub CreateReport() Dim rpt As New rptTemplate Dim ctl As Object ' Create an ADO data source control With rpt.Sections("Detail") Set ctl = .CreateControl("DDActiveReports2.DataControl") End With ctl.Provider = "MSDASQL" ctl.ConnectionString = "driver={SQL Server};" & _ "Server=local;uid=sa;pwd=;database=pubs" ctl.Source = "SELECT * FROM RoySched" ctl.ConnectionTimeOut = 20 ctl.CommandTimeout = 20 ctl.MaxRows = 20 ctl.LockType = 0 ' ReadOnly ' Create Additional Controls ' Run and Preview the report output rpt.Show End Sub

ConnectionTimeOut

ConnectionTimeOut
Description
Sets or returns the period of time (in seconds) to wait for a connection before terminating and returning an error.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub CreateReport() Dim rpt As New rptTemplate Dim ctl As Object ' Create an ADO data source control With rpt.Sections("Detail").Controls Set ctl = .Add("DDActiveReports2.DataControl") End With ctl.Provider = "MSDASQL" ctl.ConnectionString = "driver={SQL Server};" & _ "Server=local;uid=sa;pwd=;database=pubs"

ActiveReports 2.0 Standard User's Guide | 340


ctl.Source = "SELECT * FROM RoySched" ctl.CommandTimeout = 20 ctl.MaxRows = 20 ctl.LockType = 0 ' ReadOnly ' Create Additional Controls ' Run and Preview the report output rpt.Show End Sub

CursorLocation

CursorLocation
Description
Sets or returns the location of the cursor that ActiveReports should created when creating the recordset. Setting the CursorLocation to ddADOUseClient allows you to disconnect the recordset and use client-side features such as Sort and Filter properties that are made available by some OLEDB providers.

Data Type
ADOCursorLocation

Settings
Value 2 3 Mnemonic ddADOUseServer ddADOUseClient Description Default - Creates a server-side cursor. Creates a client-side cursor, when supported by the provider.

Availability
Design time Run time Read / Write Read / Write**

Remarks
The CursorLocation is read/write when the recordset is closed and read-only when the recordset is open.

CursorType

CursorType
Description
The CursorType property specifies the type of cursor that should be used when opening the recordset.

Data Type
ADOCursorType

Settings
Value 0 1 2 3 Mnemonic ddADOOpenForwardOnly ddADOOpenKeyset ddADOOpenDynamic ddADOOpenStatic Description Default - Creates a forward-only cursor. Keyset cursor Dynamic Cursor Static cursor

ActiveReports 2.0 Standard User's Guide | 341

Availability
Design time Run time Read / Write Read / Write**

Remarks
The CursorType property is read/write when the recordset is closed and read-only when the recordset is open.

DataSourceName

DataSourceName (ADO)
Description
Sets or returns the data source name for the connection.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub RunReport() Dim sDSN As String ' Modify the report DSN to a DSN name from the registry sDSN = LoadDSNFromReg() If sDSN <> "" Then Load rptSales rptSales.dcRptData.DataSourceName = sDSN rptSales.Show End If End Sub

DefaultDatabase

DefaultDatabase
Description
Sets or returns the name of the default database to use from the provider.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

LockType

ActiveReports 2.0 Standard User's Guide | 342

LockType (ADO)
Description
Sets or returns the type of record locking to be used while reading from, or writing to, the data source.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

MaxRows

MaxRows
Description
Sets or returns the number of records to return from the record set for processing in the detail section. You can use this property to create Top n style reports. For example, you can create a sales query that returns sales results of all employees sorted in a descending order by the total sales amount. Set the MaxRows property to the number of top records you want to print. Note: Default value of 0 means all records.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Set the number of records returned by the query to 10 ' For Top 10 Report dcRptData.MaxRows = 10 End Sub

NRecords

NRecords
Description
Returns the number of records in the current recordset.

Data Type
Long

Availability
Design time N/A

ActiveReports 2.0 Standard User's Guide | 343

Run time

Read-Only

Password

Password (ADO)
Description
Sets or returns the data source password.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Set the user login properties before the report ' starts dcRptData.UserID = sUserID dcRptData.Password = sPassword End Sub

Provider

Provider
Description
Sets or returns the name of the OLEDB provider for the data source. The Provider property is read/write when the connection is closed and read -only when it is open.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Set the OLEDB provider name dcRptData.Provider = "MSDASQL" End Sub

RecordSet

Recordset (ADO)

ActiveReports 2.0 Standard User's Guide | 344

Description
Sets or returns a reference to the recordset object.

Data Type
Object

Availability
Run time Read / Write

Example
Private Sub PrintOrder(lOrderID As Long) Dim rs As Recordset ' Print a specific order based on a parameter sSQL = "SELECT * FROM Invoice WHERE OrderID = " & _ Str(lOrderID) Set rs = dbOrderSystem.OpenRecordset(sSQL) Load rptOrders ' Set the recordset property to our VB recordset Set rptOrders.dcRptData.Recordset = rs ' Print the report rptOrders.PrintReport End Sub

Source

Source
Description
Sets or returns the SQL source or table name for the recordset object.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
srptProducts.dcRptData.Source = sSQL srptProducts.dcRptData.Refresh

UserID

UserID
Description
Sets the user id used to open the data source.

Data Type
String

Availability

ActiveReports 2.0 Standard User's Guide | 345

Design time Run time

Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Set the user login properties before the report> ' starts dcRptData.UserID = sUserID dcRptData.Password = sPassword End Sub

ADO DB Data Control Methods

ADO Data Control Methods


Method Refresh Description Refreshes the data control's recordset. Sub Refresh()

Refresh

Refresh (ADO)
Description
Refresh method refreshes the data control's recordset. Use this method to update the recordset after modifying any of the connection or record source properties of your data control.

Return Value
None the recordset object property will be updated to contain the new results.

Syntax
Sub Refresh()

Parameters
None

Example
srptProducts.dcRptData.Source = sSQL srptProducts.dcRptData.Refresh

DAO

DAO
DAO Data Control Properties DAO Data Control Methods

DAO Data Control Properties

ActiveReports 2.0 Standard User's Guide | 346

DAO Data Control Properties


Property Connect DatabaseName DefaultCursorType Data Type String String DAOCursorType Description Sets or returns the connection string or type to the data source. Sets or returns the database name or path based on the Connect property setting. Sets or returns the type of cursor driver used to open the data source. This property is used with ODBCDirect data sources only. Determines the type of workspace used to open the data source. Determines whether the data source is opened in a single-user mode or a shared multi-user mode. Sets the number of rows to be returned from the recordset to be processed in the detail section. Sets or returns a value that defines the recordset object characteristics. See Visual Basic DAO documentation for more information about this property's settings. Sets or returns the password associated with the user name to open secure MS Access mdb files. Sets or returns a Recordset object from the data control. Sets or returns the type of the recordset that the data control will create from your data source. Sets or returns strings identifying the table name, querydef or SQL string that defines the record source of the data control. Sets or returns the name of the security setting mdw file. Sets or returns the user name to open secure MS Access mdb files.

DefaultType Exclusive

DAODefaultType Boolean

MaxRows

Long

Options

Long

Password

String

Recordset RecordsetType

Object DAORecordsetType

RecordSource

String

SystemDB UserName

String String

Connect

Connect (DAO)
Description
Connect property sets or returns the connection string or type of the data source. The connection string can be any of the ISAM file types supported by DAO, or set to ODBC;<ODBC connection string> for ODBC access. Note: To access locked mdb files, you should set the connect property to "Access;<pwd>"

Data Type
String

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 347

Example
' Connect to SQL Server using ODBC dcRptData.Connect = "ODBC;DSN=LocalServer;UID=sa;PWD=;"

DatabaseName

DatabaseName
Description
DatabaseName property sets or returns the database name or path based on the Connect property setting.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport1_ReportStart() ' Verify the location of the database dcRptData.DatabaseName = App.Path & "\appdb.mdb" End Sub

DefaultCursorType

DefaultCursorType
Description
DefaultCursorType sets or returns the type of cursor driver used to open the data source. This property is valid when the data source is ODBCDirect. It is ignored when the type is JET.

Data Type
DAOCursorType

Settings
Value 0 1 2 Mnemonic ddDAODefaultCursor ddDAOODBCCursor ddDAOServerSideCursor Description Let the ODBC driver select the cursor type. Use the ODBC driver client-side cursor. Let the server manage the cursor

Availability
Design time Run time Read / Write Read / Write

DefaultType

ActiveReports 2.0 Standard User's Guide | 348

DefaultType
Description
DefaultType determines the type of data source to be opened You can use the JET engine or ODBCDirect, which bypasses the JET and accesses RDO directly.

Data Type
DAODefaultType

Settings
Value 1 2 Mnemonic ddDAOUseODBC ddDAOUseJet Description Use ODBCDirect to bypass the JET engine and access RDO directly. Use the Microsoft JET to access your data source.

Availability
Design time Run time Read / Write Read / Write

Exclusive

Exclusive
Description
Exclusive property determines whether the data source recordset should be opened in an exclusive single-user mode or shared multi-user mode. In most cases, you would accept the default False setting.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

MaxRows

MaxRows
Description
Sets or returns the number of records to return from the record set for processing in the detail section. You can use this property to create Top n style reports. For example, you can create a sales query that returns sales results of all employees sorted in a descending order by the total sales amount. Set the MaxRows property to the number of top records you want to print. Note: Default value of 0 means all records.

Data Type
Long

Availability

ActiveReports 2.0 Standard User's Guide | 349

Design time Run time

Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Set the MaxRows to the top n records dcRptData.MaxRecords = nMaxRecords End Sub

Options

Options (DAO)
Description
Options property specifies one or more of the recordset object characteristics. You can combine settings using the "OR" operator.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Password

Password (DAO)
Description
Password property sets or returns the password string associated with the user name used to open secure mdb files. ActiveReports sets the DbEngine.DefaultPassword to this property before attempting to open the mdb file.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub RunPayrollReport() frmGetPassword.Show vbModal If sPwd <> "" Then ' Load the report Load rptPayroll rptPayroll.dcRptData.SystemDB = App.Path & _ "\Payroll.mdw" ' Set the password for the secure database rptPayroll.dcRptData.UserName = sUser rptPayroll.dcRptData.Password = sPwd ' Preview the report,

ActiveReports 2.0 Standard User's Guide | 350


' an error would occur if the password is invalid rptPayroll.Show End If End Sub

Recordset

Recordset (DAO)
Description
Recordset property sets or returns a reference to the open recordset object. You can use the recordset property to set your own created recordset object at run time.

Data Type
Object

Availability
Run time Read / Write

Example
Private Sub PrintOrder(lOrderID As Long) Dim rs As Recordset ' Print a specific order based on a parameter sSQL = "SELECT * FROM Invoice WHERE OrderID = " & _ Str(lOrderID) Set rs = dbOrderSystem.OpenRecordset(sSQL) Load rptOrders ' Set the recordset property to our VB recordset Set rptOrders.dcRptData.Recordset = rs ' Print the report rptOrders.PrintReport End Sub

RecordsetType

RecordsetType
Description
RecordsetType property determines the type of the open recordset.

Data Type
DAORecordsetType

Settings
Value 0 1 2 Mnemonic ddDAOTable ddDAODynaset ddDAOSnapshot Description Table type recordset object Dynaset type recordset object Snapshot type recordset object

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 351

RecordSource

RecordSource
Description
RecordSource property sets or returns the SQL RecordSource, table name or querydef name for the data control.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
' Modify the report record source based on user input sSQL = "SELECT * FROM Customers " sSQL = sSQL & "WHERE Region = '" & sState & "'" rptOrders.dcRptData.Recordsource = sSQL rptOrders.dcRptData.Refresh

SystemDB

SystemDB
Description
SystemDB property sets or returns the name of the security file (system.mdw) required to open secure database files. ActiveReports sets the DAO DbEngine.SystemDB property to the value of this property.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub RunPayrollReport() frmGetPassword.Show vbModal If sPwd <> "" Then ' Load the report Load rptPayroll ' Set the pathname to the security file rptPayroll.dcRptData.SystemDB = App.Path & _ "Payroll.mdw" ' Set the password for the secure database rptPayroll.dcRptData.UserName = sUser rptPayroll.dcRptData.Password = sPwd ' Preview the report, ' an error would occur if the password is invalid rptPayroll.Show

ActiveReports 2.0 Standard User's Guide | 352


End If End Sub

UserName

UserName (DAO)
Description
UserName sets or returns the user name used to open a secure database files. ActiveReports sets the DAO DbEngine.UserName property to the value of this property.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub RunPayrollReport() frmGetPassword.Show vbModal If sPwd <> "" Then ' Load the report Load rptPayroll ' Set the pathname to the security file rptPayroll.dcRptData.SystemDB = App.Path & _ "Payroll.mdw" ' Set the password for the secure database rptPayroll.dcRptData.UserName = sUser rptPayroll.dcRptData.Password = sPwd ' Preview the report, ' an error would occur if the password is invalid rptPayroll.Show End If End Sub

DAO Data Control Methods

DAO Data Control Methods


Method Refresh Description Refreshes the data control's recordset. Sub Refresh()

Refresh

Refresh (DAO)
Description
Refresh method refreshes the data control's recordset. Call this method after modifying any of the data control's connection and RecordSource properties.

Return Value

ActiveReports 2.0 Standard User's Guide | 353

None the recordset object property will be updated to contain the new results.

Syntax
Sub Refresh()

Parameters
None

Example
srptProducts.dcRptData.RecordSource = sSQL srptProducts.dcRptData.Refresh

RDO

RDO
RDO Data Control Properties RDO Data Control Methods

RDO Data Control Properties

RDO Data Control Properties


Property Connect Connection CursorDriver DataSourceName Environment ErrorThreshold KeysetSize LockType LoginTimeout LogMessages MaxRows Options Password Data Type String Object RDOCursorDriver String Object Long Long RDOLockType Long String Long Integer String Description The RDOConnection parameters string. A reference to the data control's underlying RDOConnection object. Specifies the type of cursor driver to be created. The name of the ODBC data source used in the connection. A reference to the control's RDOEnvironment object. The severity level value that constitutes a fatal error. Number of rows in the keyset buffer. The type of concurrent locking. Number of seconds to wait for a connection before a timeout error. Path of the ODBC trace log file. The maximum number of records to be returned from the query. Sets one or more of the resultset characteristics. The password used to create the RDOEnvironment object for the connection. Determines how the ODBC driver should prompt for missing connection parameters. Number of seconds to wait before a query timeout error occurs.

Prompt QueryTimeout

RDOPrompt Long

ActiveReports 2.0 Standard User's Guide | 354

Resultset ResultsetType RowsetSize SQL UserName Version

Object RDOResultSetType Long String String String

A reference to the RDOResultset object of the connection. Indicates the type of the open resultset, static or keyset. The number of rows in a resultset. The SQL statement that defines the query executed by the control. The user name used in the connection. The version of the data source associated with the connection.

Connect

Connect (RDO)
Description
Connect string sets the parameters for the RDO connection. Parameters are specified in the <parameter>=<value>; format. Valid parameters are:
Value DSN UID PWD DRIVER DATABASE SERVER WSID APP Description ODBC registered data source name. Recognized user of the database. Password associated with the user. Description of the ODBC driver. Used in DSN-less connections. Use brackets {} around descriptions containing spaces. Default database to use once connected. Name of remote server. The systems Net Name. Application's EXE name.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
' DSN-Less Connection dcRptData.Connection = "driver={SQL Server};" & _ "SERVER=bigsmile;UID=sa;PWD=pwd;database=pubs" ' DSN Connection dcRptData.LoginTimeout = 30 dcRptData.Connect = "DSN=Pubs;UID=sa;PWD=pwd;" ' Open a connection using a DSN and individual arguments ' instead of a connection string dcRptData.DataSourceName = "Pubs" dcRptData.UserName = "sa" dcRptData.Password = "pwd"

Connection

ActiveReports 2.0 Standard User's Guide | 355

Connection (RDO)
Description
Connection property sets or returns a reference to the connection object used by the RDO Data Control. You can use the property to modify connection settings at run time Or you can set it to your own connection from VB if your database connection is limited.

Data Type
Object

Availability
Run time Read / Write

Example
Private Sub RunReport(rpt As Object) ' Assign our already open connection to save on connection rpt.Connection = cnnOrderEnter rpt.Show End Sub

CursorDriver

CursorDriver
Description
Sets or returns the type of cursor to be created for the resultset.

Data Type
RDOCursorDriver

Settings
Value 0 1 2 3 4 Mnemonic ddRDOUseIfNeeded ddRDOUseODBC ddRDOUseServer ddRDOUseClientBatch ddRDOUseNone Description The ODBC Driver will choose the appropriate driver to use. Use the ODBC Driver cursor library. Use server side cursors. Use optimistic client-side cursor Recordset is not returned as a cursor.

Availability
Design time Run time Read / Write Read / Write

DataSourceName

DataSourceName (RDO)
Description
Sets or returns the ODBC registered data source name to connect to. This property can be left blank if you are setting the DSN in the Connect property.

ActiveReports 2.0 Standard User's Guide | 356

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() Dim sDSN As String sDSN = GetDSNFromRegistry() dcRptData.DataSourceName = sDSN End Sub

Environment

Environment
Description
Returns a reference to the RDOEnvironment object used by the RDO Data Control.

Data Type
Object

Availability
Run time Read / Write

ErrorTheshold

ErrorThreshold
Description
Sets or returns the severity level that constitutes a fatal error.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

KeysetSize

KeysetSize
Description
Sets or returns the number of records in the keyset buffer. The value should be greater than or equal to the RowsetSize property value.

Data Type

ActiveReports 2.0 Standard User's Guide | 357

Long

Availability
Design time Run time Read / Write Read / Write

LockType

LockType (RDO)
Description
Sets or returns the type of concurrency handling and record locking. You do not need to change the default of read-only cursor locking since the report is only reading the data for output.

Data Type
RDOLockType

Settings
Value 1 2 3 4 5 Mnemonic ddRDOConcurReadOnly ddRDOConcurLock ddRDOConcurRowVer ddRDOConcurValues ddRDOConcurBatch Description The recordset is read-only (not updateable) Pessimistic concurrency Optimistic concurrency (based on row id) Optimistic concurrency (based on row values) Optimistic concurrency using batch mode. A status is returned for each successful update.

Availability
Design time Run time Read / Write Read / Write

LoginTimeout

LoginTimeout
Description
Sets or returns the number of seconds to wait for establishing a connection before a timeout error.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

LogMessages

LogMessages
Description

ActiveReports 2.0 Standard User's Guide | 358

Sets or returns the name of the ODBC-trace log file.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

MaxRows

MaxRows
Description
Sets the maximum number of rows to return from the remote server.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Options

Options (RDO)
Description
Sets or returns the resultset characteristics flags.

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

Password

Password (RDO)
Description
Sets or returns the password associated with the user id used to connect to the data source.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 359

Example
Private Sub ActiveReport_ReportStart() ' Set the user name and password before ' openning the recordset dcRptData.UserName = gsUser dcRptData.Password = gdPassword End Sub

Prompt

Prompt (RDO)
Description
Determines how the ODBC driver should prompt for missing connection parameters.

Data Type
RDOPrompt

Settings
Value 0 Mnemonic ddRDODriverPrompt Description The driver manager displays the ODBC Data Sources dialog box. The connection string used to establish the connection is constructed from the data source name (DSN) selected and completed by the user via the dialog boxes. Or, if no DSN is chosen and the DataSourceName property is empty, the default DSN is used. The driver manager uses the connection string provided in connect. If sufficient information is not provided, the OpenConnection method returns a trappable error. If the connection string provided includes the DSN keyword, the driver manager uses the string as provided in connect. Otherwise, it behaves as it does when ddRDODriverPrompt is specified. Behaves like ddRDODriverComplete, except the driver disables the controls for any information not required to complete the connection.

ddRDODriverNoPrompt

ddRDODriverComplete

ddRDODriverCompleteRequired

Availability
Design time Run time Read / Write Read / Write

QueryTimeout

QueryTimeout
Description
Number of seconds to wait before a query timeout error occurs.

Data Type
Long

ActiveReports 2.0 Standard User's Guide | 360

Availability
Design time Run time Read / Write Read / Write

Resultset

Resultset
Description
Sets or returns a reference to the RDOResultset object of the connection.

Data Type
Object

Availability
Run time Read / Write

Example
Private Sub RunReport() Load rptProducts ' Set the report resultset to our VB RDO Resultset Set rptProducts.dcRptData.Resultset = rs ' Preview the report rptProducts.Show End Sub

ResultsetType

ResultsetType
Description
Sets or returns the type of the open resultset: static or keyset.

Data Type
RDOResultSetType

Settings
Value 1 3 Mnemonic DdRDOOpenKeySet DdRDOOpenStatic Description Creates a keyset resultset Creates a static resultset

Availability
Design time Run time Read / Write Read / Write

RowsetSize

RowsetSize

ActiveReports 2.0 Standard User's Guide | 361

Description
RowsetSize returns the number of rows in a resultset.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

SQL

SQL
Description
The SQL statement that defines the query executed by the control.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub PrintOrder(lOrderID As Long) Dim sSQL As String Load rptOrder sSQL = "SELECT * FROM orders " sSQL = sSQL & "WHERE OrderID = " & Str(lOrderID) ' Modify the SQL rptOrder.dcRptData.SQL = sSQL rptOrder.Show End Sub

UserName

UserName (RDO)
Description
The user name used in the connection.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example

ActiveReports 2.0 Standard User's Guide | 362

Private Sub ActiveReport_ReportStart() ' Set the user name and password before ' openning the recordset dcRptData.UserName = gsUser dcRptData.Password = gdPassword End Sub

Version

Version (RDO)
Description
The version of the data source associated with the connection.

Data Type
String

Availability
Design time Run time N/A Read / Write

RDO Data Control Methods

RDO Data Control Methods


Method Refresh Description Refreshes the data control's recordset. Sub Refresh()

Refresh

Refresh (RDO)
Description
Refreshes the data control's resultset.

Return Value
None the resultset object property will be updated to contain the new results.

Syntax
Sub Refresh()

Parameters
None

Example
Private Sub Detail_Format() srptProducts.dcRptData.SQL = "SELECT * FROM Products" & _ " WHERE CategoryID = " & txtCategoryID.Text srptProducts.dcRptData.Refresh End Sub

ActiveReports 2.0 Standard User's Guide | 363

XML

XML
XML Data Control Properties XML Data Control Methods

XML Data Control Properties

XML Data Control Properties


Property BOF Count CurrentPosition EOF FileURL NodeList RecordSetPattern ValidateOnParse Data Type Boolean Long Long Boolean String Variant String Boolean Description Returns whether or not the node is at the beginning of the nodelist. Sets or returns the XML RecordCount. Sets or returns the current position for the XML database. Returns whether or not the node is at the end of the nodelist. Sets or returns the file URL for the XLM database. Sets or returns the node list for the XML database. Sets or returns an XSL pattern to indicate which nodes the XML database will return. Sets or returns whether or not the XML database should validate the XML structure against a linked XML schema while it is being parsed.

BOF

BOF
Description
Returns whether or not the node is at the beginning of the nodelist.

Data Type
String

Availability
Design time Run time N/A Read Only

Example
If me.XMLDataControl.BOF and me.XMLDataControl.EOF then Exit sub End if

Count

ActiveReports 2.0 Standard User's Guide | 364

Count (XML)
Description
Returns the number of nodes selected by the XSLPattern specified in the RecordsetPattern property.

Data Type
String

Availability
Design time Run time N/A Read Only

Example
Private Sub ActiveReport_ReportStart() Dim recCount As Long recCount = XMLDataControl1.Count End Sub

CurrentPosition

CurrentPosition
Description
Returns the record number the XML database is currently using. Note: The first record in the database is at position 0.

Data Type
String

Availability
Design time Run time N/A Read Only

Example
lblDetailItem.Caption = xmlDC.CurrentPosition

EOF

EOF
Description
Returns whether or not the node is at the end of the nodelist.

Data Type
String

Availability
Design time N/A

ActiveReports 2.0 Standard User's Guide | 365

Run time

Read Only

Example
If me.XMLDataControl.BOF and me.XMLDataControl.EOF then Exit sub End if

FileURL

FileURL
Description
Sets or returns the XML DataControl's URL or file name of the XML document to which the report is connected.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_DataInitialize() If connectLocal = False Then XMLDataControl1.FileURL = _ "http://www.datadynamics.com/samples/ratings.xml" Else XMLDataControl1.FileURL = App.Path & _ "\purchaseorder.xml" End If End Sub

NodeList

NodeList
Description
Sets or returns a text stream containing the list of nodes that makes up the current XML recordset. The NodeList is based on the RecordSetPattern or can be set directly from an XML NodeList object. Note: This property returns a text stream rather than a NodeList object or an Object pointer.

Data Type
Variant Availability
Design time Run time N/A Read / Write

Example

ActiveReports 2.0 Standard User's Guide | 366


Private Sub Detail_Format() Dim itemReport As rptOrderItems Set itemReport = New rptOrderItems 'Set the node list for the subreport based off the main 'reports XML DataControl itemReport.XMLDataControl1.NodeList = _ Me.XMLDataControl1.Field("Manifest/Item", True) SubReport1.object = itemReport End Sub

RecordSetPattern

RecordSetPattern
Description
Sets or returns an XSL pattern to be used to retrieve the nodes (records) which the report will iterate through when the report is generated. The report uses each node selected in the RecordSetPattern to create a detail section. When using XML data control theDataField property represents an XPath pattern whose base path is the current node in the NodeList that the recordset pattern selects. For example, in the following XML document the XSL RecordSet pattern can be set to //ITEM to select all ITEM nodes in the XML document resulting in two records. <ORDER ID="12"> <ITEM ID="ITEM1">ActiveReports</ITEM> <ITEM ID="ITEM2">ActiveBar</ITEM> </ORDER> Note: XSL patterns are case sensitive and must use valid XSL syntax. XSL and XPath documentation can be found on MSDN at http://msdn.microsoft.com/library/default.asp?url=/library/enus/xmlsdk30/htm/xmrefxpathsyntax.asp

Typical XSL patterns


Pattern //* //ITEM / //LAYOUT/ITEM/* //ITEM[@type] //ITEM[@id="1"] Description All nodes All ITEM nodes Root item All child nodes of //LAYOUT/ITEM All item nodes that contain the type attribute All item nodes that have id attribute value of "1"

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_DataInitialize() XMLDataControl1.ValidateOnParse = True XMLDataControl1.FileURL = App.Path & _ "\purchaseorder.RPX"

ActiveReports 2.0 Standard User's Guide | 367


XMLDataControl1.RecordsetPattern = "Manifest/Item" End Sub

ValidateOnParse

ValidateOnParse
Description
Sets or returns whether or not the XML database should validate the XML structure against a linked XML schema while it is being parsed. If ValidateOnParse is false, only a properly formed XML databases can be used.

Data Type
String

Availability
Design time Run time N/A Read / Write

Example
Private Sub ActiveReport_DataInitialize() XMLDataControl1.ValidateOnParse = True XMLDataControl1.FileURL = App.Path & _ "\purchaseorder.XML" XMLDataControl1.RecordsetPattern = "Manifest/Item" End Sub

XML Data Control Methods

XML Data Control Methods


Method Field Description Returns the field specified from the XML database. When working with subreports, setting the asNodeList to true will allow for manual binding to the subreports XML DataControl. Function Field(Name As String, [asNodeList]) LoadXML Loads a XML data by using the indicated XML string. The XMLString can be an entire XML document or a correctly formed XML document section. Sub LoadXML(XMLString As Integer) MoveNext Moves the XML database up one record. Sub MoveNext() Reset Resets the XML database Sub Reset()

Field

Field
Description
Returns the field specified from the XML database. When working with subreports, setting the

ActiveReports 2.0 Standard User's Guide | 368 asNodeList to true will allow for manual binding to the subreports XML DataControl.

Return Type
None

Syntax
Function Field(Name As String,[AsNodeList])

Parameters
Name Name AsNodeList Type String Boolean Description Name of XML field Determines if the field will be used as a NodeList.

Example
Private Sub Detail_Format() Dim itemReport As rptOrderItems Set itemReport = New rptOrderItems itemReport.XMLDataControl1.NodeList = _ Me.XMLDataControl1.Field("Manifest/Item", True) SubReport1.object = itemReport End Sub

LoadXML

LoadXML
Description
Loads XML data by using the indicated XML string. The XMLString can be an entire XML document or a correctly formed XML document section.

Return Type
None

Syntax
Sub LoadXML(XMLString As Integer)

Parameters
Name XMLString Type String Description String indicating the XML file to load

Example
Private Sub ActiveReport_DataInitialize() XMLDataControl1.ValidateOnParse = True XMLDataControl1.RecordsetPattern = "//Customer" XMLDataControl1.LoadXML ("<Order>" & _ "<Customer>" & _ "<Name>John Doe</Name>" & _ Cardnum>131 131 131 131</Cardnum>" & _ "<Manifest>" & _ "<Item>" & _ "<ID>204</ID>" & _ "<Title>Advanced VB</Title>" & _ Quantity>1</Quantity>" & _ "<UnitPrice>$10.75</UnitPrice>" & _ "</Item>" & _ "</Manifest>" & _ "<Receipt>" & _

ActiveReports 2.0 Standard User's Guide | 369


"<Subtotal>$23.75</Subtotal>" & _ "<Tax>$2.43</Tax>" & _ "</Receipt>" & _ "</Customer>" & _ "</Order>") End Sub

MoveNext

MoveNext
Description
Moves to the next node in the nodelist.

Return Type
None

Syntax
Sub MoveNext()

Parameters
None

Reset

Reset
Description
Renews the XML database with the original settings or renews the nodelist selection based on new settings. Resetting the nodelist returns the CurrentPosition to the first recordset entry.

Return Type
None

Syntax
Sub Reset()

Parameters
None

History

History Object
History Properties History Methods

History Properties

History Properties
Property Count Position Data Type Integer Integer Description Returns the number of entries in the history stack. Returns the position of the current page in the history stack.

ActiveReports 2.0 Standard User's Guide | 370

Count

Count (History)
Description
Returns the number of entries in the navigation history stack.

Data Type
Integer

Availability
Run time Read

Example
' Command button implementations of a Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position >= btnForward.Enabled = (.Position End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position >= btnForward.Enabled = (.Position End With End Sub custom toolbar

0) < .Count)

0) < .Count)

Position

Position
Description
Returns the position of the current page in the navigation history stack.

Data Type
Integer

Availability
Run time Read

Example
' Command button implementations of a Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position >= btnForward.Enabled = (.Position End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position >= btnForward.Enabled = (.Position custom toolbar

0) < .Count)

0) < .Count)

ActiveReports 2.0 Standard User's Guide | 371


End With End Sub

History Methods

History Methods
Method Back Description Displays the previous page in the navigation history stack. Sub Back() Forward Displays the next page in the navigation history stack. Sub Forward() Item Returns the page at the selected index in the navigation history stack. Sub Item(index As Integer, PageNumber As Long)

Back

Back
Description
Displays the previous page in the navigation history stack.

Return Type
None

Syntax
Sub Back()

Parameters
None

Example
' Command button implementations of a Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position >= btnForward.Enabled = (.Position End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position >= btnForward.Enabled = (.Position End With End Sub custom toolbar

0) < .Count)

0) < .Count)

Forward

Forward
Description
Displays the next page in the navigation history stack.

ActiveReports 2.0 Standard User's Guide | 372

Return Type
None

Syntax
Sub Forward()

Parameters
None

Example
' Command button implementations of a Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position >= btnForward.Enabled = (.Position End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position >= btnForward.Enabled = (.Position End With End Sub custom toolbar

0) < .Count)

0) < .Count)

Item

Item (History)
Description
Returns the page number at the selected index in the navigation history stack.

Return Type
None

Syntax
Sub Item(Index As Integer, PageNumber As Long)

Parameters
Name Index PageNumber Type Integer Long Description Index of the navigation history entry. The returned page number at the specified index.

Example
Dim cIndex As Integer Dim pIndex As Integer Private Sub arv_TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long) pIndex = cIndex cIndex = cIndex + 1 End Sub Private Sub cmdOpenReport_Click() arv.ReportSource = New rptCustomers End Sub Private Sub cmdPrevTOC_Click() Dim pg As Long arv.TOC.History.Item pIndex, pg arv.TOC.GotoPage pg

ActiveReports 2.0 Standard User's Guide | 373


End Sub

Pages and PageSettings

Pages and PageSettings


PageSettings Properties Pages

PageSettings Properties

PageSettings Properties
Property BottomMargin Data Type Single Description Sets or returns the space between the bottom of the physical page and the bottom of the printing area. When printing multiple copies of a report, complete pages of each copy will be printed before the next copy starts printing. Sets or returns the type of duplex printing to be used. This property depends on the selected device. Not all printers support duplex printing. Sets or returns the extra space between the edge of the page and the page's margins. Sets or returns the space between the left edge of the physical page and the left edge of the printing area. Sets or returns whether the left page's margins will be mirrored on the right page. Determines whether a report prints vertically or horizontally. It defaults to the current setting of the printer in Windows Control Panel. PaperBin sets or returns the paper bin number from which the paper is fed. PaperHeight sets or returns the length of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection. PaperSize sets or returns the index in the PaperSizes collection of the currently selected standard paper size. PaperWidth sets or returns the width of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection. Sets or returns the space between the right edge of the physical page and the right edge of the printing area. Sets or returns the space between the top of the physical page and the top of the printing area.

Collate

prtCollate

Duplex

prtDuplex

Gutter

Single

LeftMargin

Single

MirrorMargins Orientation

Boolean prtOrientation

PaperBin PaperHeight

Integer Single

PaperSize

Integer

PaperWidth

Single

RightMargin

Single

TopMargin

Single

BottomMargin

ActiveReports 2.0 Standard User's Guide | 374

BottomMargin
Description
Sets or returns the space between the bottom of the physical page and the bottom of the printing area.

DataType
SingleDefault Value 1440 twips = 1 inch.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Sets a 1 inch bottom margin Me.PageSettings.BottomMargin = 1440 'Sets a 1 inch top margin Me.PageSettings.TopMargin = 1440 ' inch left margin Me.PageSettings.LeftMargin = 720 ' inch right margin Me.PageSettings.RightMargin = 720 End Sub

Collate

Collate (PageSettings)
Description
When printing multiple copies of the report, this property determines whether all the pages of the report should be printed before another copy of the report. Note: This property has no effect when printing a single copy of the report. The collate property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

DataType
PrtCollate

Settings
Value -1 0 Mnemonic COLLATE_PRINTERDEFAULT COLLATE_FALSE Description The report will use the setting selected on the default printer Multiple copies of a page will be printed followed by multiple copies of the following page. A complete copy of the report will be printed before another copy starts printing.

COLLATE_TRUE

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 375

Example
Private Sub ActiveReport_ReportStart() 'Prints all copies of a each page before moving to the next page Me.PageSettings.Collate = COLLATE_FALSE End Sub

Duplex

Duplex (PageSettings)
Description
Sets or returns the type of duplex action to use when printing out double sided reports. This property depends on the selected printer device because some printers are unable to support duplex printing. Note: The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type
prtDuplex

Settings
Value -1 1 2 3 Mnemonic ddDXPrinterDefault ddDXSimplex ddDXHorizontal ddDXVertical Description The report will use the default setting on the selected printer. Turns off duplex printing. Prints horizontally on both sides of the paper. Prints vertically on both sides of the paper.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Sets a report up to be bound like a book 'Turn on MirrorMargins Me.PageSettings.MirrorMargins = True 'Sets gutter to .5 in to allow for binding Me.PageSettings.Gutter = 720 'Set duplex to print vertically on both sides Me.PageSettings.Duplex = ddDXVertical End Sub

Gutter

Gutter
Description
Sets or returns the extra space between the page's edge and the page's margins. The gutter is used primarily for adding extra space for binding pages. Note: When using mirror margins, the gutter will apply to the left side of odd pages and the right side

ActiveReports 2.0 Standard User's Guide | 376 of even pages.

DataType
Single

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Sets a report up to be bound like a book 'Turn on MirrorMargins Me.PageSettings.MirrorMargins = True 'Sets gutter to .5 in to allow for binding Me.PageSettings.Gutter = 720 'Set duplex to print vertically on both sides Me.PageSettings.Duplex = ddDXVertical End Sub

LeftMargin

LeftMargin
Description
Sets or returns the space between the left edge of the physical page and the left edge of the printing area.

DataType
SingleDefault Value 1440 twips = 1 inch.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Sets a 1 inch bottom margin Me.PageSettings.BottomMargin = 1440 'Sets a 1 inch top margin Me.PageSettings.TopMargin = 1440 ' inch left margin Me.PageSettings.LeftMargin = 720 ' inch right margin Me.PageSettings.RightMargin = 720 End Sub

MirrorMargins

MirrorMargins
Sets or returns whether the left page's margins will be mirrored on the right page. Setting

ActiveReports 2.0 Standard User's Guide | 377 MirrorMargins to true forces inside margins for opposite pages to be the same width and outside margins for opposite pages to be the same width. Note: MirrorMargins can be used to set up reports for book style formatting.

DataType
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Sets a report up to be bound like a book 'Turn on MirrorMargins Me.PageSettings.MirrorMargins = True 'Sets gutter to .5 in to allow for binding Me.PageSettings.Gutter = 720 'Set duplex to print vertically on both sides Me.PageSettings.Duplex = ddDXVertical End Sub

Orientation

Orientation (PageSettings)
Description
Determines whether a report prints vertically or horizontally. It defaults to the current setting of the printer in Windows Control Panel. Note: The Orientation property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type
PrtOrientation

Settings
Value -1 1 2 Mnemonic ddODefault ddOPortrait ddOLandscape Description Uses printer's default orientation setting Print along the width of the paper. Print along the length of the paper.

Availability
Design time Run time Read / Write Read / Write

Example
' ActiveReports defaults to the current printer settings ' to change the default you need to set the orientation ' property in the ReportStart event Private Sub ActiveReport_ReportStart() me.PageSettings.Orientation = ddOLandscape End Sub

ActiveReports 2.0 Standard User's Guide | 378

PaperBin

PaperBin
Description
PaperBin sets or returns the paper bin number from which the paper is fed.

Data Type
Integer

Settings
Value 1 2 3 4 5 6 7 8 9 10 11 14 Description Use paper from the upper bin. Use paper from the lower bin. Use paper from the middle bin. Wait for manual insertion of each sheet of paper. Use envelopes from the envelope feeder. Use envelopes from feeder, but wait for manual insertion. (Default) Use paper from the current default bin. Use paper fed from the tractor feeder. Use paper from the small paper feeder. Use paper from the large paper bin. Use paper from the large capacity feeder. Use paper from the attached cassette cartridge.

Note: PaperBin values may very with individual printers. Check printer documentation for appropriate PaperBin.

Availability
Design time Run time Read / Write Read / Write

PaperHeight

PaperHeight (PageSettings)
Description
PaperHeight sets or returns the length of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection. Note: This property is used only when PaperSize is set to 256 Custom. The PaperHeight property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type
Single

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 379

Example
Private Sub ActiveReport_ReportStart() ' Specify a custom paper size Me.PageSettings.PaperSize = 256 ' Sets the paper's width to 2 inches Me.PageSettings.PaperWidth = 1440 * 2 ' Sets the paper's height to 4 inches Me.PageSettings.PaperHeight = 1440 * 4 End Sub

PaperSize

PaperSize
Description
PaperSize sets or returns the index in the PaperSizes collection of the currently selected standard paper size. Note: The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Settings
Value 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Description Letter, 8 1/2 x 11 in +A611Letter Small, 8 1/2 x 11 in Tabloid, 11 x 17 in Ledger, 17 x 11 in Legal, 8 1/2 x 14 in Statement, 5 1/2 x 8 1/2 in Executive, 7 1/2 x 10 1/2 in A3, 297 x 420 mm A4, 210 x 297 mm A4 Small, 210 x 297 mm A5, 148 x 210 mm B4, 250 x 354 mm B5, 182 x 257 mm Folio, 8 1/2 x 13 in Quarto, 215 x 275 mm 10 x 14 in 11 x 17 in Note, 8 1/2 x 11 in Envelope #9, 3 7/8 x 8 7/8 in Envelope #10, 4 1/8 x 9 1/2 in Envelope #11, 4 1/2 x 10 3/8 in Envelope #12, 4 1/2 x 11 in Envelope #14, 5 x 11 1/2 in C size sheet D size sheet

ActiveReports 2.0 Standard User's Guide | 380

26 27 29 30 28 31 32 33 34 35 36 37 38 39 40 41 255

E size sheet Envelope DL, 110 x 220 mm Envelope C3, 324 x 458 mm Envelope C4, 229 x 324 mm Envelope C5, 162 x 229 mm Envelope C6, 114 x 162 mm Envelope C65, 114 x 229 mm Envelope B4, 250 x 353 mm Envelope B5, 176 x 250 mm Envelope B6, 176 x 125 mm Envelope, 110 x 230 mm Envelope Monarch, 3 7/8 x 7 1/2 in Envelope, 3 5/8 x 6 1/2 in U.S. Standard Fanfold, 14 7/8 x 11 in German Standard Fanfold, 8 1/2 x 12 in German Legal Fanfold, 8 1/2 x 13 in User Defined

Note: ActiveReports will use the custom size of PaperHeight and PaperWidth when this property is set to 256. Note: Not all printers support the above PaperSizes. If the default printer does not support a specified size, the printer's default PaperSize will be used instead.

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub InitPaperSizes() Dim I As Integer For I = 0 To rptSummary.Printer.PaperSizes.Count 1 lstPaperSizes.AddItem rptSummary.Printer.PaperSizes(I) Next I End Sub Private Sub lstPaperSizes_DblClick() ' Set the paper size to the selected size rptSumamry.PageSettings.PaperSize = lstPaperSizes.ListIndex End Sub

PaperWidth

PaperWidth (PageSettings)
Description
PaperWidth sets or returns the width of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection. Note: This property is used only when PaperSize is set to 256 Custom. The Duplex property is

ActiveReports 2.0 Standard User's Guide | 381 common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type
Single

Availability
Design time Run time N/A Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Specify a custom paper size Me.PageSettings.PaperSize = 256 ' Sets the paper's width to 2 inches Me.PageSettings.PaperWidth = 1440 * 2 ' Sets the paper's height to 4 inches Me.PageSettings.PaperHeight = 1440 * 4 End Sub

RightMargin

RightMargin
Description
Sets or returns the space between the right edge of the physical page and the right edge of the printing area.

DataType
SingleDefault Value 1440 twips = 1 inch.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Sets a 1 inch bottom margin Me.PageSettings.BottomMargin = 1440 'Sets a 1 inch top margin Me.PageSettings.TopMargin = 1440 ' inch left margin Me.PageSettings.LeftMargin = 720 ' inch right margin Me.PageSettings.RightMargin = 720 End Sub

TopMargin

TopMargin
Description

ActiveReports 2.0 Standard User's Guide | 382

Sets or returns the space between the top of the physical page and the top of the printing area.

DataType
SingleDefault Value 1440 twips = 1 inch.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Sets a 1 inch bottom margin Me.PageSettings.BottomMargin = 1440 'Sets a 1 inch top margin Me.PageSettings.TopMargin = 1440 ' inch left margin Me.PageSettings.LeftMargin = 720 ' inch right margin Me.PageSettings.RightMargin = 720 End Sub

Pages

Pages Object
Pages Properties Pages Methods

Pages Properties

Pages Properties
Property Password Data Type String Description Sets or returns a case-sensitive password for saving or loading protected reports.

Note: Users should set this property prior to saving or loading a password-protected file.

Password

Password (Pages)
Description
Sets or returns a case-sensitive password for saving or loading protected reports. Note: The password should be set prior to saving or loading a password-protected file.

Data Type
String

Availability

ActiveReports 2.0 Standard User's Guide | 383

Run time

Read / Write

Example
Private Sub cmdLoadRDF_Click() ARViewer1.Pages.Password = "myPassword" ARViewer1.Pages.Load app.path & "\Password.RDF" End Sub Private Sub ActiveReport_ReportEnd() Me.Pages.Password = "myPassword"< Me.Pages.Save app.path & "\Password.RDF" End Sub

Pages Methods

Pages Methods
Method Add Description Adds a new blank canvas object to the collection. Sub Add() Commit Commits any pages collection modifications. Changes will be reflected in any open preview of window of the report. Sub Commit() Count Returns the number of page canvas objects in the collection. Function Count() As Long GetPagesInRange Returns a pages collection containing pages specified in the rangeString. Function GetPagesInRange(rangeString As String) As Pages Insert Inserts the specified canvas object before the specified index in the collection. Sub Insert(Index As Long, Canvas As Canvas) InsertNew Inserts a new canvas object before the specified index in the collection. Sub InsertNew(Index As Long) Item Returns the canvas object at the specified index. Function Item(Index As Long) As Canvas Load Loads a pages collection from a report data format (RDF) file. Pages can be saved using the Save method. Sub Load(FileName As String) Remove Removes the specified canvas from the report. Sub Remove(Index As Long) RemoveAll Save Removes all object from the collection.Sub RemoveAll() Save the report pages output to the specified file. Sub Save(FileName As String,[SaveOptions], [Vdata])

Add

Add (Pages)
Description

ActiveReports 2.0 Standard User's Guide | 384

Adds a new blank canvas object to the collection. The new canvas object can be accessed at the index Count 1.

Return Value
None

Syntax
Sub Add()

Parameters
None The new canvas object is added to the end of the collection.

Example
' Run the report to create the pages collection rptInvoice.Run ' Add a new page to the report rptInvoice.Pages.Add With rptInvoice.Pages(rptInvoice.Pages.Count-1) ' Print additional information about the report ' to the last page End With ' Display the report with the additional page rptInvoice.Show

Commit

Commit
Description
Commits the updates made to the a report's pages collection and causes any linked viewer control to refresh its pages cache. Whenever changes are made to the pages collection, such as adding or removing pages, the commit method should be called to refresh the pages collection with the new changes. Once the pages are committed, the report or viewer will contain the updated pages collection.

Return Value
None

Syntax
Sub Commit()

Parameters
None

Example
Private Sub ActiveReport_ReportEnd() Dim rpt As New arTOC Dim iPg As Integer Dim pg As Canvas 'Runs the arTOC report to generate the TOC Set rpt.PrintTOC = TOC rpt.Run ' Insert all the arTOC pages into the end of ' this report iPg = Me.Pages.Count For Each pg In rpt.Pages Pages.Insert iPg, pg iPg = iPg + 1 Next

ActiveReports 2.0 Standard User's Guide | 385


' Commit all changes to the pages collection Pages.Commit Unload rpt Set rpt = Nothing End Sub

Count

Count (Pages)
Description
Returns the number of objects in the collection.

Return Value
Long

Syntax
Function Count() As Long

Parameters
None

Example
For I = 0 to rpt.Pages.Count 1 Rpt.Pages(I).Overlay cv Next I

GetPagesInRange

GetPagesInRange
Description
Returns a Pages collection containing only the pages specified in the rangeString. The returned range can then be saved or exported. Note: The returned pages will be Read-Only since it is based on another pages collection. So the pages can only be save or exported.

Return Type
Pages

Syntax
Function GetPagesInRange(rangeString As String) As Pages

Parameters
Name rangeString Type String Description String value indicating the range of pages to be returned

Example
Private Sub ActiveReport_ReportEnd() Dim myPDFExport As ActiveReportsPDFExport.ARExportPDF Dim myPageRange As Pages Set myPDFExport = New _ ActiveReportsPDFExport.ARExportPDF

ActiveReports 2.0 Standard User's Guide | 386


Set myPageRange = _ Me.Pages.GetPagesInRange("1,3,5,7,9") myPDFExport.FileName = "C:\PDFExportRanges.PDF" myPDFExport.Export myPageRange End Sub

Insert

Insert (Pages)
Description
Adds the specified canvas object before the specified index in the collection.

Return Value
None

Syntax
Sub Insert(Index As Long, Canvas As Canvas)

Parameters
Name Index Canvas Type Long Canvas Description Index of the item to succeed the new object. A canvas object to be inserted into the collection.

Example
' Insert a FaxCover Page before the first page in the report rptInvoice.Pages.Insert 0, cvFaxCover

InsertNew

InsertNew
Description
Adds a new blank canvas object before the specified index in the collection.

Return Value
None

Syntax
Sub InsertNew(Index As Long)

Parameters
Name Index Type Long Description Index of the item to succeed the new object.

Example
' Insert a new page before the 5th page in the report rptInvoice.Pages.InsertNew 4

Item

ActiveReports 2.0 Standard User's Guide | 387

Item (Pages)
Description
Returns a reference to the canvas object at the specified index.

Return Value
Canvas

Syntax
Function Item(Index As Long) As Canvas

Parameters
Name Index Type Long Description Index of the requested canvas object.

Load

Load (Pages)
Description
Retrieves previously saved Pages collection.

Return Value
None

Syntax
Sub Load(FileName As String)

Parameters
Name FileName Type String Description Full path of the file to be loaded

Example
rptInvoice.Pages.Load App.Path & "\SavedReport.rdf" rptInvoice.Show

Remove

Remove (Pages)
Description
Removes the canvas object at the specified index in the collection.

Return Value
None The specified item is removed from the collection.

Syntax
Sub Remove(Index As Long)

Parameters

ActiveReports 2.0 Standard User's Guide | 388

Name Index

Type Long

Description Index of the canvas object to be removed from the collection.

Example
' Remove the first page of the report rptInvoice.Pages.Remove(0) rptInvoice.Pages.Commit

RemoveAll

RemoveAll (Pages)
Description
Removes all objects from the collection. Count returns 0.

Return Value
None All objects are removed from the collection.

Syntax
Sub RemoveAll()

Parameters
None

Example
' Clear the pages collection rptInvoice.Pages.RemoveAll rptInvoice.Pages.Commit ' Run the report again rptInvoice.Run

Save

Save (Pages)
Description
Saves the report pages output to the specified file. Saved files can be loaded and viewed or printed using the viewer control.

Return Value
None

Syntax
Sub Save(FileName As String, [SaveOptions],[Vdata])

Parameters
Name FileName SaveOptions Vdata Type String SaveOptionTypes Variant Description Full path of the file to be loaded. Indicates how the pages should be save. Returns the byte array when ByteArray is specified in

ActiveReports 2.0 Standard User's Guide | 389

the SaveOptions

Settings
Value 1 2 4 Description Compresses all pages Decompresses all pages and saves them Save to byte array

Example
' Run the invoice report to create the pages collection rptInvoice.Run ' Save the output to file rptInvoice.Pages.Save App.Path & "\Invoice.rdf"

PaperSizes Methods

PaperSizes Methods
Method Count Description Returns the number of available paper sizes. Function Count() As Integer Item Returns the paper size at the specified index. Function Item(Index As Variant) As String Name Sets or returns the description for the specified paper size. Function Name(Index) As String

Count

Count (PaperSizes)
Description
The count method returns the number of available standard paper sizes.

Return Type
Integer

Syntax
Function Count() As Integer

Parameters
None

Example
'Returns a list of PaperSize Names and Values 'supported by the assigned printer and adds them to a 'listbox control Private Sub cmdGetPaperSizes_Click() For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1 lstPaperSizes.AddItem "PaperSize Value = " & _ ActiveReport1.Printer.PaperSizes.Item(P) & _

ActiveReports 2.0 Standard User's Guide | 390


" PaperSize Name = " & _ ActiveReport1.Printer.PaperSizes.Name(P) Next P End Sub

Item

Item (PaperSizes)
Description
Item method returns a reference to the PaperSize string at the specified index.

Return Type
String

Syntax
Function Item(Index As Variant) As String

Parameters
Name Index Type Variant Description Index of the requested paper size.

Example
'Returns a list of PaperSize Names and Values 'supported by the assigned printer and adds them to a 'listbox control Private Sub cmdGetPaperSizes_Click() For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1 lstPaperSizes.AddItem "PaperSize Value = " & _ ActiveReport1.Printer.PaperSizes.Item(P) & _ " PaperSize Name = " & _ ActiveReport1.Printer.PaperSizes.Name(P) Next P End Sub

Name

Name (PaperSizes)
Description
Sets or returns a description for the specified paper size.

Return Type
String

Syntax
Function Name(Index As Variant) As String

Parameters
Name Index Type Variant Description Index for the requested paper size name.

Example

ActiveReports 2.0 Standard User's Guide | 391

'Returns a list of PaperSize Names and Values 'supported by the assigned printer and adds them to a 'listbox control Private Sub cmdGetPaperSizes_Click() For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1 lstPaperSizes.AddItem "PaperSize Value = " & _ ActiveReport1.Printer.PaperSizes.Item(P) & _ " PaperSize Name = " & _ ActiveReport1.Printer.PaperSizes.Name(P) Next P End Sub

Parameters

Parameters Collection
Parameter Properties Parameters Methods

Parameter Properties

Parameter Properties
Property Default Value Key Prompt Tag Value Data Type String String String Variant String Description Sets or returns a string expression containing the query parameter's default value. Sets or returns the query parameter's key (name). Sets or returns the string expression to be used as a prompt for the query parameter. Sets or returns custom data attached to the query parameter. Sets or Returns the string expression to be substituted in the query

DefaultValue

DefaultValue
Description
Sets or returns a string expression containing the query parameter's default value. Setting a default value will automatically fill in the value if none is specified.

Syntax
SELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data Type
String

Availability
Design time Run time N/A Read / Write

Example
Text1.Text = "select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995%

ActiveReports 2.0 Standard User's Guide | 392


># and OrderID><%OrderID|Order ID:|11000%>"

Key

Key
Description
Sets or returns the query parameter's key or name. The key is used to identify the parameter. Note: The Key is a required property.

Syntax
SELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data Type
String

Availability
Design time Run time N/A Read / Write

Example
Text1.Text = "select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995%># and OrderID><%OrderID|Order ID:|11000%>" Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim myprop As PropNode Dim i As Integer If Cancelled = True Then Me.Cancel Exit Sub End If Form1.EventListBox.Clear For i = 0 To Me.Parameters.Count - 1 Set myprop = New PropNode myprop.Name = Me.Parameters(i).Key myprop.Value = Me.Parameters(i).Value Form1.EventListBox.Properties.Add myprop Next End Sub

Prompt

Prompt (Parameters)
Description
Sets or returns the string expression to be used as a prompt for the query parameter. If no prompt is specified, the Key will be used to identify the parameter in the parameters dialog box.

Syntax
SELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data Type
String

Availability
Design time N/A

ActiveReports 2.0 Standard User's Guide | 393

Run time

Read / Write

Example
Text1.Text = "select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995% ># and OrderID><%OrderID|Order ID:|11000%>"

Tag

Tag (Parameters)
Description
Sets or returns custom data attached to the query parameter.

Data Type
Variant

Availability
Design time Run time N/a Read / Write

Example
Me.Parameters(0).Tag = "date" Me.Parameters(1).Tag = "string"

Value

Value (Parameters)
Description
Sets or Returns the string expression to be substituted in the query.

Data Type
String

Availability
Design time Run time N/a Read / Write

Example
Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim myprop As PropNode Dim i As Integer If Cancelled = True Then Me.Cancel Exit Sub End If Form1.EventListBox.Clear For i = 0 To Me.Parameters.Count - 1 Set myprop = New PropNode myprop.Name = Me.Parameters(i).Key myprop.Value = Me.Parameters(i).Value Form1.EventListBox.Properties.Add myprop Next

ActiveReports 2.0 Standard User's Guide | 394


End Sub

Parameters Methods

Parameters Methods
Method Count Description Returns the number of available query parameters. Function Count() As Integer Item Returns the query parameter for the specified index. Function Item(Index) As ARParameter

Count

Count (Parameters)
Description
Returns the number of available parameters in the query string.

Return Type
Integer

Syntax
Function Count() As Integer

Parameters
None

Example
Private Sub btnSetQuery_Click() myReport.DAODataControl1.RecordSource = Text1.Text PropList1.Clear For cnt = 0 To myReport.Parameters.Count - 1 PropList1.AddObject myReport.Parameters(cnt) If cnt = 0 Then PropList1.SelectObjects myReport.Parameters(0) End If Next btnRunReport.Enabled = True End Sub

Item

Item (Parameters)
Description
Returns the query parameter for the specified index.

Return Type
ARParameter

Syntax
Function Item(Index As Variant) As ARParameter

ActiveReports 2.0 Standard User's Guide | 395

Parameters
Name Index Type Variant Description Index for the requested parameter.

Example
Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim i As Integer If Cancelled = True Then Me.Cancel Exit Sub End If 'If data parameter is empty set the default date If Me.Parameters.Item(0).Value = "" Then Me.Parameters.Item(0).Value = "1/1/95" End If 'if orderID parameter is empty set the default to zero If Me.Parameters.Item(1).Value = "" Then Me.Parameters.Item(1).Value = "0" End If End Sub

Printer

Printer Object
Printer Properties Printer Methods

Printer Properties

Printer Properties
Property Collate ColorMode Copies DeviceCopies DeviceName Devices DisplayProgressDialog DPI Duplex FileName FromPage hDC MaxPage Data Type prtCollate Integer Integer Integer String String Array Boolean Long prtDuplex String Long Long Long Description When printing multiple copies of a report, complete pages of each copy will be printed before the next copy starts printing. Determines whether to force print in color or monochrome, this property dependent on the selected printer driver. Number of copies to print. Sets or returns the physical number of copies of the selected device. Name of the printer device driver. A string array of available device names. Determines whether the print progress dialog should be displayed while the report is printed. The printer resolution (Dots Per Inch) Sets or returns the type of duplex printing to be used. This property depends on the selected device. Not all printers support duplex printing. Sets/returns file name used to print to a file. If empty, ActiveReports prints to the printer. Specifies the first page to print. Returns a handle (from Microsoft Windows) to the printer's device context. Returns the total number of pages to be printed.

ActiveReports 2.0 Standard User's Guide | 396

NDevices NPorts Orientation PaperBinNames PaperBins PaperHeight

Long Long prtOrientation Variant Variant Long

The number of available printers. The number of available ports. Determines whether a report prints vertically or horizontally. It defaults to the current setting of the printer in Windows Control Panel. Returns a zero-based array of names of PaperBins supported by the current device. Returns an zero-based array of PaperBin codes supported by the current device. PaperHeight sets or returns the length of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection. A collection of available paper sizes. PaperWidth sets or returns the width of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection. Returns the current printer port name. A string array of available port names Determines the level of detail to use when printing. Returns the current job status. Specifies the last page to print from the collection. Specifies whether device changes will modify Windows default printer. Number of twips for each printer pixel horizontally. Number of twips for each printer pixel vertically.

PaperSizes PaperWidth

PaperSizes Long

Port Ports PrintQuality Status ToPage TrackDefault TwipsPerPixelX TwipsPerPixelY

String String Array Long JobStatus Long Boolean Single Single

Collate (Printer)

Collate (Printer)
Description
When printing multiple copies of the report, this property determines whether all the pages of the report should be printed before another copy of the report. Note: This property has no effect when printing a single copy of the report. The collate property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

DataType
PrtCollate

Settings
Value -1 0 Mnemonic COLLATE_PRINTERDEFAULT COLLATE_FALSE Description The report will use the setting selected on the default printer Multiple copies of a page will be printed followed by multiple copies of the following page. A complete copy of the report will be printed before another copy starts printing.

COLLATE_TRUE

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 397

Example
Private Sub ActiveReport_ReportStart() 'Prints all copies of a each page before moving to the next page Me.PageSettings.Collate = COLLATE_FALSE End Sub

ColorMode

ColorMode
Description
ColorMode determines whether to force printing to a color printer in color or monochrome. This property is dependent on whether the selected printer driver supports color printing.

Data Type
Integer

Settings
Value 1 2 Description Print in Monochrome Print in Color

Availability
Design time Run time N/A Read / Write

Example
rptInvoice.Printer.ColorMode=2

Copies

Copies
Description
Sets or returns the number of report copies to print. This is a logical number of copies that ActiveReports manages. If the printer does not support automatic multiple copies, ActiveReports will attempt to generate the copies by sending the report pages twice to the selected device.

Data Type
Integer

Availability
Design time Run time N/A Read / Write

Example
rptInvoice.Printer.Copies = 2

DeviceCopies

ActiveReports 2.0 Standard User's Guide | 398

DeviceCopies
Description
Sets or returns the physical printer driver's default number of copies when TrackDefault = True. This property works only with certain print drivers that support multiple copy printing such as the Adobe PDFWriter. DeviceCopies is the copy value that the printer device uses or defaults to; Copies is the copy value which is set and used in the print dialog. ActiveReports will always set the DeviceCopies to 1, and use the Copies value, either telling the printer to print the same page this number of times, or to re-send the same page this number of times to the printer. Note: For printing purposes, you would normally use Printer.Copies rather than Printer.DeviceCopies.

Data Type
Integer

Availability
Design time Run time N/A Read / Write

Example
rptInvoice.Printer.DeviceCopies = 2

DeviceName

DeviceName
Description
Sets or returns the unique name of the currently selected printer device. A list of valid printer device names is enumerated in the Devices string array property. Note: You can set the DeviceName property to an empty string "" to enable a virtual printer mode where all properties and print methods will not make any printer calls. This is useful when your reports are compiled as ASP Active Server DLLs. The report will be formatted according to the printer properties you set whether there is a printer connected or not.

Data Type
String

Availability
Design time Run time N/A Read / Write

Example
Debug.Print rptInvoice.Printer.DeviceName

Devices

Devices
Description
A zero-based string array property that enumerates all the available printer devices. You can use this property to display a list of the devices for the report print destination from which the user can select.

ActiveReports 2.0 Standard User's Guide | 399

Data Type
Array of Strings

Availability
Design time Run time N/A Read-Only

Example
' Fill a listbox with the available print devices For i = 0 to NDevices 1 lstDevices.AddItem Devices(i) Next i

DisplayProgressDialog

DisplayProgressDialog
Description
Determines whether the print progress dialog should be displayed while the report is printing.

Data Type
Boolean Default is True

Availability
Design time Run time N/A Read / Write

Example
rptInvoice.PrintReport False rptInvoice.Printer.DisplayProgressDialog = False

DPI

DPI
Description
DPI returns the resolution of the currently selected printer device. Note: DPI is the number of Dots Per Inch.

Data Type
Long

Availability
Design time Run time N/A Read

Duplex (Printer)

ActiveReports 2.0 Standard User's Guide | 400

Duplex (Printer)
Description
Sets or returns the type of duplex action to use when printing out double sided reports. This property depends on the selected printer device because some printers are unable to support duplex printing. Note: The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type
prtDuplex

Settings
Value -1 1 2 3 Mnemonic ddDXPrinterDefault ddDXSimplex ddDXHorizontal ddDXVertical Description The report will use the default setting on the selected printer. Turns off duplex printing. Prints horizontally on both sides of the paper. Prints vertically on both sides of the paper.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() 'Sets a report up to be bound like a book 'Turn on MirrorMargins Me.PageSettings.MirrorMargins = True 'Sets gutter to .5 in to allow for binding Me.PageSettings.Gutter = 720 'Set duplex to print vertically on both sides Me.PageSettings.Duplex = ddDXVertical End Sub

FileName

FileName
Description
Sets or returns file name used to print to a file. If empty, ActiveReports prints to the printer.

Data Type
String

Availability
Run time Read / Write

Example
rptSales.Printer.FileName = "C:\temp\sales.prn"

ActiveReports 2.0 Standard User's Guide | 401


rptSales.PrintReport False

FromPage

FromPage
Description
Sets the starting page in a print job. Note: A. When a report runs to completion, it will set the FromPage to 1 and ToPage to number of pages in the report. B. If you set FromPage and ToPage to 0 , the print dialog will disable the pages radio button and select "All Pages". C. If you set FromPage -1 and ToPage to -1, the selection radio is selected which means, print currently visible page. When report is not visible, this will print the first page. D. On return from PrintDialog method or PrintReport method FromPage and ToPage are set to the user selected values in the dialog.

Data Type
Long

Availability
Design time Run time N/A Read / Write

Example
rptSales.Printer.FromPage = 1 rptSales.Printer.ToPage = 1 rptSales.PrintReport

hDC

hDC
Description
Returns a handle (from Microsoft Windows) to the printer's device context. This property is valid only after a print job has been started. It allows you to control the device using Windows API functions.

Data Type
Long

Availability
Run time Read

MaxPage

MaxPage
Description
MaxPage is used to properly set the total page count in the progress dialog when doing custom printing. For example, you can merge multiple reports and print them in a single job. ActiveReports

ActiveReports 2.0 Standard User's Guide | 402 will not know the total number of pages coming into the job. You need to set MaxPage so that the progress dialog will display the "n of m pages" message properly. When printing a single report automatically, you do not need to set MaxPage since ActiveReports will set it to the number of pages in the report.

Data Type
Long

Availability
Design time Run time N/A Read / Write

Example
rptSummary.Printer.StartJob ' Merge the two reports together rptSummary.Printer.MaxPage = rptSummary.Pages.Count + _ rptSales.Pages.Count ' Print the summary report For Each pg In rptSummary.Pages rptSummary.Printer.PrintPage pg Next ' Print the sales detail report For Each pg In rptSales.Pages rptSummary.Printer.PrintPage pg Next ' Close the job rptSummary.Printer.EndJob

NDevices

NDevices
Description
NDevices returns the number of available printer devices. The printer device names are enumerated in the Devices property.

Data Type
Long

Availability
Design time Run time N/A Read-Only

Example
' Fill a listbox with the available print devices For i = 0 to NDevices 1 lstDevices.AddItem Devices(i) Next i

NPorts

NPorts

ActiveReports 2.0 Standard User's Guide | 403

Description
NPorts property returns the number of printer ports available (the ports to which the current device is attached). For example, if the current printer is attached to both LPT1: and FILE:, then NPorts returns 2. Available ports are enumerated in the Ports property.

Data Type
Long

Availability
Design time Run time N/A Read-Only

Example
' Fill a listbox with the available printer ports For i = 0 to NPorts 1 lstPorts.AddItem Ports(i) Next i

Orientation (Printer)

Orientation (Printer)
Description
Determines whether a report prints vertically or horizontally. It defaults to the current setting of the printer in Windows Control Panel. Note: The Orientation property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type
PrtOrientation

Settings
Value -1 1 2 Mnemonic ddODefault ddOPortrait ddOLandscape Description Uses printer's default orientation setting Print along the width of the paper. Print along the length of the paper.

Availability
Design time Run time Read / Write Read / Write

Example
' ActiveReports defaults to the current printer settings ' to change the default you need to set the orientation ' property in the ReportStart event Private Sub ActiveReport_ReportStart() me.PageSettings.Orientation = ddOLandscape End Sub

ActiveReports 2.0 Standard User's Guide | 404

PaperBinNames

PaperBinNames
Description
Returns a zero-based array of names of PaperBins supported by the current device.

Data Type
Variant (Array of Strings)

Availability
Design time Run time N/A Read

Example
' Fill a listbox (lstPaperBins and lstPaperBinNames) ' with paperbin codes and paperbin names Dim i As Integer With ActiveReport1.Printer For i = 0 To Ubound(.PaperBins) lstPaperBins.AddItem .PaperBins(i) Next For I = 0 To Ubound(.PaperBinNames) lstPaperBinNames.AddItem .PaperBinName(i) Next End With

PaperBins

PaperBins
Description
Returns a zero-based array of PaperBin codes supported by the current device. Note: Use this array to get the valid codes for the PaperBin property. Many printer drivers do not support the table of codes listed in PaperBin. Instead, they define their own codes, making the standard codes invalid as a setting to that property.

Data Type
Variant (Array of Integers)

Availability
Design time Run time N/A Read

Example
' Fill a listbox (lstPaperBins and lstPaperBinNames) ' with paperbin codes and paperbin names Dim i As Integer With ActiveReport1.Printer For i = 0 To Ubound(.PaperBins) lstPaperBins.AddItem .PaperBins(i) Next For I = 0 To Ubound(.PaperBinNames)

ActiveReports 2.0 Standard User's Guide | 405


lstPaperBinNames.AddItem .PaperBinName(i) Next End With

PaperHeight (Printer)

PaperHeight (Printer)
Description
PaperHeight sets or returns the length of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection. Note: This property is used only when PaperSize is set to 256 Custom. The PaperHeight property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type
Single

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Specify a custom paper size Me.PageSettings.PaperSize = 256 ' Sets the paper's width to 2 inches Me.PageSettings.PaperWidth = 1440 * 2 ' Sets the paper's height to 4 inches Me.PageSettings.PaperHeight = 1440 * 4 End Sub

PaperSizes

PaperSizes
Description
Returns a reference to the collection of paper sizes the currently selected printer supports.

Data Type
PaperSizes

Availability
Design time Run time N/A Read / Write

Example
Private Sub InitPaperSizes() Dim I As Integer For I = 0 To rptSummary.Printer.PaperSizes.Count 1 lstPaperSizes.AddItem rptSummary.Printer.PaperSizes(I) Next I

ActiveReports 2.0 Standard User's Guide | 406


End Sub

PaperWidth (Printer)

PaperWidth (Printer)
Description
PaperWidth sets or returns the width of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection. Note: This property is used only when PaperSize is set to 256 Custom. The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type
Single

Availability
Design time Run time N/A Read / Write

Example
Private Sub ActiveReport_ReportStart() ' Specify a custom paper size Me.PageSettings.PaperSize = 256 ' Sets the paper's width to 2 inches Me.PageSettings.PaperWidth = 1440 * 2 ' Sets the paper's height to 4 inches Me.PageSettings.PaperHeight = 1440 * 4 End Sub

Port

Port
Description
Sets or returns the current printer port.

Data Type
String

Availability
Design time Run time N/A Read / Write

Example
rptSummary.Printer.Port = "LPT1"

Ports

Ports

ActiveReports 2.0 Standard User's Guide | 407

Description
A zero-based string array property that enumerates all the available ports. You can use this property to display a list of ports to the user.

Data Type
Array - string

Availability
Design time Run time N/A Read / Write

Example
Dim prt As New DDActiveReports2.Printer ' Fill a listbox with the available printer ports For i = 0 to prt.NPorts 1 lstPorts.AddItem prt.Ports(i) Next i

PrintQuality

PrintQuality
Description
PrintQuality specifies the printer resolution used when printing the report.

Data Type
PrtQuality

Settings
Value -1 -2 -3 -4 Mnemonic ddPQDraft ddPQLow ddPQMedium ddPQHigh Description Draft Low resolution Medium resolution High resolution

Availability
Design time Run time N/A Read / Write

Example
rptInvoice.PrintQuality = ddPQHigh

Status

Status (Printer)
Description
Returns the current print job status.

Data Type

ActiveReports 2.0 Standard User's Guide | 408

JobStatus

Settings
Value 0 1 2 3 Mnemonic ddJSIdle ddJSPrinting ddJSCompleted ddJSAborted Description Idle Printing Completed Aborted

Availability
Design time Run time N/A Read Only

Example
lblStatus.Caption = rptInvoice.Printer.Status

ToPage

ToPage
Description
Sets the number for the last page to print in the specified report. Note: A. When a report runs to completion, it will set the FromPage to 1 and ToPage to number of pages in the report. B. If you set FromPage and ToPage to 0 , the PrintDialog will disable the pages radio button and select "All Pages". C. If you set FromPage-1 and ToPage to -1, the selection radio is selected which means, print currently visible page. When report is not visible, this will print the first page. D. On return from PrintDialog method or PrintReport method, FromPage and ToPage are set to the user selected values in the dialog.

Data Type
Long

Availability
Design time Run time N/A Read / Write

Example
rptSales.Printer.FromPage = 1 rptSales.Printer.ToPage = 1 rptSales.PrintReport

TrackDefault

TrackDefault
Description
Specifies whether changes to the printer options will be reflected in Windows default printer.

ActiveReports 2.0 Standard User's Guide | 409

Data Type
Boolean Default is False, changes will not be reflected in the printer settings.

Availability
Design time Run time N/A Read / Write

Example
' If user changes printer options in our custome printer ' form the changes will be reflected in Windows ' default printer rptSummary.Printer.TrackDefault = True ' This form displays custom printer settings and ' modifies the printer object frmPrintSetup.Show vbModal

TwipsPerPixelX, TwipsPerPixelY

TwipsPerPixelX, TwipsPerPixelY
Description
TwipsPerPixelX and TwipsPerPixelY return the number of twips per pixel horizontally (TwipsPerPixelX) or vertically (TwipsPerPixelY).

Data Type
Single

Availability
Design time Run time N/A Read

Printer Methods

Printer Methods
Method AbortJob Description Aborts the current print job. Sub AbortJob() EndJob Ends a previously started print job. Sub EndJob() EndPage EndPage ends a previously started page. You must call StartPage before calling this method. Otherwise, ActiveReports will fire an error event. Sub EndPage() Escape Sends a raw escape sequence to the printer. Sub Escape(code As String) PrintPage Sends the specified canvas object to the printer. Sub PrintPage(Canvas As Canvas) PrintDialog Displays the system's print dialog.

ActiveReports 2.0 Standard User's Guide | 410

Function PrintDialog(ParentWnd As Long) As Boolean SetupDialog Displays the system's printer setup dialog. Function SetupDialog(ParentWnd As Long) As Boolean StartJob Starts spooling a new print job. Sub StartJob(DocumentName As String) StartPage Starts a new page inside a print job. This is used to output multiple scaled canvas objects on the same page. Sub StartPage()

AbortJob

AbortJob
Description
Aborts the current print job.

Return Type
None

Syntax
Sub AbortJob()

Parameters
None

EndJob

EndJob
Description
EndJob ends a previously started print job. You must call StartJob before calling this method. Otherwise, ActiveReports will fire an error event.

Return Type
None

Syntax
Sub EndJob()

Parameters
None

Example
rptSummary.Printer.StartJob "Sales Report" For Each pg In rptSales.Pages rptSales.Printer.PrintPage pg Next> ' Close the job rptSummary.Printer.EndJob

EndPage

EndPage

ActiveReports 2.0 Standard User's Guide | 411

Description
EndPage ends a previously started page. You must call StartPage before calling this method. Otherwise, ActiveReports will fire an error event.

Return Type
None

Syntax
Sub EndPage()

Parameters
None

Example
Dim rpt As New ActiveReport1 Set PageEventHandler = rpt rpt.Show PrintTiled rpt, 3, 3 End Sub Sub PrintTiled(rpt As ActiveReport, rowCount As Integer, colCount As Integer) Dim row, col Dim pagex, pagey, pagew, pageh As Integer Dim margx, margy Dim pageNum As Integer rpt.Printer.StartJob "One Page" rpt.Printer.StartPage pagew = (rpt.Printer.PaperWidth ActiveReport1.PageSettings.LeftMargin ActiveReport1.PageSettings.RightMargin) / colCount pageh = (rpt.Printer.PaperHeight ActiveReport1.PageSettings.TopMargin _ ActiveReport1.PageSettings.BottomMargin) / rowCount For row = 0 To rowCount - 1 pagey = (pageh + SPACE_BETWEEN_PAGES) * row For col = 0 To colCount - 1 pagex = (pagew + SPACE_BETWEEN_PAGES) * col pageNum = row * colCount + col If (pageNum < rpt.Pages.Count) Then rpt.Printer.PrintPage rpt.Pages(pageNum), pagex, pagey, pagew, pageh End If Next Next rpt.Printer.EndPage rpt.Printer.EndJob End Sub Private Sub PageEventHandler_PageEnd() Dim pageObject As Canvas Set pageObject = PageEventHandler.Canvas pageObject.ForeColor = vbBlack pageObject.BackStyle = ddBKTransparent pageObject.PenStyle = 1 pageObject.PenWidth = 1 pageObject.DrawRect 0, 0, pageObject.Width, pageObject.Height End Sub

Escape

Escape
Description
Escape method is used to send raw escape sequences to the printer. Escape sequences allow you to modify custom print setting while printing.

ActiveReports 2.0 Standard User's Guide | 412

Escape sequences start with ASCII character 27 Chr$(27) followed by an escape sequence of characters.

Return Type
None

Syntax
Sub Escape(Code As String)

Parameters
Name Code Type String Description The escape sequence string to be sent to the printer

PrintPage

PrintPage
Description
Print method renders the specified canvas object to the printer. PrintPage can also be used to scale the page's output by indicating a left, top, width, and height value for the output.

Return Type
None

Syntax
Sub PrintPage(Canvas As Canvas, [left],[top],[width],[height])

Parameters
Name Canvas Left, Top, Width, Height (optional) Type Canvas Long Description A reference to a valid canvas object. Specifying a left, top, width and height will scale the page's output.

Example
rptSummary.Printer.StartJob "Sales Report" For Each pg In rptSales.Pages rptSales.Printer.PrintPage pg Next ' Close the job rptSummary.Printer.EndJob

PrintDialog

PrintDialog
Description
Displays Windows standard print dialog. User settings will effect the printer settings in ActiveReports. You can center the dialog by specifying the parent window handle. PrintDialog returns False if the user cancels the dialog.

ActiveReports 2.0 Standard User's Guide | 413

Return Type
None

Syntax
Function PrintDialog(ParentWindow As Boolean)

Parameters
Name ParentWindow Type Long Description Parent window handle to center the dialog within the specified window.

Example
Private Sub btnPrint() ' Display the printer dialog centered within ' the current form rpt.Printer.PrintDialog frmReports.hWnd End Sub

SetupDialog

SetupDialog
Description
Displays Windows printer setup dialog centered within the specified window. Any user changes will be reflected in the Windows default printer settings and ActiveReports printer object. SetupDialog returns False if the user cancels the setup dialog.

ActiveReports 2.0 Standard User's Guide | 414

Return Type
None

Syntax
Function SetupDialog(ParentWindow As Boolean)

Parameters
Name ParentWindow Type Long Description Parent window handle to center the dialog within the specified window.

Example
Private Sub btnPrinterSetup() rpt.Printer.SetupDialog frmReports.hWnd End Sub

StartJob

StartJob
Description
Starts a new printing job.

Return Type
None

Syntax
Sub StartJob(DocumentName As String)

Parameters
Name DocumentName Type String Description The name of the job as it would appear in the spooler's list of jobs.

ActiveReports 2.0 Standard User's Guide | 415

Example
rptSummary.Printer.StartJob "Sales Report" For Each pg In rptSales.Pages rptSales.Printer.PrintPage pg Next ' Close the job rptSummary.Printer.EndJob

StartPage

StartPage
Description
Starts a new page inside a print job. This is used to output multiple scaled canvas objects on the same page.

Return Type
None

Syntax
Dim rpt As New ActiveReport1 Set PageEventHandler = rpt rpt.Show PrintTiled rpt, 3, 3 End Sub Sub PrintTiled(rpt As ActiveReport, rowCount As Integer, colCount As Integer) Dim row, col Dim pagex, pagey, pagew, pageh As Integer Dim margx, margy Dim pageNum As Integer rpt.Printer.StartJob "One Page" rpt.Printer.StartPage pagew = (rpt.Printer.PaperWidth ActiveReport1.PageSettings.LeftMargin ActiveReport1.PageSettings.RightMargin) / colCount pageh = (rpt.Printer.PaperHeight ActiveReport1.PageSettings.TopMargin _ ActiveReport1.PageSettings.BottomMargin) / rowCount For row = 0 To rowCount - 1 pagey = (pageh + SPACE_BETWEEN_PAGES) * row For col = 0 To colCount - 1 pagex = (pagew + SPACE_BETWEEN_PAGES) * col pageNum = row * colCount + col If (pageNum < rpt.Pages.Count) Then rpt.Printer.PrintPage rpt.Pages(pageNum), pagex, pagey, pagew, pageh End If Next Next rpt.Printer.EndPage rpt.Printer.EndJob End Sub Private Sub PageEventHandler_PageEnd() Dim pageObject As Canvas Set pageObject = PageEventHandler.Canvas pageObject.ForeColor = vbBlack pageObject.BackStyle = ddBKTransparent pageObject.PenStyle = 1 pageObject.PenWidth = 1 pageObject.DrawRect 0, 0, pageObject.Width, pageObject.Height End Sub

ActiveReports 2.0 Standard User's Guide | 416

RptFields

RptFields
RptFields Properties RptFields Methods

RptFields Properties

RptField Properties
Property Name Tag Value Data Type String Variant Variant Description Sets or returns the name of the field. Sets or returns a user defined value. Sets or returns the current value of the field object.

Name

Name (RptField)
Description
Sets or returns the name of the field. It should be unique within the collection and is used as a key of the field in the collection.

Data Type
String

Availability
Run time Read / Write

Example
Private Sub ActiveReport_DataInitialize() Fields.Add "OrderID" Debug.Print Fields("OrderID").Name End Sub

Tag

Tag (RptField)
Description
Sets or returns a user defined value associated with the field object.

Data Type
Variant

Availability
Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 417

Value

Value (RptField)
Description
Sets or returns the current value of the field object.

Data Type
Variant

Availability
Run time Read / Write

Example
Private Sub ActiveReport_FetchData(eof As Boolean) If rs.EOF Then Exit Sub Fields("Amount").Value = rs!Qty Eof = False End If End Sub

RptFields Methods

RptFields Methods
Method Add Description Adds a new field to the collection. Function Add(Name As String) As Object Count Returns the number of fields in the collection. Function Count() As Integer Item Returns the field object at the specified index. Function Item(Index) As Object Remove Removes the specified field from the collection. Sub Remove(Index) RemoveAll Removes all fields from the collection. Sub RemoveAll()

Add

Add (RptFields)
Description
Adds a new custom field to the report's fields collection.

Return Type
RptField object

Syntax
Function Add(Name As String) As Object

ActiveReports 2.0 Standard User's Guide | 418

Parameters
Name Name Type String Description New field name, used as a key in the collection.

Example
Private Sub ActiveReport_DataInitialize() Fields.Add "Amount" End Sub

Count

Count (RptFields)
Description
Returns the number of fields in the collection.

Return Type
Integer

Syntax
Function Count() As Integer

Parameters
None

Example
For I = 0 To Fields.Count 1 Debug.Print Fields(I).Value Next

Item

Item
Description
Returns the field object at the specified index. Item is the default method of the RptFields collection.

Return Type
Object

Syntax
Function Item(Index As Object)

Parameters
Name Index Type Variant Description The index of the entry to be retrieved. Can be the ordinal index or the key of the field in the collection.

Remove

ActiveReports 2.0 Standard User's Guide | 419

Remove (RptFields)
Description
Removes the field at the specified index from the collection.

Return Type
None

Syntax
Sub Remove(Index)

Parameters
Name Index Type Variant Description The index of the entry to be removed. Can be the ordinal index or the key of the field in the collection.

RemoveAll

RemoveAll (RptFields)
Description
Removes all elements from the collection.

Return Type
None

Syntax
Sub RemoveAll()

Parameters
None

Sections

Sections Collection
Section Properties Section Methods Section Events

Section Properties

Section Properties
Property BackColor Data Type OLE_COLOR Description Sets or returns the background color of a section. The setting will be reflected when the BackStyle property is set to ddBKNormal. Sets or returns whether the object has a transparent or normal background. Transparent background makes the objects behind the section visible. Determines if the section is allowed to

BackStyle

Integer

CanGrow

Boolean

ActiveReports 2.0 Standard User's Guide | 420

stretch beyond its maximum height based on its contents. CanShrink Boolean Determines if the section height should shrink to reflect the size of its components. Sets or returns the number of columns in the section. Sets or returns the direction to use when printing multiple columns. Determines if a group header or footer section should reflect the column setting of it detail. Sets or returns the space between columns in multicolumn report (in twips) Returns a reference to the controls collection placed in the section. Applies to group header sections. It sets or returns the name of the field to use for grouping data. ActiveReports will start a new group whenever the value of the specified field changes in the data set. Applies to group header sections. Used as an alternative unbound grouping of data. setting this property while the report is running will cause ActiveReports to start a new group whenever that value changes. Applies to group header sections. Determines if the group can be separated from its detail section. Specifies the height of the section in twips. Returns true if the section is repeating from last page. Determines if the section can be split across pages if it does not fit in the available area on a page. Returns the unique name of a section. Determines whether the section should be preceded or followed by a column break, i.e., cause the start or end of a column. Does not apply to PageHeader or PageFooter sections. Determines whether the section should be preceded or followed by a page break, i.e., cause the start or end of a page. Does not apply to PageHeader or PageFooter sections. Sets or returns whether or not the GroupFooter or ReportFooter should be printed at the bottom of the page. Determines whether a group section should be repeated at the beginning of a new page if its detail was split across pages. Sets or returns the script being used for the section. Returns the type of the section (ReportHeader, Detail, Etc.) Determines whether the section should print underneath the following section. The following section will start printing

ColumnCount ColumnDirection ColumnLayout

Integer ColumnDirections Boolean

ColumnSpacing Controls DataField

Single Controls String

GroupValue

Variant

GrpKeepTogether

GrpKeepTogether

Height IsRepeating KeepTogether

Single Boolean Boolean

Name NewColumn

String NewPageConstants

NewPage

NewPageConstants

PrintAtBottom

Boolean

Repeat

RepeatStyle

Script Type UnderlayNext

String SectionType Boolean

ActiveReports 2.0 Standard User's Guide | 421

beginning from the top coordinate of the section instead of the bottom coordinate. Visible Boolean Determines whether the section is visible; non-visible sections are not printed.

BackColor

BackColor (Section)
Description
Sets or returns the background color of a section. The setting will be reflected when the BackStyle property is set to ddBKNormal.

Data Type
OLE_COLOR

Availability
Design time Run time Read / Write Read / Write

Example
rptAuthors.Detail.BackColor = vbBlue rptAuthors.Detail.BackStyle = ddBKNormal

BackStyle

BackStyle (Section)
Description
Sets or returns whether the section has a transparent or normal background.

Data Type
BackStyle

Settings
Value 0 1 Mnemonic ddBKTransparent ddBKNormal Description Transparent opaque background, the objects behind the object show through the object. Normal, the object hides all controls behind it.

Availability
Design time Run time Read / Write Read / Write

Example
rptAuthors.Detail.BackColor = vbBlue rptAuthors.Detail.BackStyle = ddBKNormal

ActiveReports 2.0 Standard User's Guide | 422

CanGrow

CanGrow (Section)
Description
CanGrow determines whether the section height will be expanded if any of its contained controls grow beyond its area. If this property is set to False, the section contents will be clipped to the height of the section.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
rptAuthors.Detail.CanGrow = False rptAuthors.Detail.CanShrink = False

CanShrink

CanShrink (Section)
Description
CanShrink determines whether the section height will be adjusted to fit its contents. When this property set to False the section will not shrink beyond the minimum value defined by its Height property. Note: This property does not apply to PageHeader and PageFooter sections.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
rptAuthors.Detail.CanGrow = False rptAuthors.Detail.CanShrink = False

ColumnCount

ColumnCount
Description
ColumnCount property sets or returns the number of newspaper columns in the report. This property

ActiveReports 2.0 Standard User's Guide | 423 can be used to print labels or phonebook style listings. The width of each column equals the PrintWidth of the report divided by the number of columns. ColumnCount applies to Detail sections only. You can use the ColumnLayout property to force associated group headers and footers to follow the same column format as their detail section.

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

Example
rptMenu.Detail.ColumnCount = 3 rptMenu.Detail.ColumnDirection = ddCDAcrossDown

ColumnDirection

ColumnDirection
Description
ColumnDirection property determines how ActiveReports should print the detail section in a multicolumn report.

Data Type
ColumnDirections

Settings
Value 0 1 Mnemonic ddCDDownAcross ddCDAcrossDown Description Print each section down each column followed by the next column to its right. Print sections right across the first row followed by the second row and so on.

Availability
Design time Run time Read / Write Read / Write

Example
rptMenu.Detail.ColumnCount = 3 rptMenu.Detail.ColumnDirection = ddCDAcrossDown

ActiveReports 2.0 Standard User's Guide | 424

ColumnLayout

ColumnLayout
Description
ColumnLayout property determines whether a group header section should use the same column layout of its detail section. When this property is True, the number of columns in a detail section will be reflected in the associated group headers and footers. Note: This property applies to GroupHeader and GroupFooter sections only.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
rptShipments.GHLocation.ColumnLayout = False

ColumnSpacing

ColumnSpacing
Description
Sets or returns the space between columns in multicolumn report (in twips).

Data Type
Single

Availability
Design time Run time Read / Write Read / Write

Example
rptAuthors.Detail.ColumnSpacing = .5 * 1440

Controls

Controls (Section)
Description
Returns a reference to the controls collection placed in the section

Data Type
Controls

Availability
Run time Read-Only

Example

ActiveReports 2.0 Standard User's Guide | 425

Private Sub Detail_BeforePrint() Dim ctrl As Control Dim sec As Section Set sec = ActiveReport1.Sections("Detail") For Y = 0 To sec.Controls.Count - 1 If TypeOf sec.Controls(Y) Is DDActiveReports2.Field Then If sec.Controls(Y).DataValue = 0 Then sec.Controls(Y).Visible = False Else sec.Controls(Y).Visible = True End If End If Next Y End Sub

DataField

DataField (Section)
Description
DataField applies to GroupHeader sections. It defines the binding field for a group within the detail body. This value is set to the name of any field in the Data Source or the name of a custom field added into the Fields collection. When this property is set, ActiveReports will create a new group each time the value of the bound field changes in the detail data records. Note : ActiveReports will not sort the data automatically. The data source should be sorted to reflect the desired grouping of detail records. When using XML the DataField must be set to a valid XPath string. Note: The base path set by the RecordSetPattern is used as the starting node So if a control needs to use a higher level node, use "../" to move back a node.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
RptLoans.ghClient.DataField = "CustomerID"

GroupValue

GroupValue
Description
This property applies to GroupHeader sections only. It is used to define custom grouping of detail records. You can use this value when you need to group your detail records on a calculated value that is not part of the detail fields in the data source. You would update this value in the Format event of the Detail section. ActiveReports reads the detail record, binds the fields in the Detail section, and then fires a Format event. ActiveReports checks whether the GroupValue has been set in the Format event and whether the new value is different from the value set in the previous event. If the value is different, then ActiveReports closes the current group (by printing the group footer) and starts a new group (by printing the group header). Note: This property is obsolete as of ActiveReports 1.0 Service Pack 3, and should never be used in ActiveReports 2.0. To bind a group to a custom value you can add a field to the Fields collection and

ActiveReports 2.0 Standard User's Guide | 426 bind the group to that field by setting the DataField property to its name.

Data Type
Variant

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() ' Set the unbound group breaking value ghCountry.GroupValue = dcRptData.Recordset.Fields("Country").Value End Sub

GrpKeepTogether

GrpKeepTogether
Description
GrpKeepTogether determines whether group header and footer sections will print as a single block on the same page. The property defaults to ddGrpNone, which allows the group, block to be split across pages. When you set this property to ddGrpAll, ActiveReports attempts to print the complete block on the same page without any page-breaks. When a complete block does not fit on a single page, it will be split across two or more pages. The third option prevents any widowed group header sections. The group header will always print with at least one detail section. Note: This property applies to GroupHeader sections only.

Data Type
GrpKeepTogether

Settings
Value 0 1 2 Mnemonic ddGrpNone ddGrpFirstDetail ddGrpAll Description A page can be broken immediately after a group header. The group header will print with the first detail section on the same page or column. The group header, detail and group footer will print together on the same page.

Availability
Design time Run time Read / Write Read / Write

Example
rptAuthors.GHCategory.GrpKeepTogether = True

Height

ActiveReports 2.0 Standard User's Guide | 427

Height (Section)
Description
Sets or returns the section's height in twips. Note: A section's height can only be changed in the section's Format event, the ReportStart event, or before the report is run. Changing the height will not automatically reposition the controls inside the section.

Data Type
Single

Availability
Design time Run time Read / Write Read / Write

Example
RptMain.GHEmployee.Height = 2*1440

IsRepeating

IsRepeating
Description
Returns true if the section is repeated from last page.

Data Type
Boolean

Availability
Run time Read

Example
Private Sub ghCustomer_Format() If ghCustomer.IsRepeating Then lblContinued.Caption = "Continued" Else lblContinued.Caption = "" End If End Sub

KeepTogether

KeepTogether
Description
KeepTogether property determines whether a section should print in its entirety on the same page. When you set this property to True, the section will print on the same page without any page breaks. A False setting allows the section to be split across two or more pages. Note: This property applies to GroupHeader, GroupFooter and Detail sections only.

Data Type
Boolean

ActiveReports 2.0 Standard User's Guide | 428

Availability
Design time Run time Read / Write Read / Write

Example
rptInvoice.Detail.KeepTogether = False

Name

Name (Section)
Description
Sets or returns the unique identifying name of the section.

Data Type
String

Availability
Design time Run time Read / Write Read

NewColumn

NewColumn
Description
NewColumn determines whether ActiveReports should insert a column-break before and/or after printing the section. Note: This property does not apply to ReportHeader, ReportFooter, PageHeader or PageFooter sections.

Data Type
NewPageConstants

Settings
Value 0 1 2 3 Mnemonic ddNPNone ddNPBefore ddNPAfter ddNPBeforeAfter Description No page-break before the section. Start printing the section on a new page. Start a new page after printing the section. Start printing the section on a new page and start a new page after printing it.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Static RNumber As Long RNumber = RNumber + 1

ActiveReports 2.0 Standard User's Guide | 429


If RNumber = 6 Then 'If there are 6 records in the column 'it will add a new column and reset the counter Detail.NewColumn = ddNPAfter RNumber = 0 Else Detail.NewColumn = ddNPNone 'This turns off the Add New column End If End Sub

NewPage

NewPage
Description
NewPage determines whether ActiveReports should insert a page-break before and/or after printing the section. Note: This property does not apply to PageHeader or PageFooter sections.

Data Type
NewPageConstants

Settings
Value 0 1 2 3 Mnemonic ddNPNone ddNPBefore ddNPAfter ddNPBeforeAfter Description No page-break before the section. Start printing the section on a new page. Start a new page after printing the section. Start printing the section on a new page and start a new page after printing it.

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub Detail_Format() Static RNumber As Long RNumber = RNumber + 1 If RNumber = 6 Then 'If there are 6 records on the page 'it will add a new page and reset the counter Detail.NewPage = ddNPAfter RNumber = 0 Else Detail.NewPage = ddNPNone 'This turns off the Add New page End If End Sub

PrintAtBottom

PrintAtBottom
Description
Sets or returns whether or not the GroupFooter or ReportFooter should be printed at the bottom of the page. Note: If PrintAtBottom is set to true and the report has a PageFooter, the GroupFooter or

ActiveReports 2.0 Standard User's Guide | 430 ReportFooter will be printed above the PageFooter. Note: Setting more than one section to print at the bottom will cause the subsequent footer sections to be printed on separate pages.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub GroupFooter1_Format() 'Prints GroupFooter at the bottom of the page GroupFooter1.PrintAtBottom = True End Sub

Repeat

Repeat
Description
Repeat property determines whether a GroupHeader section should be printed again before its associated detail section when the detail section is broken across multiple pages or columns.

Data Type
RepeatStyle

Settings
Value 0 1 2 3 4 Mnemonic ddRepeatNone ddRepeatOnPage ddRepeatOnColumn ddRepeatAll ddRepeatOnPageIncludeNoDetail Description Do not reprint the group header. Print the group header at the top of each page within the group's detail sections. Print the group header at the top of each column within the group's detail sections. Print the group header at the top of each column and page within the group's detail sections. Print the group header at the top of each page within the group's detail section even if there is no data in the section.

Availability
Design time Run time Read / Write Read / Write

Example
rptSales.GHDepartments.Repeat = ddRepeatAll

Script

Script (Section)

ActiveReports 2.0 Standard User's Guide | 431

Description
Sets or returns an ActiveScript string for the report to use when making modifications to the report at runtime. The scripts run immediately after their matching ActiveReports' events and take precedence over the code inside the project. If reports with scripts are saved to XML, the scripts are incorporated into the XML file. Changes to scripts in the XML file can be made and then loaded back into a report project to show the changes. This allows reports to be modified without requiring the project to be recompiled. The report's section script property allows access to the following scripting events.
Sub end Sub end Sub end OnFormat() sub OnBeforePrint() sub OnAfterPrint() sub

Note: When referencing the report in the script, use rpt instead of the report's name or "me". If the script editor is not used, the scripts must use Chr(34) to insert double-quotes around strings, section names and control names. More information on scripting can be found on Microsoft's site at http://msdn.microsoft.com/scripting/.

Data Type
String

Availability
Design time Run time Read /Write Read / Write

Example
Private Sub Command1_Click() Dim vbScript As String vbScript = "sub OnFormat" & vbCrLf vbScript = vbScript & "rpt.Sections(" & Chr(34) & _ "Detail" & Chr(34) & ").Controls(" vbScript = vbScript & Chr(34) & "Label1" & Chr(34) & _ ").Caption = " & Chr(34) & "Hello world" & _ Chr(34) & vbCrLf vbScript = vbScript & "end sub" ActiveReport1.Detail.Script = vbScript ActiveReport1.Show End Sub

Type

Type (Section)
Description
Type property returns the type of the section.

Data Type
SectionType

Settings
Value 0 Mnemonic ddSTReportHeader Description A section that prints once per report before any other report section is printed.

ActiveReports 2.0 Standard User's Guide | 432

1 2 3 4 5 6

ddSTReportFooter ddSTPageHeader ddSTPageFooter ddSTGroupHeader ddSTGroupFooter ddSTDetail

A section that prints once per report, after all detail and group sections are printed. A section that prints once at the top of each page in the report. A section that prints once at the bottom of each page in the report. A section that prints once before detail sections whenever the group value or the group field value changes. A section that prints once after detail sections whenever the group value or the group field value changes. A section that prints once for each record or detail line in the report.

Availability
Design time Run time N/A Read Only

Example
Private Sub ActiveReport_ReportStart() Dim ctl As Object For x = 0 To Me.Sections.Count - 1 If Me.Sections(x).Type = 2 Then Set ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label") ctl.Caption = "Page Header" ctl.Top = 0 ctl.Left = 0 ctl.Height = 500 ctl.Width = 2000 ctl.BackStyle = vbNormal ctl.BackColor = vbBlue ElseIf Me.Sections(x).Type = 6 Then Set ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label") ctl.Caption = "Detail Section" ctl.Top = 0 ctl.Left = 0 ctl.Height = 500 ctl.Width = 2000 ctl.BackColor = vbRed ctl.BackStyle = vbNormal ElseIf Me.Sections(x).Type = 3 Then Set ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label") ctl.Caption = "Page Footer" ctl.Top = 0 ctl.Left = 0 ctl.Height = 500 ctl.Width = 2000 ctl.BackColor = vbGreen ctl.BackStyle = vbNormal End If Next End Sub

UnderlayNext

UnderlayNext
Description
UnderlayNext property determines whether the section should print underneath the following section. The following section will start printing starting from the top coordinate of the under-laid section instead of the bottom coordinate. Note: This property applies to GroupHeader sections only.

Data Type

ActiveReports 2.0 Standard User's Guide | 433

Boolean

Availability
Design time Run time Read / Write Read / Write

Example
RptStyles.GHImported.UnderlayNext = True

Visible

Visible (Section)
Description
Visible property determines whether the section is to be printed or not.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
If doSummary = True then rptInvolice.Detail.Visible = False End if

Section Methods

Section Methods
Method Add Description Creates a new section of a specified type. Sub Add(Name As String, insertionIndex As Long, Type As SectionType, height As Long) Count Returns the number of sections in the collection. Function Count() As Integer Item Returns the section object at the specified index. Function Item(index As Variant) As Object Refresh Remove Updates the section when using a designer control (Professional Version only). Removes the specified section from the report. Sub Remove(index As Variant)

Add

Add (Sections)

ActiveReports 2.0 Standard User's Guide | 434

Description
Creates a new section of a specified type (detail, group header, etc.) and adds it to the report. This method can be used at design time (when creating add -ins that dynamically create reports) or run time (when creating or modifying a report). Note: When adding a ReportHeader, PageHeader, or GroupHeader, the section's footer must also be added.

Return Type
Section object

Syntax
Sub Add(Name As String, insertionIndex As Long, Type As SectionType, height As Long)

Parameters
Name Name InsertionIndex SectionType Height Type String Integer SectionType Long Description Unique name of the new section. Position where the new section should be inserted within the current Sections collection. Type of the section to be created (see Section Types in Constants). Height of the new section in twips.

Example
Dim ar As rptTemplate Set ar = New rptTemplate ' Add A Group Header Section ar.Sections.Add "ghCustomer", 1, ddSTGroupHeader, 370 ' And always add a matching group footer ar.sections.Add "gfCustomer", 3, ddSTGroupFooter, 370 ' Bind the section Ar.Sections("ghCustomer").DataSource = "dcRptData" Ar.Sections("ghCustomer").DataField = "CustomerName"

Count

Count (Sections)
Description
Count method returns the number of section object in the Sections collection.

Return Type
Integer

Syntax
Function Count() As Integer

Parameters
None

Item

Item (Sections)
Description

ActiveReports 2.0 Standard User's Guide | 435

Item method returns a reference to the section object at the specified index.

Return Type
Section object

Syntax
Function Item(i ndex As Variant) As Object

Parameters
Name Index Type Variant Description The index of the section in the collection or unique name of the section.

Refresh

Refresh (Sections)
Description
Updates the section when using a designer control (Professional Version only).

Return Type
none

Syntax
Sub Refresh()

Parameters
None

Remove

Remove (Sections)
Description
Remove method removes the section at the specified index from the Sections collection.

Return Type
None

Syntax
Sub Remove(index As Variant)

Parameters
Name Index Type Variant Description The index of the section in the collection or unique name of the section.

Section Events

Section Events
Event AfterPrint Description This event fires after the section is rendered to the canvas.

ActiveReports 2.0 Standard User's Guide | 436

Sub AfterPrint() BeforePrint This event fires before the section is rendered to the canvas. Sub BeforePrint() Format This event fires after the data is loaded and bound to the controls contained in a section, but before the section is rendered to the canvas. Sub AfterPrint()

AfterPrint

AfterPrint
Description
This event fires after the section is rendered to the canvas. Although Detail AfterPrint originally started off as a very important event prior to Version 1 Service Pack 3, it is rarely used in any of the newer builds of ActiveReports. When you are placing code in the section events, chances are you are going to be placing your code in the Format or BeforePrint events. This event is still useful for drawing on the canvas after text has already been rendered to the canvas.

Syntax
Sub AfterPrint()

Example
Private Sub Detail_AfterPrint() ActiveReport1.Canvas.DrawText "Private", 4 * 1440, _ 4 * 1440, 4 * 1440, 4 * 1440 End Sub

BeforePrint

BeforePrint
Description
This event fires before the section is rendered to the canvas. The growing and shrinking of the section and all controls contained in a section have already taken place by the time this event fires. Use this section to resize any controls if needed. Since all controls and section growth have already taken place by the time this event fires, this event may be used to get an accurate height of the section or any controls in it. You may resize any controls in this event, but you cannot resize the section itself.

Syntax
Sub BeforePrint()

Example
Private Sub ghCountry_BeforePrint() txtPctTotal.DataValue = txtSales.DataValue / txtGrandTotal.DataValue End Sub

Format

ActiveReports 2.0 Standard User's Guide | 437

Format
Description
This event fires after the data is loaded and bound to the controls contained in a section, but before the section is rendered to the canvas. The format event is the only event where the section's height may be changed. This section may be used to set or change the properties of any controls, or load subreport controls with subreports. If the CanGrow or CanShrink property of any control contained within a section, or the section itself, is set to true, all of the growing and shrinking of controls contained in this section, and the section itself, takes place in this event. Because of this, information about a control or section's height cannot be obtained in this event.

Syntax
Sub Format()

Example
Private Sub Detail_Format() ' If sales value is > 10000 Then color the field red If txtSales.DataValue > 10000 Then TxtSales.ForeColor = vbRed End If End Sub

TOC

TOC Object
TOC Properties TOC Methods TOCEntry Properties

TOC Properties

TOC Properties
Property Count CurrentPage History SelectedItem Data Type Long Long History Long Description Returns the number of entries in the table. Sets or returns the current displayed page. Returns a reference to the history object. Returns the selected item in the TOC tree.

Count

Count (TOC)
Description
Count property returns the number of TOC entries.

Data Type
Long

ActiveReports 2.0 Standard User's Guide | 438

Availability
Run time Read

CurrentPage

CurrentPage
Description
Sets or returns the current page in the viewer. Works in both the built-in viewer and the Viewer control. You can use this property to navigate through the viewer pages and display the current page number.

Data Type
Long

Availability
Run time Read

Example
' Implement a First, Previous, Next, and Last Page ' command buttons and ' update a current page number label. ' Create a form with a viewer control named arv, ' 4 command buttons array named btnMove(0..4) ' Label named lblPage Private Sub btnMove_Click(Index As Integer) Select Case Index Case 0 ' First Page If arv.Pages.Count > 0 Then arv.TOC.CurrentPage = 0 Case 1 ' Previous Page If arv.TOC.CurrentPage > 0 Then arv.TOC.CurrentPage = arv.TOC.CurrentPage-1 End If Case 2 ' Next Page If arv.TOC.CurrentPage < arv.Pages.Count-1 Then arv.TOC.CurrentPage = arv.TOC.CurrentPage + 1 End If Case 3 ' Last Page If arv.Pages.Count > 0 Then arv.TOC.CurentPage = arv.Pages.Count-1 End If End Select End Sub

History

History (TOC)
Description
History property returns a reference to the navigation history object.

Data Type
History

Availability

ActiveReports 2.0 Standard User's Guide | 439

Run time

Read

Example
' Command button implementations of a custom toolbar Private Sub btnBack() arv.TOC.History.Back End Sub Private Sub btnForward() arv.TOC.History.Forward End Sub

SelectedItem

SelectedItem
Description
Returns the selected item in a table of contents tree. This property is read -only and available at run time.

Data Type
Long

Availability
Run time Read

TOC Methods

TOC Methods
Method Add Description Adds a new node to the report's table of contents. Sub Add(text As String) GotoPage Displays the requested page number. Sub GotoPage(PageNumber As Long) Item Returns the text of the entry at the selected index. Function Item(index As Long) As String Navigate Displays the page that contains the requested entry. Sub Navigate(tocEntry As String) PageNumber Returns the page number associated with the specified TOC entry. Function PageNumber(index) As Long Remove Removes the specified entry from the table of contents. Sub Remove(text As String) RemoveAll Removes all entries from the table of contents. Sub RemoveAll()

Add

Add (TOC)
Description

ActiveReports 2.0 Standard User's Guide | 440

Add method adds a new node to the table of contents. The entry text is a directory path-like string, which determines the parent-child relationship within the content tree. For example, inserting the string "Vendor 1" and later adding "Vendor 1\Product 1" makes the later entry a child of the "Vendor 1" entry. The "\" is used as a parent child separator. The text entered after the "\" will be displayed in an expandable node in the TOC window. When new items are added to the table of contents, the report uses the top of the section used to add the item as its reference point. For example, if an item was added in the GroupFooter, clicking on the table of contents item will take you to the top of the item's GroupFooter. Note: You can use "\\" to insert a back-slash literal character.

Return Type
None

Syntax
Sub Add(text As String)

Parameters
Name Text Type String Description Text string identifying the table of contents entry.

Example
Private Sub ghCategory_AfterPrint() TOC.Add txtCategory.Text End Sub Private Sub Detail_BeforePrint() ' Add a TOC entry for each printed product ' within its category TOC.Add txtProduct.Text & "\" & txtCategory.Text End Sub

GotoPage

GotoPage
Description
Displays the specified page in the report preview window.

Return Type
None

Syntax
Sub GotoPage(PageNumber As Long)

Parameters
Name PageNumber Type Long Description The page number to be displayed in the viewer

Example
' Implementation of custom First Page, Last Page buttons Private Sub btnFirstPage() ' Goto First Page arv.TOC.GotoPage 0 End Sub Private Sub btnLastPage()

ActiveReports 2.0 Standard User's Guide | 441


' Goto Last Page arv.TOC.GotoPage arv.Pages.Count - 1 End Sub

Item

Item (TOC)
Description
Returns the table of content entry at the specified index.

Return Type
String

Syntax
Function Item(index As Long) As String

Parameters
Name Index Type Long Description The index of the entry to be retrieved.

Example
Private Sub arv_TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long) Me.Caption = arv.TOC(ItemIndex).Name Me.Caption = Me.Caption & " Page " & arv.TOC(ItemIndex).pageNumber + 1 End Sub

Navigate

Navigate
Description
Navigate method displays the page containing the requested entry.

Return Type
None

Syntax
Sub Navigate(tocEntry As String)

Parameters
Name tocEntry Type String Description The table of contents entry string.

Example
Private Sub GotoProduct() ' Display a form to get category and product names frmGotoProduct.Show vbModal arv.TOC.Navigate sCategory & "\" & sProductName End Sub

ActiveReports 2.0 Standard User's Guide | 442

PageNumber

PageNumber (TOC)
Description
Returns the pages number associated with the specified table of contents entry. You can use this property to build a Table of Contents from all entries in the TOC object. You can output the table of contents into a canvas object and insert it at the beginning of your report. Note: This method has been replaced with Toc.Item(index).PageNumber. This method is for backwards compatibility with ActiveReports 1.0.

Return Type
String

Syntax
Function PageNumber(index As Long)

Parameters
Name Index Type Variant Description The index of the entry to be retrieved.

Remove

Remove (TOC)
Description
Removes the specified entry from the table of contents.

Return Type
None

Syntax
Sub Remove(tocEntry As String)

Parameters
Name tocEntry Type String Description The table of contents entry string.

RemoveAll

RemoveAll
Description
Clears all entries from the table of contents.

Return Type
None

Syntax
Sub RemoveAll()

Parameters

ActiveReports 2.0 Standard User's Guide | 443

None

TOCEntry Properties

TOCEntry Properties
Property Name PageNumber PageOffSet Data Type String Long Integer Description Sets or returns the name for the item entered into the TOC. Sets or returns the page number for the item entered into the TOC. Sets or returns the page offset for the item entered into the TOC.

Name

Name (TOCEntry)
Description
Sets or returns the name for the specified item in the TOC.

Data Type
String

Availability
Run time Read / Write

Example
Private Sub ActiveReport_TOCSelChange(ByVal ItemIndex As Long) Me.Caption = TOC.Item(ItemIndex).Name End Sub

PageNumber

PageNumber (TOCEntry)
Description
Sets or returns the page number for the specified item in the TOC. Note: The page numbers begin with 0.

Data Type
Long

Availability
Run time Read / Write

Example
Private Sub ActiveReport_TOCSelChange(ByVal ItemIndex As Long) Me.Caption = "Page " & TOC.Item(ItemIndex).pageNumber End Sub

ActiveReports 2.0 Standard User's Guide | 444

PageOffSet

PageOffSet
Description
Sets or returns the TOC entry's top position in twips. The PageOffSet measures the distance between the TOC entry and the page's top margin.

Data Type
Integer

Availability
Run time Read / Write

Tools and Toolbar

Tools and Toolbar


DDToolbar Properties DDToolbar Methods DDTools Methods DDTool Properties DDTool Methods

DDToolbar Properties

DDToolbar Properties
Property DisplayTooltips Font Tools Data Type Boolean StdFont DDTools Description Determines whether to display screen tooltips when the mouse hovers over a tool. Specified the Font properties of the tool. A collection of the tool objects that displayed in the toolbar.

DisplayTooltips

DisplayTooltips
Description
Determines whether to display screen tooltips when the mouse hovers over a tool.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

ActiveReports 2.0 Standard User's Guide | 445

Example
arv.Toolbar.DiaplayTooltips = True

Font

Font (DDToolbar)
Description
Defines the font properties used to display the tools.

Data Type
StdFont

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub ActiveReport_ReportStart() arv.Toolbar.Font.Name = "Tahoma" arv.Toolbar.Font.Size = "10" End Sub

Tools

Tools
Description
Returns a collection of the tools that are displayed on the toolbar. The tools collection contains 14 standard built-in tools that cannot be removed.
Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Description Table of Contents Separator Print Separator Copy Separator Find Separator SinglePage MultiPage Separator Zoom Out Zoom In Zoom Percent Separator Page Up

ActiveReports 2.0 Standard User's Guide | 446

16 17 18 19 20

Page Down Page n of m Separator History List Back History List Forward

Data Type
DDTools

Availability
Run time Read / Write

Example
Private Sub btnViewReport_Click() Load frmRptViewer frmRptViewer.arv.TOCVisible = True frmRptViewer.arv.ToolBar.Tools.Add "Printer Setup" frmRptViewer.Show End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

DDToolbar Methods

DDToolbar Methods
Method Refresh Description Causes the toolbar to repaint itself to reflect changes in the tools collection. Sub Refresh()

Refresh

Refresh (DDToolbar)
Description
Causes the toolbar to repaint itself to reflect changes in the tools collection.

Return Type
None

Syntax
Sub Refresh()

Parameters
None The toolbar will reflect the changes in its tools collection.

DDTools Methods

DDTools Methods

ActiveReports 2.0 Standard User's Guide | 447

Method Add

Description Adds a new tool to the tools collection. Sub Add(Caption As String)

AddEx

Adds a new tool to the tools collection while giving access to the added tools properties. Sub AddEx(Caption As String) As DDTool

Count

Returns the number of tools in the tools collection. Function Count() As Long

Insert

Inserts a new tool into the tools collection at the specified index. Sub Insert(Index As Integer, Caption As String)

Item

Returns a reference to the tool object at the specified collection. Function Item(Index As Integer) As DDTool

Add

Add (DDTools)
Description
Adds a new tool to the tools collection while giving access to the tool's properties. Note: Remember to set the ID property of a tool after adding or inserting it into the toolbar. The ToolbarClick event will not fire if the tool does not have its ID set. It is also important to make sure the ID property is not the same as one of the other toolbar items. Below is a list of predefined tool IDs:
Tool Name Table Of Contents Print Find Single Page Multiple Page Zoom Out Zoom In Zoom Previous Page Next Page Page Edit History Backward History Forward Tool ID 40008 32773 32774 40014 40013 40006 32775 32771 40004 40005 32772 32776 40010

Return Type
None

Syntax
Sub Add(Caption As String)

Parameters

ActiveReports 2.0 Standard User's Guide | 448

Name Caption

Type String

Description The tool caption string.

Example
Private Sub btnAddTools_Click() ' arv is the name of an ActiveReports Viewer control With arv.Toolbar.Tools .Addex("Printer Setup").AddIcon("Printer.ico") ' Must set the ID property .Item(.Count 1).ID = 999 End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

AddEx

AddEx
Description
Adds a new tool to the tools collection. Note: Remember to set the ID property of a tool after adding or inserting it into the toolbar. The ToolbarClick event will not fire if the tool does not have its ID set.

Return Type
None

Syntax
Sub Add(Caption As String)

Parameters
Name Caption Type String Description The tool caption string.

Example
Private Sub btnAddTools_Click() ' arv is the name of an ActiveReports Viewer control With arv.Toolbar.Tools .Add "Printer Setup" ' Must set the ID property .Item(.Count 1).ID = 999 End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

Count

Count (DDTools)
Description

ActiveReports 2.0 Standard User's Guide | 449

Returns the number of tools in the collection.

Return Type
Long

Syntax
Function Count() As Long

Parameters
None

Example
Private Sub btnAddTools_Click() ' arv is the name of an ActiveReports Viewer control With arv.Toolbar.Tools .Add "Printer Setup" ' Must set the ID property .Item(.Count 1).ID = 999 End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

Insert

Insert (DDTools)
Description
Inserts a new tools into the tools collection at the specified index.

Return Type
None

Syntax
Sub Insert(Index As Integer, Caption As String)

Parameters
Name Index Caption Type Integer String Description Index of the tool where the tool is to be inserted. The new tools is inserted after the specified index. Caption string of the new tool

Example
Private Sub AddPrinterSetup() ' Inserts a new Printer Setup tool ' after the Print Tool arv.Toolbar.Tools.Insert 2, "Printer Setup" arv.Toolbar.Tools(3).ID = 999 End Sub

Item

Item (DDTools)

ActiveReports 2.0 Standard User's Guide | 450

Description
Returns a reference to the tool object at the specified index.

Return Type
DDTool

Syntax
Function Item(Index As Integer) As DDTool

Parameters
Name Index Type Integer Description Index of the tool to return

Example
Private Sub btnAddTools_Click() ' arv is the name of an ActiveReports Viewer control With arv.Toolbar.Tools .Add "Printer Setup" ' Must set the ID property .Item(.Count-1).ID = 999 End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

DDTool Properties

DDTool Properties
Property Caption Checked Enabled ID Style Tooltip Type Visible Data Type String Boolean Boolean Integer Integer String Integer Boolean Description Caption string of the tool. Determines the checked state of the tool. Determines whether the tool is enabled or not. Returns the index of the tool. Sets or returns the type of button to use. A button with just an icon or a button with an icon and text. Sets or returns the string to be displayed when the mouse hovers over the tool. Sets or returns the type of the tool (0-Button, 1Checkbox, 2-Separator) Determines whether the tool is displayed on the toolbar.

Caption

Caption (DDTool)
Description
Sets or returns caption string of the tool, command button or checkbox.

Data Type

ActiveReports 2.0 Standard User's Guide | 451

String

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub btnAddTools_Click() arv.ToolBar.Tools.Add "Printer Setup" End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

Checked

Checked
Description
Determines the checked state of a checked button tool. This property applies to custom checked button tool added using Add or Insert.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
Private Sub AddTools() With arv.Toolbar .Tools.Add "Display Tooltips" ' Checkbox .Tools(.Tools.Count-1).Type = 1 .Tools(.Tools.Count-1).Checked = .DisplayTooltips End With End Sub

Enabled

Enabled (DDTool)
Description
Determines whether a tool is enabled (True) or disabled (False).

Data Type
Boolean

Availability

ActiveReports 2.0 Standard User's Guide | 452

Design time Run time

Read / Write Read / Write

Example
' Disable the Print Button arv.Toolbar.Tools(2).Enabled = False

ID

ID
Description
Returns the tool id in the tools collection. Tools ID number in between 5100 and 5200 are reserved for the built-in tools. You can change the behavior of built-in tools by changing the ID property and handling the ToolbarClick event.

Data Type
Long

Availability
Design time Run time Read / Write Read / Write

Example
Private CancelJob As Boolean Private Const CONST_PRINTTOOLID As Long = 999 Private Sub ActiveReport_ReportStart() Dim bReturn As Boolean Dim cnt As Integer ' This overrides the print tool For cnt = 0 To Me.Toolbar.Tools.Count-1 If "&Print..." = Me.Toolbar.Tools(cnt).Caption Then Me.Toolbar.Tools(cnt).ID = CONST_PRINTTOOLID End If Next cnt End Sub ' This catches the print tool and shows a custom printdialog, and prints manually Private Sub ActiveReport_ToolbarClick(ByVal tool As DDActiveReports2.DDTool) Dim bReturn As Boolean If CONST_PRINTTOOLID = tool.ID Then ' They clicked the "&Print..." button bReturn = Me.Printer.PrintDialog(Me.hWnd) If bReturn Then Me.PrintReport False ElseIf Not bReturn Then CancelJob = True End If End If End Sub ' This enables the Print tool after the report finishes processing. Private Sub ActiveReport_ReportEnd() Dim cnt As Long For cnt = 0 To Me.Toolbar.Tools.Count-1 If "&Print..." = Me.Toolbar.Tools(cnt).Caption Then Me.Toolbar.Tools(cnt).Enabled = True End If Next cnt

ActiveReports 2.0 Standard User's Guide | 453


End Sub

Style

Style (DDTool)
Description
Sets or returns the type of button to use. Setting the style to 0 will show the button with just an Icon. Setting the style to 1 will show the button with an icon and caption.

Data Type
Integer

Settings
Value 0 1 Description Show just the icon. Show both the icon and the caption.

Availability
Design time Run time Read / Write Read / Write

Example
arv.ToolBar.Tools.Insert 4, "O&pen" arv.ToolBar.Tools.Item(4).AddIcon LoadPicture(App.Path & "\openfold.ico") arv.ToolBar.Tools.Item(4).Tooltip = "Open RDF File" arv.ToolBar.Tools.Item(4).Style = 1

Tooltip

Tooltip
Description
Sets or returns the tooltip help text to be displayed when the mouse hovers over the tool.

Data Type
String

Availability
Design time Run time Read / Write Read / Write

Example
' Add an Export to RTF button arv.Toolbar.Tools.Add "RTF" arv.Toolbar.Tools(arv.Toolbar.Tools.Count-1).Tooltip = _ "Export Report to RTF"

ActiveReports 2.0 Standard User's Guide | 454

Type

Type (DDTool)
Description
Sets or returns the specified tool's type.

Data Type
Integer

Availability
Design time Run time Read / Write Read / Write

Settings
Value 0 1 2 8 16 Description Specifies a command button Specifies a checked button Specifies a separator Specifies the Page Textbox and Zoom Combobox (read-only) Specifies the Multipage button (read-only)

Example
Private Sub AddTools() With arv.Toolbar .Tools.Add "Display Tooltips" ' Checked Button .Tools(.Tools.Count-1).Type = 1 .Tools(.Tools.Count-1).Checked = .DisplayTooltips End With End Sub

Visible

Visible (DDTool)
Description
Determines whether the tool is visible on the toolbar or not.

Data Type
Boolean

Availability
Design time Run time Read / Write Read / Write

Example
arv.Toolbar.Tools(2).Visible = False

DDTool Methods

ActiveReports 2.0 Standard User's Guide | 455

DDTool Methods
Method AddIcon Description Attaches an Icon to the indicated tool. Sub AddIcon(Picture As StdPicture)

AddIcon

AddIcon
Description
Attaches an icon to the indicated or added tool.

Return Type
None

Syntax
Sub AddIcon(Picture As StdPicture)

Parameters
Name Picture Type StdPicture Description Path or reference to the icon file.

Example
Private Sub addButtonsToARV() 'Insert the Save button in the sixth 'position and assign it an icon and 'disable it arv.ToolBar.Tools.Insert 5, "&Save" arv.ToolBar.Tools.Item(5).AddIcon LoadPicture("tfsave.ico") arv.ToolBar.Tools.Item(5).Tooltip = "Save Report to RDF" arv.ToolBar.Tools.Item(5).Enabled = False End Sub

You might also like