Top Banner

of 455

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

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 ContentsUser'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 GuideIntroduction 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

IntroductionActiveReports 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' DocumentationDocument Conventions Documentation Overview Sample Reports

Document Conventions

Document ConventionsThis 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 OverviewActiveReports' documentation consists of two separate manuals.

Developer's GuideThe 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 ManualThe 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 FeaturesActiveX DesignerActiveReports 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 interfaceActiveReports 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 LanguageActiveReports 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 OverheadActiveReports' 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 ModelActiveReports 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 EngineActiveReports 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 objectsThe viewer contains a programmable table of contents tree allowing users to quickly jump between report sections.

Lightweight, Internet-enabled, ActiveX ControlThe 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 ExportsActiveReports 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 Knowledgebasehttp://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 FeaturesEnhanced 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 OverviewFormatA 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 ProcessingThe 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 ProcessActiveReports 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 EventsRegardless 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 ActiveReportsInstallation Steps Sample Reports Client Distribution

Installation Steps

Installation Steps1. Select RUN from the Windows Start Menu. 2. Type \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 ReportsThe 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.

1718 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 DistributionYou 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 DistributionTo 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 TimeAdding 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 BasicActiveReports 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 EnvironmentTo 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 InterfaceActiveReports' 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

ToolbarsThe 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 ToolbarClick the grab handle to a new location. for docked toolbars or the title bar for floating toolbars, and drag the toolbar

Toolbar's Context MenuTo 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 ToolbarButton 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 ToolbarButton 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.

ToolboxButton 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 ToolbarButton 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 ToolbarButton 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 MenusContext 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 ExplorerActiveReports 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 ListThe 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 ReportTo 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 objectsActiveReports 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 ControlsYou 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 ControlsTo 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 SectionsYou 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

l

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.

l

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

and dragging it up or

l

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.

l

Control Alignment and Sizing

Control Alignment and SizingControl 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.

l

Click the Align Left

, Center

or Right

to align the controls as shown below:

ActiveReports 2.0 Standard User's Guide | 40

l

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

Formatting Controls

Formatting ControlsSetting Font PropertiesTo 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 ColorsForeground 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 Style1. 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 FormatsActiveReports 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 Report1. 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 \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 PreviewYou 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' WizardActiveReports' 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 \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.0By 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 ReportsAccess 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 ReportsReports 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 DialogWith 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 DialogWith 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 CodeWith 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.

DeviceNameBy 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.

OrientationA 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 | 48PageSettings.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.

PaperSizeThe 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.

MarginsA 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.

PrintWidthModifying 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 ControlsUsing 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 ConnectionYou 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=;[UID=;][PWD=]

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 ConnectionYou 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 serverDRIVER={SQL Server};SERVER=MySQLServer;DATABASE=pubs;UID=sa;PWD=admin;

MS AccessDRIVER={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 Access1. 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=;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 Files1. 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.01. 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 SQLOLEDB1. 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 PropertiesIn 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 ControlActiveReports 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 GroupingSimple 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 ReportsThe 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 ReportsThis 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:

1. Continuing with the sample started above, make the following modification to the DataControl's source property:SELECT * FROM customers WHERE customerID ="''"

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 RecordsUsing 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 ExpressionMany 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 FooterSummary 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:

SummaryTypeSpecifies 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

SummaryFuncSets 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.

SummaryGroupCalculates 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.

SummaryRunningCalculates 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 FieldsSome 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/1996Last 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/1996Country 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