83791925 Active Report 2 0 Standard Edition

455
ActiveReports 2.0 Standard User's Guide ActiveReports 2.0 Standard User's Guide | 1

Transcript of 83791925 Active Report 2 0 Standard Edition

Page 1: 83791925 Active Report 2 0 Standard Edition

ActiveReports 2.0 Standard User's Guide

ActiveReports 2.0 Standard User's Guide | 1

Page 2: 83791925 Active Report 2 0 Standard Edition

Table Of ContentsUser's Guide 23

Introduction 23

Using ActiveReports' Documentation 23

Document Conventions 23-24

Documentation Overview 24

ActiveReports 2.x Features 24-26

ActiveReports 2.0 Architectural Overview 26-28

Chapter 1 - Installation 28

Installation Steps 28

Sample Reports 29-30

Client Distribution 30

Chapter 2 - Using ActiveReports for the First Time 30-31

Adding ActiveReports to Visual Basic 31

Adding a Report to the Visual Basic Environment 31-32

User Interface 32

Toolbars 32-35

Context Menus 35-36

Report Explorer 36

Fields List 36

Adding Controls to Your Report 36

Adding ActiveX controls and OLE objects 36-37

Selecting Multiple Controls 37-38

Moving and Sizing Controls 38

Sizing Sections 38-39

Control Alignment and Sizing 39-40

Formatting Controls 40-41

Quick Start -Creating Your First Report 41-42

Using ActiveReports' Print Preview 42-43

Using ActiveReports' Wizard 43-44

Converting Version 1.0 Reports to Version 2.0 44

Converting Access Reports 44-45

Converting Crystal Reports 45

Chapter 3 - Printer and Page Settings 45-46

Using the Page Setup Dialogue 46

Using the Printer Settings Dialogue 46-47

Changing Page and Printer Setting in Code 47-50

ActiveReports 2.0 Standard User's Guide | 2

Page 3: 83791925 Active Report 2 0 Standard Edition

Chapter 4 - Binding Reports to Data Controls 50

RDO (Remote Data Objects) 50-51

DAO (Data Access Objects) 51

ADO (ActiveX Data Objects) 51-52

XML 52-53

Setting Recordset and Connection Properties 53

Binding Controls to a Data Control 53-54

Chapter 5 - Bound Reporting and Grouping 54

Simple Table or List Report 54-55

Using Parameters With Bound Reports 55-56

Grouping Records 56-57

Grouping on Calculated Expression 57

Adding a Summary Field in Group Footer 57-59

Conditional Summary Fields 59-62

Using Formulas and Calculated Fields 62-63

Page N of M in the Page Footer 63-64

Page N of M in the Group Header 64-65

Chapter 6 - Unbound Reporting and Grouping 65

Unbound Reports 65

Simple Unbound Reports 65-67

Grouping With Unbound Reports 67

Adding Summary Fields to Unbound Reports 67-68

Unbound Reporting with Arrays 68-70

Unbound Reporting with Collections 71-72

Unbound Reporting with Text Files 72-74

Chapter 7 - Using Subreports 74

Subreports 74-75

Bound Subreports 75-78

Using Parameters with Subreports 78

Embedded Subreports 78-83

Shaped/Hierarchical Subreports 83-87

Unbound Subreports 88-93

Chapter 8 - Dynamic (Run-Time) Reporting 93

Modifying and Formatting Controls at Run Time 93

Creating Dynamic Reports 93-94

Dynamic Reports 94-97

Chapter 9 - Creating Reports from an XML Document 97

Bound XML Data Reports 97-98

ActiveReports 2.0 Standard User's Guide | 3

Page 4: 83791925 Active Report 2 0 Standard Edition

XML Data Reports and Subreports 98-102

XML Reports using LoadXML 102

Chapter 10 - Additional Report Types 102-103

Top n Reports 103

Master Detail Reports 103

Summary Reports 103-104

Mail-Merge Reports 104

Columnar Reports 104

Creating Labels 104-105

Conditional Printing 105

Green-Bar Printout Reports 105

Multi-Page Sections 105

Charts 105-106

Multiple Records Per Section 106

Modifying the Pages Collection of a Processed Report 106

Report Coding Tips 106-107

Chapter 11 - Organizing Reports with the TOC and Frame Control 107

Setting Up a Table of Contents 107-108

Using the TOC with Subreports 108-109

Using the TOC with Groups 109-110

Working with the Frame Control 110

Using the Frame Control for a Table 110-111

Chapter 12 - Hyperlinking, CSS and ActiveReports 111-112

Using Hyperlinks 112

Using HTML links 112-113

Using Hyperlinks for Drill-Down reports 113-115

Using Hyperlinks with the TOC 115-117

Using the MouseOver event with Hyperlinks 117-118

Using CSS 118

Creating Global Styles 118-119

Using Special CSS Styles 119

Chapter 13 - Saving and Loading 119-120

Saving And Loading RDF Files 120-122

Using ActiveReports' Export Filters 122-124

Saving and Loading Canvas Files 124

Saving and Loading Report Layouts 124-125

Saving and Loading to a Byte Array 125

Chapter 14 - Scripting 125

ActiveReports 2.0 Standard User's Guide | 4

Page 5: 83791925 Active Report 2 0 Standard Edition

What are Scripts for? 125-126

How to Add Scripts 126-127

Working With Scripts 127-129

Using RPX Files 129-130

Chapter 15 - Using ActiveReports' ActiveX Viewer Control 130

ActiveReports' ActiveX Viewer Control 130-131

Adding the Viewer Control to VB 131

Creating a Custom Preview Screen 131-132

Using Split Windows on the Viewer Control 132-133

Adding Buttons to the Viewer Control 133-136

Controlling Printing and Printer Setup on the Viewer 136-137

Chapter 16 - ActiveReports on the Web 137

Using the Viewer Control with Internet Explorer 137-138

Using the Java Viewer Control 138-139

Creating a ReportServer with ASP and ActiveReports 139

Support and Licensing 142

Production Registration 142

Technical Support 142-143

Web Site 143

NewsGroups 143

Product Upgrades 143

Suggestions 143

Disk Defects Policy 143-144

License Agreement and Limited Warranty 144-145

ActiveReports Error Codes 145-147

Reference 148

Constants 148-156

ActiveReports' Architecture 156

Report Sections 156-157

Report Processing 158

Events 158

Reports Passes 158-159

Printing Process 159

Common Properties 159

BackColor 159-160

BackStyle 160

DataField 160-161

Font 161-162

ActiveReports 2.0 Standard User's Guide | 5

Page 6: 83791925 Active Report 2 0 Standard Edition

ForeColor 162

Common Methods 162

ZOrder 162-163

ActiveReport 163

ActiveReport Properties 163-165

AllowSplitter 165

Canvas 165-166

DocumentName 166

Fields 166-167

LayoutAction 167-168

MaxPages 168

PageBorder 168-169

PageNumber 169

Pages 169-170

Parameters 170-171

ParentReport 171

Printer 171-172

PrintWidth 172

RulerVisible 172-173

Sections 173

Script 173-174

ScriptDebuggerEnabled 174-175

ScriptLanguage 175

ShowMessages 175-176

ShowParameterUI 176

Status 176-177

TOC 177

TOCEnabled 177-178

TOCVisible 178

TOCWidth 178

ToolbarVisible 178-179

UserData 179

Version 179

WaterMark 180

WaterMarkAlignment 180-181

WaterMarkPrintOnPages 181

WaterMarkSizeMode 181-182

Zoom 182

ActiveReports 2.0 Standard User's Guide | 6

Page 7: 83791925 Active Report 2 0 Standard Edition

ActiveReport Methods 182-183

About 183

AddCode 183-184

AddControlLicense 184-185

AddNamedItem 185

Cancel 185-186

Export 186

LoadLayout 186-187

Localize 187-188

PageSetup 188

PrintReport 188-189

ResetScripts 189

Restart 189-190

Run 190

SaveLayout 190-191

Stop 191

ActiveReport Events 191-192

DataInitialize 192-193

Error 193-194

FetchData 194

FindProgress 194-195

HyperLink 195

KeyDown 195-196

KeyPress 196

KeyUp 196

MouseOver 196-197

NoData 197

PageEnd 197-198

PageStart 198

PrintAborted 198

PrintProgress 198-199

PromptDialogClosed 199

ReportEnd 199-200

ReportStart 200

TOCClick 200

TOCSelChange 200-201

ToolbarClick 201

ARViewer Control 201

ActiveReports 2.0 Standard User's Guide | 7

Page 8: 83791925 Active Report 2 0 Standard Edition

ARViewer Properties 201-202

AllowSplitter 202

BackColor 202-203

BorderStyle 203

DataPath 203-204

Object 204

Pages 204-205

PaperColor 205

Printer 205

ReportSource 206

RulerVisible 206

Status 206-207

TOC 207

TOCEnabled 207-208

TOCVisible 208

TOCWidth 208-209

ToolBar 209

ToolbarVisible 209

UseSourcePrinter 209-210

Zoom 210

ARViewer Methods 210-211

CopyPageToClipboard 211

Find 211-212

Localize 212-213

MultiplePage 213

PrintReport 213-214

Refresh 214

SinglePage 214

ARViewer Events 215-216

DblClk 216

Error 216-217

FindProgress 217

hyperLink 218

KeyDown 218

KeyPress 218-219

KeyUp 219

LoadCompleted 219

MouseDown 219-220

ActiveReports 2.0 Standard User's Guide | 8

Page 9: 83791925 Active Report 2 0 Standard Edition

MouseMove 220

MouseOver 220-221

MouseUp 221

PageModeChanged 221

PrintAborted 221-222

TOCClick 222

TOCSelChange 222-223

ToolbarClick 223

ZoomChanged 223

Border Properties 223-224

BottomColor, LeftColor, RightColor, TopColor 224

BottomStyle, LeftStyle, RightStyle, TopStyle 224-225

Shadow 225

Canvas 225

Canvas Properties 225-226

Alignment 226

BackColor (Canvas) 226-227

BackStyle (Canvas) 227

Font (Canvas) 227-228

ForeColor (Canvas) 228

Height 228-229

Orientation 229

PenStyle 229-230

PenWidth 230

Tag 230-231

TextAngle 231

VerticalAlignment 231-232

Width 232

Canvas Methods 232-234

Clear 234

DrawEllipse 234-235

DrawLine 235

DrawPicture 235-236

DrawPictureLink 236

DrawRect 236-237

DrawRoundRect 237

DrawText 238

DrawTextLink 238-239

ActiveReports 2.0 Standard User's Guide | 9

Page 10: 83791925 Active Report 2 0 Standard Edition

FillRect 239

IntersectClipRect 239-240

Load 240-241

MeasureParagraphHeight 241-242

MeasureText 242

Overlay 242-243

PopClipRect 243-244

PushClipRect 244

Save 244-245

TextOut 245

Controls 245-246

Controls Methods 246

Add 246-247

Count 247-248

Item 248

Remove 248

RemoveAll 248-249

BarCode Control Properties 249

Alignment 249-250

BackColor 250

BarWidth 250-251

Caption 251

CaptionPosition 251-252

DataField 252

Direction 252-253

EnableCheckSum 253

Font (BarCode) 253-254

ForeColor (BarCode) 254

Style 254-256

Checkbox Properties 256

Alignment 256-257

BackColor (Checkbox) 257

BackStyle (Checkbox) 257-258

Caption 258

Font (Checkbox) 258

ForeColor (Checkbox) 259

Style 259-260

Value 260

ActiveReports 2.0 Standard User's Guide | 10

Page 11: 83791925 Active Report 2 0 Standard Edition

Field Control Properties 260-261

Alignment 261-262

BackColor (Field) 262

BackStyle (Field) 262-263

CanGrow 263

CanShrink 263-264

ClassName 264

DataField (Field) 264-265

DataValue 265

Font (Field) 265-266

ForeColor (Field) 266

hyperLink 266-267

Multiline 267

OutputFormat 267-268

Style 268

SummaryDistinctField 268-269

SummaryDistinctValue 269

SummaryFunc 269-270

SummaryGroup 270

SummaryRunning 270-271

SummaryType 271-272

Text 272

VerticalAlignment 272-273

WordWrap 273

ZOrder (Field) 273-274

Frames and Panes 274

Frame Control Properties 274

BackColor 274-275

CanGrow 275

CanShrink 275-276

CloseBorder 276

Panes 276-277

ZOrder (Frame) 277-278

Panes 278

Pane Properties 278

BackColor 278

BackStyle 278-279

Border 279

ActiveReports 2.0 Standard User's Guide | 11

Page 12: 83791925 Active Report 2 0 Standard Edition

CloseBorder 279-280

Controls 280

Pane Methods 280

Add 280-281

Count 281-282

Item 282

Remove 282

Image Properties 282-283

BackColor (Image) 283

BackStyle (Image) 284

ForeColor (Image) 284-285

hyperLink 285

LineColor 285

LineStyle 285-286

LineWeight 286

Picture 287

PictureAlignment 287

SizeMode 287-288

ZOrder (Image) 288-289

Label Control Properties 289-290

Alignment 290

Angle 290-291

BackColor (Label) 291

BackStyle (Label) 291-292

Caption 292

ClassName 292

Font (Label) 292-293

ForeColor (Label) 293

hyperLink 294

Multiline 294

Style 294-295

VerticalAlignment 295

WordWrap 295-296

ZOrder (Label) 296-297

Line Properties 297

LineColor 297-298

LineStyle 298

LineWeight 298-299

ActiveReports 2.0 Standard User's Guide | 12

Page 13: 83791925 Active Report 2 0 Standard Edition

X1 299

X2 299-300

Y1 300

Y2 300

ZOrder (Line) 300-301

OLE Control 301

OLE Object Properties 301-302

BackColor (OLE) 302

BackStyle (OLE) 302-303

Class 303

Object 303-304

PictureAlignment 304

SizeMode 304-305

VerbCount 305

ZOrder (OLE) 305-306

OLE Object Methods 306-307

CreateEmbedded 307

DoVerb 307-308

GetUserType 308

GetVerbID 308

GetVerbName 308-309

InsertObject 309

PageBreak Control Properties 309-310

Enabled 310

RTF Text Control 310

RTF Text Control Properties 310-311

BackStyle 311-312

BulletIndent 312

CanGrow 312-313

CanShrink 313

GetTab 313

MaxLength 313-314

Multiline 314

SelAlignment 314-315

SelBold 315

SelBullet 315

SelCharOffset 315-316

SelColor 316

ActiveReports 2.0 Standard User's Guide | 13

Page 14: 83791925 Active Report 2 0 Standard Edition

SelFontName 316-317

SelFontSize 317

SelHangingIndent 317

SelIndent 317-318

SelItalic 318

SelLength 318

SelProtected 318-319

SelRightIndent 319

SelStart 319-320

SelStrikeThru 320

SelTabCount 320

SelTabs 320-321

SelText 321

SelTextBackColor 321

SelUnderline 321-322

Tag 322

Text 322

TextRTF 322-323

ZOrder (RTF) 323-324

RTF Text Control Methods 324

Clear 324

Copy 324-325

Cut 325

DeleteField 325

Find 325-326

InsertField 326

LoadFile 326-327

Paste 327

ReplaceField 327-328

SaveFile 328

SelectField 328-329

Shape Control Properties 329

BackColor (Shape) 329

BackStyle (Shape) 329-330

LineColor 330

LineStyle 330-331

LineWeight 331-332

Shape 332

ActiveReports 2.0 Standard User's Guide | 14

Page 15: 83791925 Active Report 2 0 Standard Edition

SubReport Control Properties 332

CanGrow 332-333

CanShrink 333

DataField 333-334

Object 334-335

ReportName 335

ZOrder (SubReport) 335-336

Data Controls 336

ADO 336

ADO Data Control Properties 336-337

CommandTimeOut 337-338

Connection 338

ConnectionString 338-339

ConnectionTimeOut 339-340

CursorLocation 340

CursorType 340-341

DataSourceName 341

DefaultDatabase 341

LockType 341-342

MaxRows 342

NRecords 342

Password 343

Provider 343

RecordSet 343-344

Source 344

UserID 344-345

ADO DB Data Control Methods 345

Refresh 345

DAO 345

DAO Data Control Properties 345-346

Connect 346-347

DatabaseName 347

DefaultCursorType 347

DefaultType 347-348

Exclusive 348

MaxRows 348-349

Options 349

Password 349-350

ActiveReports 2.0 Standard User's Guide | 15

Page 16: 83791925 Active Report 2 0 Standard Edition

Recordset 350

RecordsetType 350

RecordSource 350-351

SystemDB 351-352

UserName 352

DAO Data Control Methods 352

Refresh 352-353

RDO 353

RDO Data Control Properties 353-354

Connect 354

Connection 354-355

CursorDriver 355

DataSourceName 355-356

Environment 356

ErrorTheshold 356

KeysetSize 356-357

LockType 357

LoginTimeout 357

LogMessages 357-358

MaxRows 358

Options 358

Password 358-359

Prompt 359

QueryTimeout 359-360

Resultset 360

ResultsetType 360

RowsetSize 360-361

SQL 361

UserName 361-362

Version 362

RDO Data Control Methods 362

Refresh 362

XML 363

XML Data Control Properties 363

BOF 363

Count 363-364

CurrentPosition 364

EOF 364-365

ActiveReports 2.0 Standard User's Guide | 16

Page 17: 83791925 Active Report 2 0 Standard Edition

FileURL 365

NodeList 365-366

RecordSetPattern 366-367

ValidateOnParse 367

XML Data Control Methods 367

Field 367-368

LoadXML 368-369

MoveNext 369

Reset 369

History 369

History Properties 369

Count 370

Position 370-371

History Methods 371

Back 371

Forward 371-372

Item 372-373

Pages and PageSettings 373

PageSettings Properties 373

BottomMargin 373-374

Collate 374-375

Duplex 375

Gutter 375-376

LeftMargin 376

MirrorMargins 376-377

Orientation 377

PaperBin 378

PaperHeight 378-379

PaperSize 379-380

PaperWidth 380-381

RightMargin 381

TopMargin 381-382

Pages 382

Pages Properties 382

Password 382-383

Pages Methods 383

Add 383-384

Commit 384-385

ActiveReports 2.0 Standard User's Guide | 17

Page 18: 83791925 Active Report 2 0 Standard Edition

Count 385

GetPagesInRange 385-386

Insert 386

InsertNew 386

Item 386-387

Load 387

Remove 387-388

RemoveAll 388

Save 388-389

PaperSizes Methods 389

Count 389-390

Item 390

Name 390-391

Parameters 391

Parameter Properties 391

DefaultValue 391

Key 392

Prompt 392-393

Tag 393

Value 393-394

Parameters Methods 394

Count 394

Item 394-395

Printer 395

Printer Properties 395-396

Collate (Printer) 396-397

ColorMode 397

Copies 397

DeviceCopies 397-398

DeviceName 398

Devices 398-399

DisplayProgressDialog 399

DPI 399

Duplex (Printer) 399-400

FileName 400-401

FromPage 401

hDC 401

MaxPage 401-402

ActiveReports 2.0 Standard User's Guide | 18

Page 19: 83791925 Active Report 2 0 Standard Edition

NDevices 402

NPorts 402-403

Orientation (Printer) 403

PaperBinNames 404

PaperBins 404-405

PaperHeight (Printer) 405

PaperSizes 405-406

PaperWidth (Printer) 406

Port 406

Ports 406-407

PrintQuality 407

Status 407-408

ToPage 408

TrackDefault 408-409

TwipsPerPixelX, TwipsPerPixelY 409

Printer Methods 409-410

AbortJob 410

EndJob 410

EndPage 410-411

Escape 411-412

PrintPage 412

PrintDialog 412-413

SetupDialog 413-414

StartJob 414-415

StartPage 415

RptFields 415-416

RptFields Properties 416

Name 416

Tag 416

Value 416-417

RptFields Methods 417

Add 417-418

Count 418

Item 418

Remove 418-419

RemoveAll 419

Sections 419

Section Properties 419-421

ActiveReports 2.0 Standard User's Guide | 19

Page 20: 83791925 Active Report 2 0 Standard Edition

BackColor 421

BackStyle 421

CanGrow 422

CanShrink 422

ColumnCount 422-423

ColumnDirection 423

ColumnLayout 424

ColumnSpacing 424

Controls 424-425

DataField 425

GroupValue 425-426

GrpKeepTogether 426

Height 426-427

IsRepeating 427

KeepTogether 427-428

Name 428

NewColumn 428-429

NewPage 429

PrintAtBottom 429-430

Repeat 430

Script 430-431

Type 431-432

UnderlayNext 432-433

Visible 433

Section Methods 433

Add 433-434

Count 434

Item 434-435

Refresh 435

Remove 435

Section Events 435-436

AfterPrint 436

BeforePrint 436

Format 436-437

TOC 437

TOC Properties 437

Count 437-438

CurrentPage 438

ActiveReports 2.0 Standard User's Guide | 20

Page 21: 83791925 Active Report 2 0 Standard Edition

History 438-439

SelectedItem 439

TOC Methods 439

Add 439-440

GotoPage 440-441

Item 441

Navigate 441

PageNumber 442

Remove 442

RemoveAll 442

TOCEntry Properties 443

Name 443

PageNumber 443

PageOffSet 444

Tools and Toolbar 444

DDToolbar Properties 444

DisplayTooltips 444-445

Font 445

Tools 445-446

DDToolbar Methods 446

Refresh 446

DDTools Methods 446-447

Add 447-448

AddEx 448

Count 448-449

Insert 449

Item 449-450

DDTool Properties 450

Caption 450-451

Checked 451

Enabled 451-452

ID 452-453

Style 453

Tooltip 453

Type 453-454

Visible 454

DDTool Methods 454-455

AddIcon 455

ActiveReports 2.0 Standard User's Guide | 21

Page 22: 83791925 Active Report 2 0 Standard Edition

ActiveReports 2.0 Standard User's Guide | 22

Page 23: 83791925 Active Report 2 0 Standard Edition

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

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' DocumentationDocument Conventions

Documentation Overview

Sample Reports

Document ConventionsThis book uses the following typographical conventions:

User's Guide

Introduction

Using ActiveReports' Documentation

Document Conventions

Convention Description

bold Programming language terms in text

ActiveReports 2.0 Standard User's Guide | 23

Page 24: 83791925 Active Report 2 0 Standard Edition

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

italic In Syntax italics indicate placeholders for information you would supply.Dialog box elements are displayed in italics

Embedded Caps

Language terms are capitalized for readability. The language is not case sensitive.

monospace font

Code Syntax and Examples

Keyboard Shortcuts

Delete means the Delete or Del key on your numeric keypadEscape means the Escape or Esc key on your keyboardEnter means Enter, Return, or the Carriage Return key on your keyboardCtrl-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.

Mouse Actions Click: Click the primary (left) mouse button onceRight-click: Click the secondary (right) mouse button onceDouble-click: Click the primary (left) mouse button twice without moving the mouse while clickingShift-click: Press and hold the SHIFT key on your keyboard and click the primary (left) mouse button

Documentation Overview

ActiveReports 2.x Features

ActiveReports 2.0 Standard User's Guide | 24

Page 25: 83791925 Active Report 2 0 Standard Edition

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 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 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 drop-down 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 | 25

Page 26: 83791925 Active Report 2 0 Standard Edition

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 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 Architectural Overview

ActiveReports 2.0 Standard User's Guide | 26

Page 27: 83791925 Active Report 2 0 Standard Edition

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, multi-threaded, 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 | 27

Page 28: 83791925 Active Report 2 0 Standard Edition

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 - Installing ActiveReportsInstallation Steps

Sample Reports

Client Distribution

Installation Steps1. 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.

Chapter 1 - Installation

Installation Steps

ActiveReports 2.0 Standard User's Guide | 28

Page 29: 83791925 Active Report 2 0 Standard Edition

12. You are now ready to use ActiveReports 2.

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:

Sample Reports

# Name Description

1 Annual Report Demonstrates subreports, page-break and green bar printing.

2 Catalog (Custom Preview) Demonstrates record grouping, page-break, OLE object binding, drawing with lines and shapes.

3 Category Selection Demonstrates record grouping, query modification and summary functions.

4 Custom Preview Demonstrates OLE, Charting, Grouping, Mail Merge, and labels.

5 Customer Labels (Custom Preview)

Demonstrates label printing, column layouts, can grow, and can shrink properties.

6 Customer Letters (Custom Preview)

Demonstrates Mail Merge.

7 Customer Phonebook Demonstrates, custom unbound grouping, column layout and "Continued .." on each page.

8 Drill -Down Demonstrates hyperlinks and Drill-Down.

9 Employee Profiles (Custom Preview)

Demonstrates OLE Image control

10 Employee Sales By Country Extensive totals, percentage of totals, delayed printing and conditional printing at run time.

11 Invoice (Custom Preview) Demonstrates standard master-detail printing and setting recordsets at run-time from VB code.

12 Price List By Category Demonstrates record grouping and bound OLE objects.

13 Print Bound DBGrid Demonstrates using DBGrid.

14 Print MSFlex Grid Demonstrates using MSFlexGrid.

15 Product Categories Demonstrates record grouping using linked subreports in the detail section.

16 Product Inventory Demonstrates different formatting options, record grouping and repeating group headers.

17 Product Price List Demonstrates "Continued.." in page footer.

18 Product Weekly Sales A more complex sample showing programmable objects, cross tab and delayed printing.

19 RDFViewer Demonstrates customizing the viewer control.

20 RDO Sample Demonstrates using RDO, record grouping.

21 ReportDLL Demonstrates setting up a report server dll.

22 Running Sales By Customer Demonstrates a variety of summarization options including subtotals and running total within groups.

23 Scripting Demonstrates a variety of scripting procedures.

24 SecureMDB Demonstrates using a secured database.

25 Students and Classes Demonstrates simple lists, grouped master detail and programmable shape control to display a graph.

26 Tutor Variety of step by step reports.

ActiveReports 2.0 Standard User's Guide | 29

Page 30: 83791925 Active Report 2 0 Standard Edition

Client DistributionYou need to include the following files on all clients when distributing your reports in an application.

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

27 Unbound Demonstrates using ActiveReports in unbound report from a variety of data sources.

28 XML Demonstrates a variety of XML procedures.

Client Distribution

File Name Description

ActRpt2.DLL The Reporting Engine (AR2Pro.dll For Professional Edition)

AB2DLL.dll The ActiveBar dll (For Professional Edition End User Designer projects)

ARVIEW2.ocx Only if you are using our ActiveX Viewer

PDFExpt.DLL PDF Export Filter (when using PDF exporting)

RTFExpt.DLL RTF Export Filter (when using RTF exporting; also to enable the copy button on the viewer)

ExclExpt.DLL Excel Export Filter (when using Excel exporting)

TextExpt.DLL Text Export Filter (when using Text exporting)

HTMLExpt.DLL HTML Export Filter (when using HTML exporting)

TiffExpt.dll Tiff Export Filter (when using Tiff exporting)

Chapter 2 - Using ActiveReports for the First Time

ActiveReports 2.0 Standard User's Guide | 30

Page 31: 83791925 Active Report 2 0 Standard Edition

Converting Access Reports

Converting Crystal Reports

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 EnvironmentTo add a new report to your project:

1. Click the Project menu in Visual Basic.

Adding ActiveReports to Visual Basic

Adding a Report to the Visual Basic Environment

ActiveReports 2.0 Standard User's Guide | 31

Page 32: 83791925 Active Report 2 0 Standard Edition

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

User Interface

Toolbars

ActiveReports 2.0 Standard User's Guide | 32

Page 33: 83791925 Active Report 2 0 Standard Edition

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 Toolbar

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

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 Toolbar

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

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 | 33

Page 34: 83791925 Active Report 2 0 Standard Edition

Toolbox

Alignment Toolbar

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.

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.

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 | 34

Page 35: 83791925 Active Report 2 0 Standard Edition

Print Preview Toolbar

Context MenusContext Menus can be accessed by right clicking on the report.

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.

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

Menu Item Function

Insert > Group Header/Footer

Adds a new group header/footer pair to the report.

Insert > Page Header / Footer

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.

Insert > Report Header / Footer

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.

Delete Section Deletes the current selected section from the report. This option does not apply to the Detail section in the report.

Reorder Groups 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.

Cut Cuts the selected control to the clipboard.

Copy Copies the selected control to the clipboard

Paste Pastes the contents of the clipboard into the current section.

ActiveReports 2.0 Standard User's Guide | 35

Page 36: 83791925 Active Report 2 0 Standard Edition

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

Bring to Front Brings the selected control to the top of the Z-Order

Send to Back Sends the selected control to the bottom of the Z-Order

Align Aligns controls to any of their vertical or horizontal coordinates.

Size Sizes the controls to same width, height or both.

Format Border Displays the border dialog box.

Report Explorer

Fields List

Adding Controls to Your Report

Adding ActiveX controls and OLE objects

ActiveReports 2.0 Standard User's Guide | 36

Page 37: 83791925 Active Report 2 0 Standard Edition

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 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:

Selecting Multiple Controls

ActiveReports 2.0 Standard User's Guide | 37

Page 38: 83791925 Active Report 2 0 Standard Edition

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

Moving and Sizing Controls

Sizing Sections

ActiveReports 2.0 Standard User's Guide | 38

Page 39: 83791925 Active Report 2 0 Standard Edition

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 and dragging it up or down to adjust the height.

l Double clicking on the section thumb allows you to quickly set the section height to precisely fit its contents.

l 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 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:

Control Alignment and Sizing

ActiveReports 2.0 Standard User's Guide | 39

Page 40: 83791925 Active Report 2 0 Standard Edition

l Follow similar steps to vertically align or size the selected 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.

Formatting Controls

ActiveReports 2.0 Standard User's Guide | 40

Page 41: 83791925 Active Report 2 0 Standard Edition

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

Quick Start -Creating Your First Report

ActiveReports 2.0 Standard User's Guide | 41

Page 42: 83791925 Active Report 2 0 Standard Edition

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 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 rptProductInventoryByCategorySet rpt = new rptProductInventoryByCategoryrpt.show

End Sub Private Sub btnPreviewProductList_Click()

Dim rpt As rptProductPriceListSet rpt = new rptProductPriceListrpt.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.

Using ActiveReports' Print Preview

ActiveReports 2.0 Standard User's Guide | 42

Page 43: 83791925 Active Report 2 0 Standard Edition

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 icon on the 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.

Using ActiveReports' Wizard

ActiveReports 2.0 Standard User's Guide | 43

Page 44: 83791925 Active Report 2 0 Standard Edition

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

Converting Version 1.0 Reports to Version 2.0

Converting Access Reports

ActiveReports 2.0 Standard User's Guide | 44

Page 45: 83791925 Active Report 2 0 Standard Edition

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

Converting Crystal Reports

Chapter 3 - Printer and Page Settings

ActiveReports 2.0 Standard User's Guide | 45

Page 46: 83791925 Active Report 2 0 Standard Edition

Using the Page Setup Dialog

Using the Printer Settings Dialog

Changing Page and Printer Settings in Code

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

Using the Page Setup Dialogue

Using the Printer Settings Dialogue

ActiveReports 2.0 Standard User's Guide | 46

Page 47: 83791925 Active Report 2 0 Standard Edition

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 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 BooleanPrivate Sub ActiveReport_ReportStart()

If lFlag Then

Changing Page and Printer Setting in Code

ActiveReports 2.0 Standard User's Guide | 47

Page 48: 83791925 Active Report 2 0 Standard Edition

PageSettings.Orientation = ddOLandscapeElse

PageSettings.Orientation = ddOPortraitEnd 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 BooleanIf bFlag Then

PageSettings.Orientation = ddOPortraitbFlag = False

ElsePageSettings.Orientation = ddOLandscapebFlag = True

End IfEnd 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 Description

1 Letter, 8 1/2 x 11 in

2 +A611Letter Small, 8 1/2 x 11 in

3 Tabloid, 11 x 17 in

4 Ledger, 17 x 11 in

5 Legal, 8 1/2 x 14 in

6 Statement, 5 1/2 x 8 1/2 in

7 Executive, 7 1/2 x 10 1/2 in

8 A3, 297 x 420 mm

9 A4, 210 x 297 mm

10 A4 Small, 210 x 297 mm

11 A5, 148 x 210 mm

12 B4, 250 x 354 mm

13 B5, 182 x 257 mm

14 Folio, 8 1/2 x 13 in

15 Quarto, 215 x 275 mm

16 10 x 14 in

17 11 x 17 in

18 Note, 8 1/2 x 11 in

19 Envelope #9, 3 7/8 x 8 7/8 in

20 Envelope #10, 4 1/8 x 9 1/2 in

21 Envelope #11, 4 1/2 x 10 3/8 in

22 Envelope #12, 4 1/2 x 11 in

23 Envelope #14, 5 x 11 1/2 in

24 C size sheet

25 D size sheet

26 E size sheet

ActiveReports 2.0 Standard User's Guide | 48

Page 49: 83791925 Active Report 2 0 Standard Edition

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 + 1If pgCounter > 1 Then

PageSettings.PaperSize = 1 'LetterEnd If

End Sub Private Sub ActiveReport_ReportStart()

PageSettings.PaperSize = 5 'LegalEnd 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 PaperSizePageSettings.PaperHeight = 6 * 1440 'Six inchesPageSettings.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 InchPageSettings.TopMargin = 2880 '2 InchesPageSettings.LeftMargin = 720 '1/2 InchPageSettings.RightMargin = 720 '1/2 Inch

End Sub

27 Envelope DL, 110 x 220 mm

29 Envelope C3, 324 x 458 mm

30 Envelope C4, 229 x 324 mm

28 Envelope C5, 162 x 229 mm

31 Envelope C6, 114 x 162 mm

32 Envelope C65, 114 x 229 mm

33 Envelope B4, 250 x 353 mm

34 Envelope B5, 176 x 250 mm

35 Envelope B6, 176 x 125 mm

36 Envelope, 110 x 230 mm

37 Envelope Monarch, 3 7/8 x 7 1/2 in

38 Envelope, 3 5/8 x 6 1/2 in

39 U.S. Standard Fanfold, 14 7/8 x 11 in

40 German Standard Fanfold, 8 1/2 x 12 in

41 German Legal Fanfold, 8 1/2 x 13 in

255 User Defined

ActiveReports 2.0 Standard User's Guide | 49

Page 50: 83791925 Active Report 2 0 Standard Edition

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 marginsMe.PrintWidth = 11 * 1440 - (PageSettings.LeftMargin

+ PageSettings.RightMargin) '11 inchesEnd 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 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)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=<dsn>;[UID=<userid>;][PWD=<password>]

Chapter 4 - Binding Reports to Data Controls

RDO (Remote Data Objects)

ActiveReports 2.0 Standard User's Guide | 50

Page 51: 83791925 Active Report 2 0 Standard Edition

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)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=<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 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)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.

DAO (Data Access Objects)

ADO (ActiveX Data Objects)

ActiveReports 2.0 Standard User's Guide | 51

Page 52: 83791925 Active Report 2 0 Standard Edition

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 (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:

XML

Pattern Description

ActiveReports 2.0 Standard User's Guide | 52

Page 53: 83791925 Active Report 2 0 Standard Edition

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 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 timeDim cn As ADODB.Connection ' ADO ConnectionDim rs As ADODB.Recordset ' ADO RecordsetSet cn = New ADODB.ConnectionSet 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 = rsrptCustomers.Show 'Preview the report

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

//* All nodes

//ITEM All ITEM nodes

/ Root item

//LAYOUT/ITEM/* All child nodes of //LAYOUT/ITEM

//ITEM[@type] All item nodes that contain the type attribute

//ITEM[@id="1"] All item nodes that have ID attribute value of "1"

Setting Recordset and Connection Properties

Binding Controls to a Data Control

ActiveReports 2.0 Standard User's Guide | 53

Page 54: 83791925 Active Report 2 0 Standard Edition

@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 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 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 SubPrivate Sub cmdPreview_Click()

ActiveReport1.showEnd 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:

Chapter 5 - Bound Reporting and Grouping

Simple Table or List Report

ActiveReports 2.0 Standard User's Guide | 54

Page 55: 83791925 Active Report 2 0 Standard Edition

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:

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

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:<%[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.CancelUnload Me

End IfEnd 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.

Name lblCustomer lblCity lblCountry lblPostalCode

Caption Customer City Country Postal Code

Height 270 270 270 270

Left 0 2970 5490 7380

Top 0 0 0 0

Width 2880 2430 1800 1800

Name txtCompanyName txtCity txtCountry txtPostalCode

DataField CompanyName City Country Postal Code

Height 270 270 270 270

Left 0 2970 5490 7380

Top 0 0 0 0

Width 2880 2430 1800 1800

Alignment 0-Left 0-Left 0-Left 1-Right

Using Parameters With Bound Reports

ActiveReports 2.0 Standard User's Guide | 55

Page 56: 83791925 Active Report 2 0 Standard Edition

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:

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:

8. Add a Field control to the ghOrderGroup section and set its properties as follows:

Grouping Records

Name ghOrderGroup

DataField Country

Height 360

Name gfOrderGroup

Height 270

Name txtGroupCountry

DataField Country

Height 360

Left 0

Top 0

Width 4230

ActiveReports 2.0 Standard User's Guide | 56

Page 57: 83791925 Active Report 2 0 Standard Edition

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

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

Font.Size 12

Font.Bold True

Grouping on Calculated Expression

Adding a Summary Field in Group Footer

ActiveReports 2.0 Standard User's Guide | 57

Page 58: 83791925 Active Report 2 0 Standard Edition

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.

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:

4. Add Field control to the gfOrderGroup section and set its properties as follows:

Order ID Date Amount

1001 5/16/97 3000

1001 5/30/97 -500

1001 6/15/97 -2500

1002 4/20/97 2550

1002 4/30/97 -2500

Name lblGFooter

Caption "Number of Customers"

Height 270

Left 0

Top 0

Width 2070

Name txtCustomerCount

Height 270

Left 2160

Top 0

ActiveReports 2.0 Standard User's Guide | 58

Page 59: 83791925 Active Report 2 0 Standard Edition

5. Set the txtCustomerCount properties as follows:

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

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/1996

Sales For: 6/5/1996

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.

Width 1980

DataField CompanyName

SummaryFunc 2-ddSFCount

SummaryGroup ghOrderGroup

SummaryType 3-ddSMSubTotal

Alignment 1-ddTXRight

Conditional Summary Fields

Last Name First Name Country Sales

Leverling Janet

USA 1000

Leverling Janet UK 560

Davolio Nancy USA 2000

Davolio Nancy UK 1067

Country Last Name First Name Sales

USA Leverling Janet 1000

UK Leverling Janet 560

USA Davolio Nancy 2000

UK Davolio Nancy 1067

Total USA 3000

Total UK 1672

ActiveReports 2.0 Standard User's Guide | 59

Page 60: 83791925 Active Report 2 0 Standard Edition

Private Sub cmdPrint_Click()ActiveReport1.printreport false

End SubPrivate Sub cmdPreview_Click()

ActiveReport1.showEnd 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 SaleAmountFROM Employees INNER JOIN (Orders INNER JOIN [Order Subtotals] ON Orders.OrderID= [Order Subtotals].OrderID) ON Employees.EmployeeID = Orders.EmployeeID ORDER BYOrders.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:

12. Click on the new section "GroupFooter1" to select it.

13. Modify the section's properties as follows:

14. Add two text fields to gfShippedDate and modify their properties as follows:

15. Add two labels to gfShippedDate and modify their properties as follows:

Name ghShippedDate

DataField ShippedDate

Height 840

Name gfShippedDate

Height 810

Name txtTotalUSA txtTotalUK

Height 270 270

Left 7740 7740

Top 90 450

Width 1530 1530

Alignment ddTxRight ddTxRight

OutputFormat $###0.00 $###0.00

DataField SalesUSA SalesUK

SummaryFunc 0 - ddSFSum 0 - ddSFSum

SummaryGroup ghOrderGroup ghOrderGroup

SummaryRunning 1 - ddSRGroup 1 - ddSRGroup

SummaryType 3 - ddSMSubTotal 3 - ddSMSubTotal

Name lblTotalUSA lblTotalUK

Caption US Total Sales UK Total Sales

Height 270 270

ActiveReports 2.0 Standard User's Guide | 60

Page 61: 83791925 Active Report 2 0 Standard Edition

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:

18. Click and drag the following field from the field's list into ghShippedDate: ShippedDate.

19. Set the field's properties as follows:

20. Add five labels to ghShippedDate and modify their properties as follows:

Left 6120 6120

Top 90 450

Width 1530 1530

Alignment ddTxRight ddTxRight

Font.Bold True True

Name txtCountry txtLastName txtFirstName txtSaleAmount

DataField Country LastName FirstName SaleAmount

Height 270 270 270 270

Left 0 1530 4140 7920

Top 0 0 0 0

Width 1440 2520 2790 1440

Alignment ddTXLeft ddTXLeft ddTXLeft ddTXRight

OutputFormat $###0.00

Name txtShippedDate

DataField ShippedDate

Height 360

Left 1620

Top 0

Width 2790

Font.Size 16

Font.Bold True

Name lblSales lblCountry lblLastName lblFirstName lblSaleAmount

Caption Sales: Country Last Name First Name Sales Amount

Height 270 270 270 270 270

Left 0 0 1530 4140 7830

Top 0 540 540 540 540

Width 1530 1440 2520 2790 1440

Font.Bold True True True True True

Font.Size 16

Alignment ddTXRight

ActiveReports 2.0 Standard User's Guide | 61

Page 62: 83791925 Active Report 2 0 Standard Edition

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").ValueMe.Fields("SalesUK").Value = 0

ElseIf Me.Fields("Country").Value = "UK" ThenMe.Fields("SalesUSA").Value = 0Me.Fields("SalesUK").Value = Me.Fields("SaleAmount").Value

ElseMe.Fields("SalesUSA").Value = 0Me.Fields("SalesUK").Value = 0

End IfEnd Sub

Using Formulas and Calculated FieldsIn 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:

SELECTCustomers.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].ProductIDWHERE (((DatePart("yyyy",[OrderDate]))=1995))ORDER BY Customers.CompanyName, Products.ProductName

5. Insert a group header/footer section.

6. Set the GroupHeader properties as follows:

7. Add a field control to the ghCustomer section and set its properties as follows:

Using Formulas and Calculated Fields

Name ghCustomer

DataField CompanyName

Height 765

Name txtCompanyName

DataField CompanyName

Height 360

ActiveReports 2.0 Standard User's Guide | 62

Page 63: 83791925 Active Report 2 0 Standard Edition

8. Add four labels to the ghCustomer section and set their properties as follows:

9. Set the detail section height to 300 and add the following text controls:

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.

Using Formulas and Calculated FieldsPage N of M in the Page FooterYou can add page numbering to your report using the field's PageCount summary type. Page numbers are created using a running summary field.

Left 0

Top 0

Width 5670

Name lblProductName lblQuantity lblUnitPrice lblExtended

Caption Product Name Quantity Unit Price Extended

Height 270 270 270 270

Left 0 3420 5040 7020

Top 450 450 450 450

Width 3330 1530 1890 1620

Name txtProductName txtQuantity txtUnitPrice txtExtended

DataField ProductName Quantity UnitPrice

Height 270 270 270 270

Left 0 3420 5040 7020

Top 0 0 0 0

Width 3330 1530 1890 1620

OutputFormat Number Currency Currency

Page N of M in the Page Footer

ActiveReports 2.0 Standard User's Guide | 63

Page 64: 83791925 Active Report 2 0 Standard Edition

1. Add two text fields and two labels to your Page Footer section.

2. Set the following properties:

First Field

Second Field

First Label

Second Label

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 HeaderYou 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

Second Field

Name txtPageNumber

SummaryRunning 2-ddSRAll

SummaryType 4-ddSMPageCount

Name txtPageCount

SummaryType 4-ddSMPageCount

Name lblPage

Caption Page

Name lblOf

Caption of

Page N of M in the Group Header

Name txtPageNumber

SummaryGroup GroupHeader1

SummaryRunning 1-ddSRGroup

SummaryType 4-ddSMPageCount

ActiveReports 2.0 Standard User's Guide | 64

Page 65: 83791925 Active Report 2 0 Standard Edition

First Label

Second Label

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 GroupingUnbound 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 ReportsActiveReports 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 ReportsThis 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

Name txtPageCount

SummaryGroup GroupHeader1

SummaryType 4-ddSMPageCount

Name lblPage

Caption Page

Name lblOf

Caption of

Chapter 6 - Unbound Reporting and Grouping

Unbound Reports

Simple Unbound Reports

ActiveReports 2.0 Standard User's Guide | 65

Page 66: 83791925 Active Report 2 0 Standard Edition

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:

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:

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.ConnectionDim rs As ADODB.RecordsetPrivateSub ActiveReport_DataInitialize()

Dim cnnStr As String' Open data base here (called from form)Set cn = New ADODB.ConnectionSet rs = New ADODB.Recordset' Add fields to ActiveReports' Fields CollectionFields.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 Visual Studio\VB98\NWind.mdb"' Set recordset properties and generate recordsetrs.Open "SELECT * FROM customers ORDER BY CompanyName", cn

End SubPrivate Sub ActiveReport_FetchData(EOF As Boolean)

' Exit sub if EOF is trueIf rs.EOF=True Then Exit SubEOF = False' Sets ActiveReports' fields collection values to the' current recordset valueFields("Customer").Value = rs!CompanyName

Name lblCustomer lblCity lblCountry lblPostalCode

Caption Customer City Country Postal Code

Height 270 270 270 270

Left 0 2970 5490 7380

Top 0 0 0 0

Width 2880 2430 1800 1800

Alignment 0-ddTXLeft 0-ddTXLeft 0-ddTXLeft 1-ddTXRight

Name txtCustomer txtCity txtCountry txtPostalCode

Text Customer City Country PostalCode

DataField Customer City Country PostalCode

Height 270 270 270 270

Left 0 2970 5490 7380

Top 0 0 0 0

Width 2880 2430 1800 1800

Alignment 0-Left 0-Left 0-Left 1-Right

ActiveReports 2.0 Standard User's Guide | 66

Page 67: 83791925 Active Report 2 0 Standard Edition

Fields("City").Value = rs!CityFields("Country").Value = rs!CountryFields("PostalCode").Value = rs!PostalCode' Advance recordsetrs.MoveNext

End Sub

8. Run the report.

Grouping with Unbound ReportsContinuing 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:

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 ReportsContinuing 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:

2. Place a textbox in the gfOrderGroup section.

3. Set the field's properties as follows:

Grouping With Unbound Reports

Name ghOrderGroup

DataField Country

Height 360

Adding Summary Fields to Unbound Reports

Name gfOrderGroup

Height 500

Name txtCustomerTotal

Text CustomerTotal

ActiveReports 2.0 Standard User's Guide | 67

Page 68: 83791925 Active Report 2 0 Standard Edition

4. Place a label in the gfOrderGroup Section.

5. Set the label's properties as follows:

6. Run the report.

Unbound Reporting with ArraysThis 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:

6. Place a textbox in the ghOrderGroup section.

DataField Customer

Height 270

Left 7380

Top 0

Width 1880

Alignment 0-Right

SummaryFunction 2-ddSFCount

SummaryGroup ghOrderGroup

SummaryRunning 1-ddSRGroup

SummaryType 3-ddSMSubTotal

Name lblCustomerTotal

Caption Total Customers:

Height 270

Left 5760

Top 0

Width 1620

Unbound Reporting with Arrays

Name ghOrderGroup

DataField OrderID

Height 690

BackColor &H00C0FFFF&

BackStyle 1-ddBKNormal

ActiveReports 2.0 Standard User's Guide | 68

Page 69: 83791925 Active Report 2 0 Standard Edition

7. Set the field's properties as follows:

8. Click on the Detail section and modify the section's properties as follows:

9. Place five textboxes in the Detail section and modify their properties as follows:

10. Click on the GroupFooter1 section and modify the section's properties as follows:

11. Place a textbox in the gfOrderGroup section and modify the section's properties as follows:

Name txtOrderID

Text Order ID

DataField OrderID

Height 630

Left 0

Top 0

Width 1440

Font.Size 14

Height 270

BackColor &H00C0FFC0&

BackStyle 1-ddBKNormal

Name txtProductID txtProductName txtQty txtPrice txtAmount

DataField ProductID ProductName Qty Price Amount

Height 270 270 270 270 270

Left 0 1440 4320 5760 7200

Top 0 0 0 0 0

Width 1440 2880 1440 1440 1440

Alignment 1-ddTXRight

0-ddTXLeft 1-ddTXRight

1-ddTXRight

0-ddTXLeft

Name gfOrderGroup

Height 330

BackColor &H00FFFFC0&

BackStyle 1-ddBKNormal

Name txtOrderTotal

Text OrderTotal

DataField Amount

Height 270

Left 7200

Top 0

Width 1440

ActiveReports 2.0 Standard User's Guide | 69

Page 70: 83791925 Active Report 2 0 Standard Edition

12. Add the following code to the report:

Option ExplicitPublic bLastIsSingle As BooleanPrivate arr(1 To 12) As OrderItemPrivate iRow As IntegerPrivate tmpAmount As CurrencyPrivate bNewGroup As Boolean

Private Type OrderItemOrderNo As LongProductID As LongProductName As StringQty As IntegerPrice As CurrencyAmount As Currency

End Type 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)

initarrayEnd Sub Private Sub ActiveReport_FetchData(eof As Boolean)

If iRow > UBound(arr) Theneof = TrueExit Sub

End IfFields("OrderID") = arr(iRow).OrderNoFields("ProductID") = arr(iRow).ProductIDFields("ProductName") = arr(iRow).ProductNameFields("Qty") = arr(iRow).QtyFields("Price") = arr(iRow).PriceFields("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 stopeof = FalseiRow = iRow + 1

End Sub Public Sub InitArray()

arr(1).OrderNo = 100arr(1).ProductID = 1arr(1).ProductName = "Hard Drive"arr(1).Qty = 1 arr(1).Price = 435arr(1).Amount = arr(1).Qty * arr(1).Price

arr(2).OrderNo = 100arr(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.

Alignment 1-ddTXRight

SummaryType 1-ddSMGrandTotal

ActiveReports 2.0 Standard User's Guide | 70

Page 71: 83791925 Active Report 2 0 Standard Edition

Unbound Reporting with CollectionsThis 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:

2. Add the following code to the Order class:

Option ExplicitPublic Key As StringPublic ProductID As LongPublic ProductName As StringPublic Qty As IntegerPublic Price As Currency

3. Add the following code to the Orders class:

Option Explicit'local variable to hold collectionPrivate mCol As CollectionPublic Function Add(Key As String, Optional sKey As String) As Order

'create a new objectDim objNewMember As OrderSet objNewMember = New Order

'set the properties passed into the methodobjNewMember.Key = KeyIf Len(sKey) = 0 Then

mCol.Add objNewMemberElse

mCol.Add objNewMember, sKeyEnd If

'return the object createdSet Add = objNewMemberSet 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.CountCount = 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

Unbound Reporting with Collections

Name Order Orders

ActiveReports 2.0 Standard User's Guide | 71

Page 72: 83791925 Active Report 2 0 Standard Edition

Public Property Get NewEnum() As IUnknown'this property allows you to enumerate'this collection with the For...Each syntaxSet NewEnum = mCol.[_NewEnum]

End Property Private Sub Class_Initialize()

'creates the collection when this class is createdSet mCol = New Collection

End Sub Private Sub Class_Terminate()

'destroys collection when this class is terminatedSet mCol = Nothing

End Sub

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

Option ExplicitPublic 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 Integeri = i + 1If i > colOrders.Count Then

eof = TrueExit Sub

Elseeof = False

End If

Fields("OrderID").Value = colOrders.Item(i).KeyFields("ProductID").Value = colOrders.Item(i).ProductIDFields("ProductName").Value = colOrders.Item(i).ProductNameFields("Qty").Value = colOrders.Item(i).QtyFields("Price").Value = colOrders.Item(i).PriceFields("Amount").Value = colOrders.Item(i).Qty * colOrders.Item(i).Price

End Sub Public Sub InitCollection()

Dim o As OrderWith colOrders

Set o = .Add("100")o.ProductID = 1o.ProductName = "Hard Drive"o.Qty = 1: o.Price = 435

Set o = .Add("100")o.ProductID = 2o.ProductName = "CD ROM"o.Qty = 1o.Price = 199

Set o = .Add("100")o.ProductID = 3o.ProductName = "32MB RAM"o.Qty = 2o.Price = 85

End WithEnd Sub

5. Run the report.

Unbound Reporting with Text Files

ActiveReports 2.0 Standard User's Guide | 72

Page 73: 83791925 Active Report 2 0 Standard Edition

Unbound Reporting with Text FilesThis 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:

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:

6. Add the following code to the Report:

Option ExplicitPrivate hFile As Integer Private Sub ActiveReport_DataInitialize()

hFile = FreeFileOpen App.Path & "\Products.txt" For Input As #hFile' This sets up the fields used in data bindingFields.Add "ProductID"Fields.Add "ProductName"Fields.Add "QuantityPerUnit"Fields.Add "UnitPrice"

End Sub Private Sub ActiveReport_FetchData(eof As Boolean)

Dim sLine As StringDim 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

Name lblProductID lblProductName lblQtyPerUnit lblPrice

Caption Product ID Product Name Qty Per Unit Price

Height 270 270 270 270

Left 0 1440 5310 7920

Top 0 0 0 0

Width 1350 3780 2520 1350

Name txtProductID txtProductName txtQtyPerUnit txtPrice

Text ProductID ProductName QtyPerUnit Price

DataField ProductID ProductName QuantityPerUnit Price

Height 270 270 270 270

Left 0 1440 5310 7920

Top 0 0 0 0

Width 1350 3780 2520 1350

Alignment 1-Right 0-Left 0-Left 1-Right

ActiveReports 2.0 Standard User's Guide | 73

Page 74: 83791925 Active Report 2 0 Standard Edition

If VBA.eof(hFile) Theneof = TrueExit Sub

Elseeof = False

End If

Line Input #hFile, sLinearr = 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 ThenClose #hFile

End IfEnd 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,02,Chang,1,1,24 - 12 oz bottles,$19.00,17,40,25,03,Aniseed Syrup,1,2,12 - 550 ml bottles,$10.00,13,70,25,0

9. Run the report.

Chapter 7 - Using SubreportsSubreports

Bound Subreports

Using Parameters with Subreports

Embedded Subreports

Shaped/Hierarchical Subreports

Unbound Subreports

SubreportsActiveReports 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 Related child reports that contain data from a source different from the main report. l 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.

Chapter 7 - Using Subreports

Subreports

ActiveReports 2.0 Standard User's Guide | 74

Page 75: 83791925 Active Report 2 0 Standard Edition

Adding a SubreportTo 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 ReportEach 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 SubreportsThe 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:

With rptSupplier1. 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:

6. Place a textbox in the ghCountry section and set its properties as follows:

Bound Subreports

Name rptSupplier rptProducts

Name ghCountry

DataField Country

Height 735

Name txtCountry

DataField Country

Height 360

Left 0

Top 0

Width 2790

Font.Size 17

Font.Bold True

ActiveReports 2.0 Standard User's Guide | 75

Page 76: 83791925 Active Report 2 0 Standard Edition

7. Place three labels in the ghCountry section and set their properties as follows:

8. Set the Detail section's height to 1110.

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

10. Place a Subreport control in the Detail Section and set its properties as follows:

11. Add the following code to rptSupplier:

Dim i_SupID As Integer Private Sub ActiveReport_FetchData(EOF As Boolean)

'Get the current records supplier IDIf Not Me.DataControl1.Recordset.EOF Then

i_SupID = Me.DataControl1.Recordset!supplierIDEnd If

End Sub Private Sub ActiveReport_ReportEnd()

Unload subProducts.objectSet subProducts.object = Nothing

End Sub Private Sub ActiveReport_ReportStart()

Set subProducts.object = New rptProductsEnd Sub Private Sub Detail_Format()

'Sets the subreport's recordsource to the current supplier

Name lblCompanyName lblContact lblPhoneNumber

Caption Company Name Contact Phone Number

Height 270 270 270

Left 0 5220 7470

Top 450 450 450

Width 5040 2070 1890

Font.Bold True True True

Name txtCompanyName txtContactName txtPhoneNumber

Text CompanyName ContactName PhoneNumber

DataField CompanyName ContactName PhoneNumber

Height 270 270 270

Left 0 5130 7380

Top 90 90 90

Width 5040 2160 1980

ForeColor &HOOCOOO8& &HOOCOOO8& &HOOCOOO8&

Name subProducts

Height 360

Left 0

Top 450

Width 9360

ActiveReports 2.0 Standard User's Guide | 76

Page 77: 83791925 Active Report 2 0 Standard Edition

subProducts.object.DataControl1.Source = "SELECT * FROM products INNER _JOIN categories ON products.categoryid = categories.categoryid _WHERE products.supplierID = " & i_SupID

End Sub

With rptProducts1. 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:

7. Place two textboxes in the ghCategory section and set their properties as follows:

8. Set the GroupFooter's height to 0.

9. Set the Detail section's properties as follows:

10. Place three textboxes in the Detail section and set their properties as follows:

Name ghCategory

DataField products.CategoryID

Height 300

BackColor &H00C0FFFF&

BackStyle 1-Normal

Name txtCategoryName txtDescription

DataField CategoryName Description

Height 270 270

Left 0 2970

Top 0 0

Width 2880 6210

Font.Size 11 10

Font.Bold True True

Height 330

BackColor &H00C0E0FF&

BackStyle 1-Normal

Name txtProductName txtUnitsInStock txtUnitPrice

Text ProductName UnitsInStock UnitPrice

DataField ProductName UnitsInStock UnitPrice

Height 270 270 270

Left 1620 6210 8370

ActiveReports 2.0 Standard User's Guide | 77

Page 78: 83791925 Active Report 2 0 Standard Edition

11. Place three labels in the Detail Section and set their properties as follows:

12. Run the report.

Using Parameters with SubreportsParameters 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 rptProducts1. 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 rptSuppliers1. Comment out the code in the detail section.

2. Save and run the report.

Embedded SubreportsThe 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 child-grandchild reports.

Add three new ActiveReports to a project, as shown in the first tutorial, and set their properties as follows:

With rptEmployees

Top 0 0 0

Width 2970 1080 990

OutputFormat Currency

Name lblProductName lblUnitsInStock lblUnitPrice

Caption Product Name: Units In Stock: UnitPrice:

Height 270 270 270

Left 0 4680 7290

Top 0 0 0

Width 1530 1530 1080

Font.Bold True True True

Using Parameters with Subreports

Embedded Subreports

Name rptCustomers rptEmployees rptOrders

ActiveReports 2.0 Standard User's Guide | 78

Page 79: 83791925 Active Report 2 0 Standard Edition

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:

7. Place four textboxes in the ghEmployee section and set their properties as follows:

8. Place four labels in the ghEmployee section and set their properties as follows:

9. Set the GroupFooter's height to 0.

10. Set the Detail section's properties as follows:

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

Name ghEmployee

DataField EmployeeID

Height 690

BackColor &H00FF8080&

BackStyle 1-Normal

Repeat 1-Every Page

Name txtEmployeeID txtExtension txtLastName txtFirstName

DataField EmployeeID Extension LastName FirstName

Height 270 270 270 270

Left 1440 5760 1440 5760

Top 90 90 360 360

Width 1440 1440 2790 3420

ForeColor White White White White

Name lblEmployeeID lblExtension lblLastName lblFirstName

Caption Employee ID: Extension: Last Name: First Name:

Height 270 270 270 270

Left 90 4320 90 4320

Top 90 90 360 360

Width 1350 1350 1350 1350

Font.Bold True True True True

ForeColor White White White White

Height 900

CanShrink True

ActiveReports 2.0 Standard User's Guide | 79

Page 80: 83791925 Active Report 2 0 Standard Edition

12. Add the following code to rptEmployees:

Dim empID As Integer Private Sub ActiveReport_FetchData(EOF As Boolean)

' Store the current records employee IDIf Not DataControl1.Recordset.EOF Then

empID = DataControl1.Recordset!employeeIDEnd If

End Sub Private Sub ActiveReport_ReportEnd()

' Unload the subreport's objectUnload subOrders.objectSet subOrders.object = Nothing

End Sub Private Sub ActiveReport_ReportStart()

' Set the subreport control's object the a new rptOrderSet subOrders.object = New rptOrders

End Sub Private Sub Detail_Format()

Dim s_SQL As String'Set the SQL string for the rptOders recordsets_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 rptOrders1. 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 subOrders

Height 900

Left 0

Top 0

Width

9360

Name ghOrders

DataField Orders.OrderID

Height 555

GroupKeepTogether 2-All

KeepTogether True

ActiveReports 2.0 Standard User's Guide | 80

Page 81: 83791925 Active Report 2 0 Standard Edition

7. Place three textboxes in the ghOrders section and set their properties as follows:

8. Place three labels in the ghOrders section and set their properties as follows:

9. Set the GroupFooter's height to 0.

10. Set the Detail section's properties as follows:

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

12. Add the following code to rptOrders:

Dim custID As String Private Sub ActiveReport_FetchData(EOF As Boolean)

' Store the current records customer IDIf Not DataControl1.Recordset.EOF Then

custID = DataControl1.Recordset!customerID

BackColor &H008080FF&

BackStyle 1-Normal

Name txtProductName txtOrderDate txtQuantity

DataField ProductName OrderDate Quantity

Height 270 270 270

Left 1080 5220 7650

Top 180 180 180

Width 3150 1440 1440

ForeColor &H00FF0000& &H00FF0000& &H00FF0000&

Name lblProduct lblDate lblQuantity

Caption Product: Date: Quantity:

Height 270 270 270

Left 90 4320 6660

Top 180 180 180

Width 990 900 990

Font.Bold True True True

ForeColor &H00FF0000& &H00FF0000& &H00FF0000&

Height 900

CanShrink True

Name subCustomers

Height 900

Left 0

Top 0

Width 9360

ActiveReports 2.0 Standard User's Guide | 81

Page 82: 83791925 Active Report 2 0 Standard Edition

End IfEnd Sub Private Sub ActiveReport_ReportEnd()

' Unload the subreport's objectUnload subCustomers.objectSet subCustomers.object = Nothing

End Sub Private Sub ActiveReport_ReportStart()

' Set the subreport control's object the a new rptOrderSet subCustomers.object = New rptCustomers

End Sub Private Sub Detail_Format()

On Error GoTo errHndl'Set the SQL string for the rptOders recordsetsubCustomers.object.DataControl1.Source = "Select * from customers _where customerID = '" & custID & "'"

Exit SuberrHndl:

Resume NextEnd Sub

With rptCustomers1. 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:

7. Set the GroupFooter's properties as follows:

8. Set the Detail section's properties as follows:

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

Name ghCustomers

Height 60

BackColor &H0080C0FF&

BackStyle 1-Normal

Name gfCustomers

Height 60

BackColor &H0080C0FF&

BackStyle 1-Normal

Height 1110

CanShrink True

BackColor &H0080C0FF&

BackStyle 1-Normal

ActiveReports 2.0 Standard User's Guide | 82

Page 83: 83791925 Active Report 2 0 Standard Edition

10. Place six labels in the Detail section and set their properties as follows:

11. Run the report.

Shaped/Hierarchical SubreportsThis 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:

With rptOrders1. 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 txtCompanyName txtContactName txtPhone txtAddress txtCity txtPostalCode

DataField CompanyName ContactName Phone Address City PostalCode

Height 270 270 270 270 270 270

Left 1170 1170 5850 1170 1170 5850

Top 0 270 270 540 810 810

Width 7560 3150 2880 7560 3150 2880

CanShrink True True True True True True

Name lblCompanyName lblContactName lblPhone lblAddress lblCity lblPostalCode

Caption Company Name: Contact Name: Phone: Address: City: Postal Code:

Height 270 270 270 270 270 270

Left 90 90 4320 90 90 4320

Top 0 270 270 540 810 810

Width 1080 1080 1530 1080 1080 1440

Font.Bold True True True True True True

Shaped/Hierarchical Subreports

Name rptCustomers rptEmployees rptOrders

Name ghOrders

DataField OrderID

Height 810

BackColor &H00800000&

ActiveReports 2.0 Standard User's Guide | 83

Page 84: 83791925 Active Report 2 0 Standard Edition

8. Place six textboxes in the ghOrders section and set their properties as follows:

9. Place Six labels in the ghOrders section and set their properties as follows:

10. Set the GroupFooter's height to 60.

11. Set the Detail section's properties as follows:

12. Place two Subreport controls in the Detail section and set their properties as follows:

13. Add the following code to rptOrders:

Private Sub ActiveReport_DataInitialize()On Error GoTo errHndlDim rs As ADODB.RecordsetDim sConnect As String

BackStyle 1-Normal

Name txtShippedDate txtRequiredDate txtShipName txtFreight txtShipAddress

DataField ShippedDate RequiredDate ShipName Freight ShipAddress

Height 270 270 270 270 270

Left 1440 4320 1440 7830 1440

Top 0 0 270 270 540

Width 1440 1440 4320 1350 5580

ForeColor White White White White White

OutputFormat Currency

Name lblShipped lblRequired lblShipName lblCost lblAddress lblCity

Caption Shipped: Required: Ship Name: Cost: Address: City:

Height 270 270 270 270 270 270

Left 90 3060 90 7200 90 7200

Top 0 0 270 270 540 540

Width 1350 1260 1350 630 1350 630

ForeColor White White White White White White

Font.Bold True True True True True True

Height 1065

BackColor &H00000080&

BackStyle 1-Normal

Name subCustomers subEmployees

Height 450 360

Left 0 0

Top 0 540

Width 9180 9180

ActiveReports 2.0 Standard User's Guide | 84

Page 85: 83791925 Active Report 2 0 Standard Edition

Dim sSQL As StringDim sProgress As StringDim cn As ADODB.Connection

Set rs = New ADODB.RecordsetSet 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 = Falsers.Open sSQL, cn

Set Me.DataControl1.Recordset = rsSet Me.subEmployees.object = New rptEmployeesSet Me.subCustomers.object = New rptCustomers

errHndl:

Debug.Print Err.Number & Err.DescriptionUnload Me

End Sub Private Sub Detail_Format()

On Error GoTo errhndlerDim rsCust As ADODB.RecordsetDim rsEmp As ADODB.Recordset

Set rsCust = DataControl1.Recordset.Fields("rsCustomers").Value.CloneSet rsEmp = DataControl1.Recordset.Fields("rsEmployee").Value.CloneSet subCustomers.object.sourceRecordSet = rsCustSet subEmployees.object.sourceRecordSet = rsEmp

Exit Sub errhndler:

Debug.Print Err.Number & Err.DescriptionEnd Sub

With rptCustomers1. 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:

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

Height 585

CanShrink True

BackColor &H00000080&

BackStyle 1-Normal

ActiveReports 2.0 Standard User's Guide | 85

Page 86: 83791925 Active Report 2 0 Standard Edition

7. Place two labels in the Detail section and set their properties as follows:

8. Add the following code to rptCustomers:

Option Explicit Private Enum ERRS

ERRS_VBINVALIDPROPERTYVALUE = 380End Enum Public Property Set sourceRecordSet(ByVal rs As ADODB.Recordset)

On Error GoTo errhndlerIf rs Is Nothing Then

Err.Raise ERRS_VBINVALIDPROPERTYVALUE, "rptCustomers.<Property _End If

Set Me.DataControl1.Recordset = rs

Exit Propertyerrhndler:Debug.Print Err.Number & Err.Description

End Property

With rptEmployees1. 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:

Name txtContactName txtCompanyName

DataField ContactName CompanyName

Height 270 270

Left 1530 1530

Top 0 270

Width 7110 7110

ForeColor White White

Name lblOrderedBy lblFor

Caption Ordered By: For:

Height 270 270

Left 0 0

Top 0 270

Width 1440 1440

ForeColor White White

Font.Bold True True

Height 300

CanShrink True

BackColor &H00000080&

ActiveReports 2.0 Standard User's Guide | 86

Page 87: 83791925 Active Report 2 0 Standard Edition

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

7. Place a label in the Detail section and set its properties as follows:

8. Add the following code to rptCustomers:

Option ExplicitPrivate Enum ERRS

ERRS_VBINVALIDPROPERTYVALUE = 380 End Enum Public Property Set sourceRecordSet(ByVal rs As ADODB.Recordset)

On Error GoTo errhndlerIf rs Is Nothing Then

Err.Raise ERRS_VBINVALIDPROPERTYVALUE, "rptEmployee.<Property _Set> sourceRecordSet"

End If

Set Me.DataControl1.Recordset = rs

Exit Propertyerrhndler:Debug.Print Err.Number & Err.Description

End Property

9. Run the report.

Using the SubReport's DataField PropertyActiveReports 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.

BackStyle 1-Normal

Name txtFirstName txtLastName

DataField FirstName LastName

Height 270 270

Left 1620 2700

Top 0 0

Width 1080 1440

ForeColor White White

Name lblProcessedBy

Caption Processed By:

Height 270

Left 0

Top 0

Width 1530

ForeColor White

Font.Bold True

ActiveReports 2.0 Standard User's Guide | 87

Page 88: 83791925 Active Report 2 0 Standard Edition

Unbound SubreportsThis 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:

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

With rptCustomers1. Remove the PageHeader/Footer section.

2. Insert a GroupHeader/Footer section.

3. Set the GroupHeader's properties as follows:

4. Place a textbox in the ghCountry section and set its properties as follows:

5. Place three labels in the ghCountry section and set their properties as follows:

Unbound Subreports

Name rptCustomers rptCustomersClone rptOrders

Name ghCountry

DataField Country

Height 810

CanShrink True

GrpKeepTogether 2-All

KeepTogether True

Repeat 1-Every Page

Font.Bold True

Name txtCountry

DataField Country

Height 540

Left 0

Top 0

Width 2880

Font.Size 22

Font.Bold True

Name lblCustomer lblCity lblPostalCode

Caption Customer City Postal Code

ActiveReports 2.0 Standard User's Guide | 88

Page 89: 83791925 Active Report 2 0 Standard Edition

6. Set the GroupFooter's height to 60.

7. Set the Detail section's properties as follows:

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

9. Add the following code to rptCustomers:

Public cn As ADODB.ConnectionDim rs As ADODB.RecordsetPublic myCloneRS As ADODB.RecordsetPrivate s_Country As String Private Sub ActiveReport_DataInitialize()

Dim cnnStr As String' Open data base here (called from form)Set cn = New ADODB.ConnectionSet rs = New ADODB.RecordsetSet myCloneRS = New ADODB.Recordset

' Add fields to ActiveReports' Fields CollectionFields.Add "Country"' Set Connection String and connect to DBcnnStr = "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 recordsetrs.CursorType = adOpenStaticrs.LockType = adLockOptimisticrs.Open "Select * from customers order by Country", cn

' Create a clone of the current recordset to use in the subreportSet myCloneRS = rs.Clone

End Sub Private Sub ActiveReport_FetchData(EOF As Boolean)

' Exit sub if EOF is trueIf rs.EOF Then Exit Sub

' Sets ActiveReports' fields collection values to the' current recordset valueFields("Country").Value = rs!countrys_Country = rs!country' Advance recordsetrs.MoveNext

Height 270 270 270

Left 0 2880 5760

Top 540 540 540

Width 2880 2800 1800

Font.Bold True True True

Height 630

KeepTogether True

Name subCustomersClone

Height 630

Left 0

Top 0

Width 9360

ActiveReports 2.0 Standard User's Guide | 89

Page 90: 83791925 Active Report 2 0 Standard Edition

If Not rs.EOF Then' If not EOF set the FetchData's EOF value to FalseEOF = False

End IfEnd Sub Private Sub ActiveReport_ReportEnd()

' Unload the subreportUnload subCustomersClone.objectSet subCustomersClone.object = Nothing' Unload the recordsets and databaseSet myCloneRS = NothingSet rs = NothingSet cn = Nothing

End Sub Private Sub ActiveReport_ReportStart()

' Set the subreport's object to a new rptCustomersCloneSet subCustomersClone.object = New rptCustomersClone

End Sub Private Sub Detail_Format()

' Filter the cloned recordset to select the country countrymyCloneRS.Filter = "Country = '" & s_Country & "'"

End Sub

With rptCustomersClone1. Remove the PageHeader/Footer section.

2. Set the Detail section's properties as follows:

3. Place three textboxes in the Detail section and set their properties as follows:

4. Place four labels in the Detail section and set their properties as follows:

Height 1260

BackClor &H00FFC0C0&

BackStyle 1-Normal

CanShrink True

KeepTogether True

Name txtCustomer txtCity txtPostalCode

DataField Customer City PostalCode

Height 270 270 270

Left 0 2880 5760

Top 0 0 0

Width 2880 2880 1800

Name lblOrdered lblRequired lblShipped lblCost

Caption Ordered Required Shipped Cost

Height 270 270 270 270

Left 90 1530 2880 4320

Top 360 360 360 360

Width 1350 1260 1350 1440

Font.Bold True True True True

ActiveReports 2.0 Standard User's Guide | 90

Page 91: 83791925 Active Report 2 0 Standard Edition

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

6. Add the following code to rptCustomers:

Private rsClone As ADODB.RecordsetPrivate s_CustomerID As String Private Sub ActiveReport_DataInitialize()

Fields.RemoveAll' Add fields to ActiveReports' Fields CollectionFields.Add "Customer"Fields.Add "City"Fields.Add "Country"Fields.Add "PostalCode"Set rsClone = New ADODB.RecordsetSet rsClone = rptCustomer.myCloneRS

' Move to the beginning of the cloned recordsetIf Not rsClone.EOF Or Not rsClone.BOF Then

rsClone.MoveFirstEnd If

End Sub Private Sub ActiveReport_FetchData(EOF As Boolean)

' Exit sub if EOF is trueIf rsClone.EOF Then Exit Sub

' Sets ActiveReports' fields collection values to the' current recordset valueFields("Customer").Value = rsClone!CompanyNameFields("City").Value = rsClone!CityFields("Country").Value = rsClone!countryFields("PostalCode").Value = rsClone!PostalCodes_CustomerID = rsClone!CustomerID' Advance recordsetrsClone.MoveNext

If Not rsClone.EOF Then

' If not EOF set the FetchData's EOF value to FalseEOF = False

End IfEnd Sub Private Sub ActiveReport_ReportStart()

' set the subreport's object to a new rptOrdersSet subOrders.object = New rptOrders

End Sub Private Sub Detail_Format()

' Pass the current customer ID to the rptOrders subreportsubOrders.object.CustomerID = s_CustomerID

End Sub

With rptOrders1. Remove the PageHeader/Footer section.

2. Insert a GroupHeader/Footer section.

3. Set the GroupHeader's properties as follows:

Name subOrders

Height 630

Left 0

Top 630

Width 9360

Name ghOrders

ActiveReports 2.0 Standard User's Guide | 91

Page 92: 83791925 Active Report 2 0 Standard Edition

4. Set the GroupFooter's properties as follows:

5. Set the Detail section's properties as follows:

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

7. Add the following code to rptOrders:

Private rsNewRS As ADODB.RecordsetPrivate m_CID As String Public Property Let CustomerID(s_CID As String)

' Store the current customerIDm_CID = s_CID

End Property Public Property Get CustomerID() As String

' Get the current customerIDCustomerID = m_CID

End Property Private Sub ActiveReport_DataInitialize()

Fields.RemoveAll' Add fields to ActiveReports' Fields Collection

Height 60

BackColor &H000040C0&

BackStyle 1-Normal

GrpKeepTogether 2-All

KeepTogether True

Name gfOrders

Height 60

BackColor &H000040C0&

BackStyle 1-Normal

KeepTogether True

Height 270

BackColor &H00C0E0FF&

BackStyle 1-Normal

CanShrink True

KeepTogether True

Name txtOrdered txtRequired txtShipped txtCost

Text Ordered Required Shipped Cost

DataField Ordered Required Shipped Cost

Height 270 270 270 270

Left 0 1440 2880 4320

Top 0 0 0 0

Width 1440 1440 1440 1440

OutputFormat Currency

ActiveReports 2.0 Standard User's Guide | 92

Page 93: 83791925 Active Report 2 0 Standard Edition

Fields.Add "Ordered"Fields.Add "Shipped"Fields.Add "Required"Fields.Add "Cost"'Generate a new orders recordset based off of the current customerIDSet rsNewRS = New ADODB.RecordsetrsNewRS.CursorType = adOpenForwardOnlyrsNewRS.LockType = adLockOptimisticrsNewRS.Open "SELECT * FROM Orders WHERE CustomerID = '" & CustomerID_

& "'", rptCustomer.cnEnd Sub Private Sub ActiveReport_FetchData(EOF As Boolean)

' Exit sub if EOF is trueIf rsNewRS.EOF Then Exit Sub

' Sets ActiveReports' fields collection values to the' current recordset valueFields("Ordered").Value = rsNewRS!OrderDateFields("Shipped").Value = rsNewRS!ShippedDateFields("Required").Value = rsNewRS!RequiredDateFields("Cost").Value = rsNewRS!Freight

' Advance recordsetrsNewRS.MoveNextIf Not rsNewRS.EOF Then

' If not EOF set the FetchData's EOF value to FalseEOF = False

End IfEnd Sub

8. Run the report.

Chapter 8 Dynamic (Run-Time) ReportingModifying and Formatting Controls at Run Time

Creating Dynamic Reports

Dynamic Reports

Modifying and Formatting Controls at Run TimeActiveReports 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 ReportsActiveReports 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

Chapter 8 - Dynamic (Run-Time) Reporting

Modifying and Formatting Controls at Run Time

Creating Dynamic Reports

ActiveReports 2.0 Standard User's Guide | 93

Page 94: 83791925 Active Report 2 0 Standard Edition

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 ReportsThis 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:

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

Private Sub cmdRun_Click()' sets up and runs the reportSet rptMain = New ActiveReport1Set rptSub = New ActiveReport1BuildMainrptMain.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.SectionDim WithEvents myGHeader As DDActiveReports2.SectionPublic CustomerID As StringDim rptMain As ActiveReport1Dim rptSub As ActiveReport1 Private Sub BuildMain()

Dim oCtrl As ObjectDim hCtrl As ObjectDim ghCtrl As ObjectDim gfCtrl As Object

rptMain.PageSettings.BottomMargin = 720rptMain.PageSettings.TopMargin = 720

Dynamic Reports

Name cmdRun

Caption Run Report

Height 615

Left 960

Top 240

Width 2295

ActiveReports 2.0 Standard User's Guide | 94

Page 95: 83791925 Active Report 2 0 Standard Edition

rptMain.documentName = "Customer"'Setting up a control in the detail sectionSet oCtrl = rptMain.Sections("Detail").Controls.Add("DDActiveReports2.subreport")

With oCtrl

.Name = "sub"

.Height = 300

.Width = 6000

.Top = 0

.Left = 0End 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 sectionrptMain.Detail.Height = 300rptMain.Detail.BackStyle = 1 '1 = normal 0 = transparentrptMain.Detail.BackColor = &HC0C0C0rptMain.Detail.ColumnCount = 1rptMain.Detail.KeepTogether = TruerptMain.Detail.CanGrow = TruerptMain.Detail.CanShrink = True'Add a report heading and grouping to the report

rptMain.Sections.Add "Group", 1, ddSTGroupHeader, 500Set myGHeader = rptMain.Sections("group")Set subDetail = rptMain.Sections("detail")rptMain.Sections.Add "foot", 3, ddSTGroupFooter, 60rptMain.Sections("group").GrpKeepTogether = TruerptMain.Sections("group").KeepTogether = TruerptMain.Sections("group").BackStyle = 1rptMain.Sections("group").BackColor = &H808080rptMain.Sections("group").DataField = "CustomerID"rptMain.Sections("foot").BackStyle = 1rptMain.Sections("foot").BackColor = vbBlack

'Add a text field to the group headerSet 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 = TrueEnd 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 = TrueEnd 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 | 95

Page 96: 83791925 Active Report 2 0 Standard Edition

.BackStyle = 1 '1 = normal 0 = transparent

.BackColor = &H800000

.ForeColor = &HC0FFFF

.DataField = "ContactName"

.Border.Shadow = TrueEnd With

'Add a label to the groupfooterrptSub.documentName = "Report Order"rptSub.Detail.BackColor = &HC0C0C0rptSub.Detail.BackStyle = 1rptSub.Detail.KeepTogether = FalserptSub.Detail.Height = 300rptSub.Detail.CanGrow = TruerptSub.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 Subnbsp;Private Sub myGHeader_Format()

CustomerID = rptMain.Sections("group").Controls("txt1").TextEnd Sub Private Sub subDetail_Format()

' Sets up the subreport control and connects the subreport's datacontrol' to the databaseSet rptMain.Detail.Controls("sub").object = rptSubrptSub.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 DSRActiveReports 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 | 96

Page 97: 83791925 Active Report 2 0 Standard Edition

Dim rptSub As ActiveReportPrivate Sub cmdRun_Click()

' setups up and runs the reportSet rptMain = New ActiveReportSet rptSub = New ActiveReportBuildMainARViewer21.ReportSource = rptMain

End Sub

Chapter 9 - Creating Reports from XML DocumentsBound XML Data Reports

XML Data Reports and Subreports

XML Reports using LoadXML

Bound XML Data ReportsThis 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:

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.

Chapter 9 - Creating Reports from an XML Document

Bound XML Data Reports

FileURL C:\Customer.xml

RecordSet Pattern //CUSTOMER

ActiveReports 2.0 Standard User's Guide | 97

Page 98: 83791925 Active Report 2 0 Standard Edition

4. Add a label to the PageHeader and set its properties as follows:

5. Add three labels to the Detail section and set their properties as follows:

6. Add three fields to the Detail Section and set their properties as follows:

7. Save the project and run it.

XML Data Reports and SubreportsThis 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 lblCustomers

Caption Customers

Height 540

Left 0

Top 0

Width 8820

Font.Size 24

Font.Bold True

Alignment 2-ddTXCenter

VerticalAlignment 1-ddTXMiddle

Name lblID lblEmail lblName

Caption ID Email Name

Height 270 270 270

Left 0 2880 0

Top 0 0 270

Width 1350 1440 1350

Font.Bold True True True

Name txtID txtEmail txtName

Text ID Email Name

DataField @id @email NAME

Height 270 270 270

Left 1440 4410 1440

Top 0 0 270

Width 720 4860 7830

XML Data Reports and Subreports

Name srptOrders srptOrderItems

ActiveReports 2.0 Standard User's Guide | 98

Page 99: 83791925 Active Report 2 0 Standard Edition

With rptCustomers1. Add a Subreport control to the Detail section and set its properties as follows:

2. Add the following code to the project:

Private Sub ActiveReport_ReportEnd()Unload srptOrders.objectSet srptOrders.object = Nothing

End Sub Private Sub ActiveReport_ReportStart()

Set srptOrders.object = New srptOrdersEnd Sub

With srptOrders1. 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:

4. Add two fields to the Detail section and set their properties as follows:

5. Add a Subreport control to the Detail section and set its properties as follows:

Name srptOrders

DataField ORDER

Height 360

Left 0

Top 810

Width 9270

FileURL customer.xml

Recordset Pattern //Order

Name txtOrderNumber txtOrderDate

Text OrderNumber OrderDate

Text NUMBER DATE

Height 270 270

Left 0 1620

Top 0 0

Width 1440 4140

Name srptItems

DataField ITEM

Height 270

Left 0

Top 270

Width 9270

ActiveReports 2.0 Standard User's Guide | 99

Page 100: 83791925 Active Report 2 0 Standard Edition

6. Add the following code to the project:

Option Explicit Private Sub ActiveReport_ReportEnd()

Unload srptItems.objectSet srptItems.object = Nothing

End Sub Private Sub ActiveReport_ReportStart()

Set srptItems.object = New srptOderItemsEnd Sub

With srptOrderItems1. Remove the PageHeader/Footer Section.

2. Insert a GroupHeader/Footer.

3. Set the GroupHeader's properties as follows:

4. Add three labels to the GroupHeader and set their properties as follows:

5. Set the GroupFooter's properties as follows:

6. Add a field control to the GroupFooter and set its properties as follows:

Name ghOrderItems

Height 360

Name lblISBN lblTitle lblPrice

Caption ISBN Title Price

Height 270 270 270

Left 0 2880 7380

Top 0 0 0

Width 2790 4320 1350

Font.Bold True True True

Name gfOrderItems

Height 270

Name txtOrderTotal

Text Total

DataField Price

Height 270

Left 7380

Top 0

Width 1350

Font.Bold True

SummaryFunc 0-ddSFSum

SummaryGroup ghOrderItems

ActiveReports 2.0 Standard User's Guide | 100

Page 101: 83791925 Active Report 2 0 Standard Edition

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

8. Add an XML DataControl to the report and set its properties as follows:

9. Add three fields to the Detail section and set their properties as follows:

10. Save the project and run it.

Using the XML DataControl's Field propertyWhen 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:

CustomersOrder

ItemItem

OrderItem

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) <> "" ThentxtTitle.Text = txtTitle.Text & vbCrLf & "Published _By: " &dc.Field("./PUBLISHER", False)End IfEnd Sub

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

SummaryType 3-ddSMSubTotal

FileURL customer.xml

RecordSet Pattern (blank)

Name txtISBN txtTitle txtPrice

Text ISBN Title Price

DataField @isbn TITLE PRICE

Height 270 270 270

Left 0 2880 7380

Top 0 0 0

Width 2790 4320 1350

ActiveReports 2.0 Standard User's Guide | 101

Page 102: 83791925 Active Report 2 0 Standard Edition

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 linkingSet nodList = dc.Field("ITEM", True)srptItems.object.dc.NodeList = nodList

End Sub

XML Reports using LoadXMLUsing 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 = TrueXMLDataControl1.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:

6. Add four fields to the Detail section and set their properties as follows:

7. Save the report and run it.

XML Reports using LoadXML

Height 765

BackColor &H00C0FFFF&

BackStyle 1-Normal

Name txtTitle txtID txtQuantity txtUnitPrice

Text Title ID Quantity UnitPrice

DataField Title ID Quantity UnitPrice

Height 270 270 270 270

Left 7380 90 3330 4950

Top 90 360 360 360

Width 4500 1440 1440 1440

ActiveReports 2.0 Standard User's Guide | 102

Page 103: 83791925 Active Report 2 0 Standard Edition

Chapter 10 - Additional Report TypesTop 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 ReportsActiveReports 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 ReportsMaster 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 ReportsSummary 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.

Chapter 10 - Additional Report Types

Top n Reports

Master Detail Reports

Summary Reports

ActiveReports 2.0 Standard User's Guide | 103

Page 104: 83791925 Active Report 2 0 Standard Edition

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 ReportsActiveReports 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 WithEnd Sub

Columnar ReportsActiveReports 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 LabelsYou 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 LabelsActiveReports 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

Mail-Merge Reports

Columnar Reports

Creating Labels

ActiveReports 2.0 Standard User's Guide | 104

Page 105: 83791925 Active Report 2 0 Standard Edition

- 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 IntegerPrivate Sub Detail_Format()

If iSkipLabels > 0 TheniSkipLabels = iSkipLabels – 1LayoutAction = ddLAMoveLayout

End IfEnd Sub

Conditional PrintingActiveReports 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 = TrueElse

lblOutstanding.Visible = FalseEnd 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 ReportsYou can create green-bar printouts by alternating the shading or background color of your detail section in the format event.

Dim I As IntegerPrivate Sub Detail_Format()

If (I Mod 2) = 0 Then' Set the detail BackStyle to normalDetail.BackStyle = ddBKNormalDetail.BackColor = vbGreen

ElseDetail.BackStyle = ddBKTransparent

End IfI = I + 1

End Sub

Multi-Page SectionsBy 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.

Conditional Printing

Green-Bar Printout Reports

Multi-Page Sections

Charts

ActiveReports 2.0 Standard User's Guide | 105

Page 106: 83791925 Active Report 2 0 Standard Edition

ChartsActiveReports 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 SectionLayoutAction 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 ReportActiveReports 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 Tips1. 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.

Multiple Records Per Section

Modifying the Pages Collection of a Processed Report

Report Coding Tips

ActiveReports 2.0 Standard User's Guide | 106

Page 107: 83791925 Active Report 2 0 Standard Edition

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 ControlSetting 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 ContentsSetting 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:

Chapter 11 - Organizing Reports with the TOC and Frame Control

Setting Up a Table of Contents

ActiveReports 2.0 Standard User's Guide | 107

Page 108: 83791925 Active Report 2 0 Standard Edition

Using the TOC with SubreportsThe 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:

Using the TOC with Subreports

ActiveReports 2.0 Standard User's Guide | 108

Page 109: 83791925 Active Report 2 0 Standard Edition

Using the TOC with GroupsDepending 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 StringPrivate Sub ActiveReport_FetchData(EOF As Boolean)

If Not DataControl1.Recordset.EOF thensCountry = DataControl1.RecordSet.Fields("country")

End ifEnd Sub Private Sub Detail_Format()

TOC.Add sCountry & "\" & txtCustomerEnd Sub Private Sub ghOrderGroup_Format()

TOC.Add sCountryEnd Sub

The code above generates the following table of contents:

Using the TOC with Groups

ActiveReports 2.0 Standard User's Guide | 109

Page 110: 83791925 Active Report 2 0 Standard Edition

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 ControlThe 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 TableThis 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.

Working with the Frame Control

Using the Frame Control for a Table

ActiveReports 2.0 Standard User's Guide | 110

Page 111: 83791925 Active Report 2 0 Standard Edition

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 and StylesUsing Hyperlinks:l Using HTML Linksl Using Hyperlinks for DrillDown Reports

Chapter 12 - Hyperlinking, CSS and ActiveReports

ActiveReports 2.0 Standard User's Guide | 111

Page 112: 83791925 Active Report 2 0 Standard Edition

l Using Hyperlinks with the TOCl Using the MouseOver Event with Hyperlinks

Using Style Class:l Creating Global Stylesl Using Special Style Classes

Using HyperlinksActiveReports 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 linksThis 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:

7. Place two labels in the PageFooter and set their properties as follows:

Using Hyperlinks

Using HTML links

LineColor &H00800000&

LineWeight 3

X1 0

X2 4320

Y1 90

Y2 90

Name lblEmail lblHomePage

Caption Need Assistance? Email Support: [email protected]

Visit our home page: www.datadynamics.com

Height 360 270

Left 0 0

Top 180 630

Width 2790 3780

Hyperlink mailto:[email protected] www.datadynamics.com

ActiveReports 2.0 Standard User's Guide | 112

Page 113: 83791925 Active Report 2 0 Standard Edition

8. Place five fields in the Detail section and set their properties as follows:

9. Add the following code to the Detail_Format event:

Private Sub Detail_Format()Dim iStart As IntegerDim 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 = sHTMLtxtHomePage.Text = Replace(txtHomePage.Text, "#", " ", 1, -1, vbTextCompare)

End If End Sub

10. Save the project and run it.

Using Hyperlinks for Drill-Down reportsThis 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:

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.

Name txtCompanyName txtContactName txtPhone txtFax txtHomePage

Text CompanyName ContactName Phone Fax HomePage

DataField CompanyName ContactName Phone Fax HomePage

Height 360 270 270 270 270

Left 270 0 2970 4860 1440

Top 180 450 450 450 720

Width 4860 2880 1890 2160 7920

Font.Bold True True

Font-Size 12

Font-Underline

True

ForeColor &H00800000&

Using Hyperlinks for Drill-Down reports

Name arDrillDown

BorderStyle 1-vbFixedSingle

ActiveReports 2.0 Standard User's Guide | 113

Page 114: 83791925 Active Report 2 0 Standard Edition

6. Set the GroupHeader's properties as follows:

7. Set the GroupFooter's properties as follows:

8. Place a field in ghCategory and set its properties as follows:

9. Set the Detail section's height to 345.

10. Place three labels in ghCategory and set their properties as follows:

11. Place three fields in the Detail section and set their properties as follows:

Name ghCategory

Height 840

Name gfCategory

Height 135

Name txtCategoryName

Text CategoryName

DataField CategoryName

Height 450

Left 0

Top 0

Width 4050

Font.Size 16

Font.Bold True

Name lblProductName lblQperU lblUnitPrice

Caption Product Name Qnty Per Unit Unit Price

Height 270 270 270

Left 0 4230 7200

Top 540 540 540

Width 4140 2880 1440

Font.Bold True True True

Alignment 1-ddTXRight

Name txtProductName txtQuantityPerUnit txtUnitPrice

Text ProductName QuantityPerUnit UnitPrice

DataField ProductName QuantityPerUnit UnitPrice

Height 270 270 270

Left 0 4230 7200

Top 0 0 0

Width 4140 2880 1440

ActiveReports 2.0 Standard User's Guide | 114

Page 115: 83791925 Active Report 2 0 Standard Edition

With rptRDFs (from project above)1. Change the following properties for txtCompanyName:

2. Add the following code to the AcitveReport_FetchDate event:

Dim i_CompanyID As IntegerPrivate Sub ActiveReport_FetchData(EOF As Boolean)

If Not EOF Then'Gets the current records SupplierIDi_CompanyID = DataControl1.Recordset.Fields("SupplierID")

End IfEnd 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 selectedIf 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 IDarDrillDown.DataControl1.Source = "Select * from products, categories _

where products.categoryID = categories.categoryID and products._supplierID = " &Link

arDrillDown.ShowEnd If

End Sub

4. Add the following lines to the Detail_Format Event:

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

5. Save the project and run the report

Using Hyperlinks with the TOCThis 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:

Alignment 1-ddTXRight

OutputFormat Currency

ForeColor &H00800000&

Font.Underline True

Using Hyperlinks with the TOC

Name lblDirectory lblCompanyName lblPage

Caption Company Name Directory Company Name Page

Height 540 270 270

Left 0 90 270

Top 0 720 720

ActiveReports 2.0 Standard User's Guide | 115

Page 116: 83791925 Active Report 2 0 Standard Edition

4. Place a Line control in the PageHeader and set its properties as follows:

5. Place two Fields in the Detail Section and set their properties as follows:

6. Add the following code to the report:

Option Explicit Public PrintTOC As DDActiveReports2.TOCPrivate iEntry As Integer Private Sub ActiveReport_FetchData(eof As Boolean)

iEntry = iEntry + 1If iEntry >= PrintTOC.Count + 1 Then Exit Subeof = False

End Sub Private Sub ActiveReport_Initialize()

Set PrintTOC = NothingEnd Sub Private Sub ActiveReport_ReportStart()

If PrintTOC Is Nothing ThenMe.Cancel

End IfEnd Sub

Width 9360 2790 1170

Font.Bold True True True

Font.Size 20 9 9

Alignment 2-ddTXCenter 2-ddTXCenter

VerticalAlignment 1-ddTXMiddle 1-ddTXMiddle

LineColor &H00800000&

LineWeight 3

X1 0

X2 9360

Y1 990

Y2 990

Name txtEntry txtPage

Text CompanyName Page

Height 270 270

Left 90 3420

Top 90 90

Width 2790 1170

Font.Size 8 8

Font.Bold True True

Font.Underline True True

ForeColor &H00800000& Black

Alignment 2-ddTXCenter

ActiveReports 2.0 Standard User's Guide | 116

Page 117: 83791925 Active Report 2 0 Standard Edition

Private Sub Detail_Format()

Sets the TOC entry caption to the field's texttxtEntry.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 toctxtEntry.Hyperlink = "toc://" & PrintTOC.Item(iEntry - 1)'puts in the page number for the TOC itemtxtpage.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 IDarDrillDown.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 arTOCDim iPg As IntegerDim pg As Canvas

'Runs the arTOC report to generate the TOCSet rpt.PrintTOC = TOCrpt.Run' Insert all the arTOC pages into the end of' this reportiPg = Me.Pages.CountFor Each pg In rpt.Pages

Pages.Insert iPg, pgiPg = iPg + 1

Next' Commit all changes to the pages collectionPages.CommitUnload rptSet rpt = Nothing

End Sub

4. Save the project and run it.

Using the MouseOver Event with HyperlinksThe 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 _

Using the MouseOver event with Hyperlinks

ActiveReports 2.0 Standard User's Guide | 117

Page 118: 83791925 Active Report 2 0 Standard Edition

Long, ByVal hyperLink As String)If InStr(1, hyperLink, "htm", vbTextCompare) > 0 Then

Me.StatusBar1.Panels(1).Text = "Click to Visit Home Page:" & hyperLinkElseIf InStr(1, hyperLink, "mailto", vbTextCompare) > 0 Then

Me.StatusBar1.Panels(1).Text = "Send Email:" & Right(hyperLink,_Len(hyperLink) - 7)

ElseMe.StatusBar1.Panels(1).Text = ""

End IfEnd Sub

Using Style ClassesActiveReports 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 Styles1. 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.

Using CSS

Creating Global Styles

ActiveReports 2.0 Standard User's Guide | 118

Page 119: 83791925 Active Report 2 0 Standard Edition

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 PropertyThe 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 Style ClassesThere 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; text-decoration: 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.

Using Special CSS Styles

Chapter 13 - Saving and Loading

ActiveReports 2.0 Standard User's Guide | 119

Page 120: 83791925 Active Report 2 0 Standard Edition

Chapter 13 - Saving and LoadingSaving 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 FilesActiveReports 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 frmRDFs1. 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:

3. Add the following code to the cmdSave_Click event:

Private Sub cmdSave_Click()rptRDFs.RunrptRDFs.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 rptRDFs1. 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:

Saving And Loading RDF Files

Name cmdSave cmdLoad

Caption Save Report Load Report

Enabled True False

BackColor Black

ActiveReports 2.0 Standard User's Guide | 120

Page 121: 83791925 Active Report 2 0 Standard Edition

7. Place three fields in the GroupHeader and set their properties as follows:

8. Set the GroupFooter's properties as follows:

9. Select the Detail section and set the section's properties as follows:

10. Place a Shape control in the Detail Section and set its properties as follows:

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:

BackStyle 1-Normal

CanShrink False

Height 330

DataField EmployeeID

GrpKeepTogether 2-All

KeepTogether True

Name txtEmployeeID txtFirstName txtLastName

Text EmployeeID FirstName LastName

DataField EmployeeID FirstName LastName

Height 270 270 270

Left 0 1440 2880

Top 0 0 0

Width 1260 1440 1440

BackColor Black

BackStyle 1-Normal

CanGrow False

Height 100

KeepTogether True

BackColor &H00404040&

BackStyle Normal

CanShrink False

Height 1650

BackColor &H00C0C0C0&

BackStyle 1-ddBKNormal

Height 720

Left 0

Top 450

Width 9360

Name txtTitle txtHireDate txtExtension txtHomePhone txtAddress

Text Title HireDate Extension HomePhone Address

DataField Title HireDate Extension HomePhone Address

ActiveReports 2.0 Standard User's Guide | 121

Page 122: 83791925 Active Report 2 0 Standard Edition

13. Save the project and run it.

Using ActiveReports' Export FiltersIncluded 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:

Height 270 270 270 270 270

Left 90 1620 3150 90 90

Top 90 90 90 1260 540

Width 1440 1440 1440 1440 9180

ForeColor &H00E0E0E0& &H00E0E0E0& &H00E0E0E0& &H00E0E0E0&

BackColor &H00E0E0E0&

BackStyle 1-ddBKNormal

Using ActiveReports' Export Filters

Name cmdExport

Caption Export Report

ActiveReports 2.0 Standard User's Guide | 122

Page 123: 83791925 Active Report 2 0 Standard Edition

6. Add the following code to the cmdExport_Click event:

Dim exportType As StringPrivate Sub cmdExport_Click()

exportType = cExportType.TextExportReportMsgBox cExportType.Text & " Export Completed"

End Sub

7. Add a ComboBox to the form and set its properties as follows:

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

Private Sub ExportReport()Dim oPDF As ActiveReportsPDFExport.ARExportPDFDim oEXL As ActiveReportsExcelExport.ARExportExcelDim oTXT As ActiveReportsTextExport.ARExportTextDim oHTML As ActiveReportsHTMLExportLexportDim oTIFF As ActiveReportsTIFFExport.TIFFExport

rptExport.RunSelect Case exportType

Case "PDF"Set oPDF = New ActiveReportsPDFExport.ARExportPDFoPDF.FileName = App.Path & "\PDFExport.PDF"oPDF.Export rptExport.Pages

Case "Excel"Set oEXL = New ActiveReportsExcelExport.ARExportExceloEXL.FileName = App.Path & "\EXLExport.xls"oEXL.Export rptExport.Pages

Case "Text"Set oTXT = New ActiveReportsTextExport.ARExportTextoTXT.FileName = App.Path & "\TXTExport.txt"oTXT.PageDelimiter = ";"oTXT.TextDelimiter = ","oTXT.Export rptExport.Pages

Case "HTML"Set oHTML = New ActiveReportsHTMLExportLexportoHTML.FileNamePrefix = "HTMLExport"oHTMLLOutputPath = App.PathoHTML.Export rptExport.Pages

Case "Tiff"Set oTIFF = New ActiveReportsTIFFExport.TIFFExportoTIFF.FileName = App.Path & "\TIFFExport.tiff"oTIFF.Export rptExport.Pages

End SelectEnd 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 OnProgressEach 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 myFilterDim WithEvents FilterEvents As ActiveReportsPDFExport.ARExportPDFPrivate Sub cmdExport_Click()

Set myFilter = New ActiveReportsPDFExport.ARExportPDFrptExport.Run False'Set the progress bar's max value to the number'of pages in the report

Name cExportType

List PDF Excel TIFF HTML Text

ActiveReports 2.0 Standard User's Guide | 123

Page 124: 83791925 Active Report 2 0 Standard Edition

ProgressBar1.Max = rptExport.Pages.CountProgressBar1.Value = 0myFilter.FileName = App.Path & "\out.pdf"Set FilterEvents = myFiltermyFilter.Export rptExport.Pages

End Sub Private Sub FilterEvents_OnProgress(ByVal PageNumber As Long)

'Updates the progress barProgressBar1.Value = PageNumberProgressBar1.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 FilesSaving 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 CanvasDim pgs As IntegerPrivate Sub cmdLoad_Click()

Dim rptTemp As ActiveReportSet rptTemp = New ActiveReportFor x = 0 To pgs - 1

Set cnv = new Canvascnv.Load App.Path & "\rptRDF_" & x & ".cnv"rptTemp.Pages.Insert x, cnv

NextrptTemp.Pages.CommitARViewer21.ReportSource = rptTemp

End Sub

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

Private Sub cmdSave_Click()rptRDFs.RunFor Each pg In rptRDFs.Pages

Set cnv = rptRDFs.Pages(pgs)cnv.Save App.Path & "\rptRDF_" & pgs & ".cnv"pgs = pgs + 1

NextcmdLoad.Enabled = TruecmdSave.Enabled = False

End Sub

3. Save the report and run it.

Saving and Loading Report LayoutsReport 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.

Saving and Loading Canvas Files

Saving and Loading Report Layouts

ActiveReports 2.0 Standard User's Guide | 124

Page 125: 83791925 Active Report 2 0 Standard Edition

1. Change the code under the cmdLoad_Click event to match below:

Private Sub cmdLoad_Click()Dim rptTemp As ActiveReportSet rptTemp = New ActiveReportrptTemp.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.RunrptRDFs.SaveLayout App.Path & "\rptRDF.RPX", ddSOFilecmdLoad.Enabled = TruecmdSave.Enabled = False

End Sub

3. Save the report and run it.

Saving and Loading to a Byte ArraySaving 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 BytePrivate Sub cmdLoad_Click()

Dim rptTemp As ActiveReportSet rptTemp = New ActiveReportrptTemp.LoadLayout rByteARViewer21.ReportSource = rptTemp

End Sub

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

Private Sub cmdSave_Click()rptRDFs.RunrByte = rptRDFs.SaveLayout("", ddSOByteArray)cmdLoad.Enabled = TruecmdSave.Enabled = False

End Sub

3. Save the report and run it.

Chapter 14 - ScriptingWhat are Scripts For?

How to Add Scripts

Working with Scripts

Using XML (.RPX) Files

Saving and Loading to a Byte Array

Chapter 14 - Scripting

What are Scripts for?

ActiveReports 2.0 Standard User's Guide | 125

Page 126: 83791925 Active Report 2 0 Standard Edition

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 ScriptsTo 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).

How to Add Scripts

ActiveReports 2.0 Standard User's Guide | 126

Page 127: 83791925 Active Report 2 0 Standard Edition

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 ScriptsIn 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 OnDataInitializeDim cnnStr' Set Connection String and connect to DBcnnStr = "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 recordssetrpt.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.

Working With Scripts

ActiveReports 2.0 Standard User's Guide | 127

Page 128: 83791925 Active Report 2 0 Standard Edition

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

Working With a DSR FileWhen 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 fileIn 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.RecordsetSub OnDataInitialize

' Add fields to ActiveReports' Fields Collectionrpt.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 trueIf rs.EOF Then Exit Sub' Sets ActiveReports' fields collection values to the' current recordset valuerpt.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 recordsetrs.MoveNext' If not EOF set the FetchData's EOF value to FalseEOF = 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.RecordsetDim cn As ADODB.ConnectionDim rs As ADODB.RecordsetSet cn = New ADODB.ConnectionSet rs = New ADODB.Recordset' Set Connection String and connect to DB

ActiveReports 2.0 Standard User's Guide | 128

Page 129: 83791925 Active Report 2 0 Standard Edition

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 recordssetrs.Open "Select * from customers order by Country", cnSet 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 ActiveReportSet rptXML = New ActiveReportrptXML.LoadLayout App.Path & "\UnboundScript.RPX"rptXML.AddNamedItem "myDB", new clsDBrptXML.RunSet ARViewer21.ReportSource = rptXML

End Sub

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

Using AddNamedItem and AddCodeThe 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 ehViewPreviewSet m_rpt = NothingSet m_rpt = New ActiveReportm_rpt.ResetScriptsm_rpt.AddNamedItem "vbo", m_vbom_rpt.AddCode ScriptCode()m_rpt.ScriptDebuggerEnabled = Truem_rpt.Run FalseSet arv.ReportSource = m_rptExit SubehViewPreview:

MsgBox Str(Err.Number) & " - " & Err.Description, vbOKOnly, _"Error: ViewPreview"

End Sub Private Function ScriptCode() As String

Dim sCode As StringsCode = 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 = sCodeEnd 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 XML (.RPX) Files

Using RPX Files

ActiveReports 2.0 Standard User's Guide | 129

Page 130: 83791925 Active Report 2 0 Standard Edition

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 ControlActiveReports' 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 ControlActiveReports 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.

Chapter 15 - Using ActiveReports' ActiveX Viewer Control

ActiveReports' ActiveX Viewer Control

ActiveReports 2.0 Standard User's Guide | 130

Page 131: 83791925 Active Report 2 0 Standard Edition

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 VB1. 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 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:

Adding the Viewer Control to VB

Creating a Custom Preview Screen

ActiveReports 2.0 Standard User's Guide | 131

Page 132: 83791925 Active Report 2 0 Standard Edition

Private Sub Form_Load()arv.ReportSource = New ActiveReport1

End Sub

Your form should look like this:

Using Split Windows on the Viewer ControlThe Viewer control's windows can easily be split into two sections by dragging the slitter control down.

Using Split Windows on the Viewer Control

ActiveReports 2.0 Standard User's Guide | 132

Page 133: 83791925 Active Report 2 0 Standard Edition

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 ControlThis sample project demonstrates how to customize the viewer control by adding additional buttons

Adding Buttons to the Viewer Control

ActiveReports 2.0 Standard User's Guide | 133

Page 134: 83791925 Active Report 2 0 Standard Edition

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:

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:

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 = 2arv.ToolBar.Tools.Item(1).ID = 999

'Insert the Close botton in the'third positionarv.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 positionarv.ToolBar.Tools.Insert 3, ""arv.ToolBar.Tools.Item(3).Type = 2arv.ToolBar.Tools.Item(3).ID = 1001

'Insert the Open button in the'fifth position and assign it'and iconarv.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 itarv.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

Name frmViewer

BorderStyle 1-Fixed Single

Height 8310

Width 13440

Name arv

Height 7815

Left 120

Top 0

Width 13095

ActiveReports 2.0 Standard User's Guide | 134

Page 135: 83791925 Active Report 2 0 Standard Edition

arv.ToolBar.Tools.Item(5).ID = 1003

'Add the PDF export button to the'end of the toolbar and disable itarv.ToolBar.Tools.AddEx("&PDF").Tooltip = "Export To PDF"arv.ToolBar.Tools.Item(arv.ToolBar.Tools.Count - 1).Enabled = Falsearv.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 subtbOpen

Case Is = "&Close"'call the exit subtbExit

Case Is = "&PDF"'call the PDFExport subtbPDFExport

Case Is = "&Save"'call the Save subtbSave

End SelectEnd 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.ShowOpenIf cmndlg.FileName <> "" Then

If Not arv.ReportSource Is Nothing ThenSet arv.ReportSource = Nothing

End Ifarv.Pages.Load cmndlg.FileName'Enables buttons when a report is loadedarv.ToolBar.Tools.Item(5).Enabled = Truearv.ToolBar.Tools.Item(arv.ToolBar.Tools.Count - 1).Enabled = True

End If End Sub Private Sub tbPDFExport()

Dim pdf As New ActiveReportsPDFExport.ARExportPDFSet pdf = New ActiveReportsPDFExport.ARExportPDFcmndlg.Filter = "Portable Document Format" & _

" (*.pdf)|*.pdf"cmndlg.DefaultExt = ".pdf"cmndlg.ShowSaveIf cmndlg.FileName <> "" Then

pdf.FileName = cmndlg.FileNameIf Not arv.ReportSource Is Nothing Then

pdf.Export arv.ReportSource.PagesElse

pdf.Export arv.PagesEnd If

End IfEnd Sub Private Sub tbSave()

ActiveReports 2.0 Standard User's Guide | 135

Page 136: 83791925 Active Report 2 0 Standard Edition

cmndlg.Filter = "Report Document File (*.rdf)|*.rdf"cmndlg.DefaultExt = ".rdf"cmndlg.ShowSaveIf cmndlg.FileName <> "" Then

If Not arv.ReportSource Is Nothing Thenarv.ReportSource.Pages.Save _cmndlg.FileName

Elsearv.Pages.Save cmndlg.FileName

End IfEnd 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 ViewerThe 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 toolFor cnt = 0 To arv.ToolBar.Tools.Count - 1

If "&Print..." = arv.ToolBar.Tools(cnt).Caption Thenarv.ToolBar.Tools(cnt).ID = CONST_PRINTTOOLID

End IfNext 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 subtbOpen

Case Is = "&Close"'call the exit subtbExit

Case Is = "&PDF"'call the PDFExport subtbPDFExport

Case Is = "&Save"'call the Save subtbSave

Case Is = "&Print..."arv.UseSourcePrinter = Truearv.Printer.SetupDialogbReturn = arv.Printer.PrintDialog(Me.hWnd)

Controlling Printing and Printer Setup on the Viewer

ActiveReports 2.0 Standard User's Guide | 136

Page 137: 83791925 Active Report 2 0 Standard Edition

If bReturn Thenarv.PrintReport FalseCancelledJob = False

ElseCancelledJob = True

End IfEnd Select

End Sub

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

Private Sub tbOpen()cmndlg.Filter = "Report Document File (*.rdf)|*.rdf"cmndlg.ShowOpenIf cmndlg.FileName <> "" Then

If Not arv.ReportSource Is Nothing ThenSet arv.ReportSource = Nothing

End Ifarv.Pages.Load cmndlg.FileName'Enables buttons when a report is loadedarv.ToolBar.Tools.Item(5).Enabled = Truearv.ToolBar.Tools.Item(arv.ToolBar.Tools.Count - 1).Enabled = True'Enable print buttonarv.ToolBar.Tools.Item(7).Enabled = True

End IfEnd Sub

Chapter 16 - ActiveReports on the WebUsing the ARViewer Control with Internet Explorer

Using the Java Viewer Control

Creating a ReportServer with ASP and ActiveReports

Using the ARViewer Control with Internet ExplorerSaved 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.

<objectID="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 outputSub 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

Chapter 16 - ActiveReports on the Web

Using the Viewer Control with Internet Explorer

ActiveReports 2.0 Standard User's Guide | 137

Page 138: 83791925 Active Report 2 0 Standard Edition

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 ControlActiveReports' 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=javascripttype=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><DIVstyle="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=cboReportonchange="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 appearbelow in a Java enabled browser.<BR><OBJECT align=middle classid=clsid:8AD9C840-044E-11D1-B3E9-00805F499D93codeBase=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">

Using the Java Viewer Control

ActiveReports 2.0 Standard User's Guide | 138

Page 139: 83791925 Active Report 2 0 Standard Edition

<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> <EMBEDtype="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 ActiveReportsSetting up the ReportServer DLLOne 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

eRDFePDF

End Enum Enum eReport

erptAnnualReportserptCatalogerptCustomerLabels

End Enum

Creating a ReportServer with ASP and ActiveReports

ActiveReports 2.0 Standard User's Guide | 139

Page 140: 83791925 Active Report 2 0 Standard Edition

Public Property Let Report(iRpt As eReport)

Dim hr As LongApp.LogEvent "Report: " & iRptDebug.Print "Report: " & iRptm_iReport = iRpt

End Property Public Property Let OutputFormat(iFormat As eOutputFormat)

App.LogEvent "OutputFormat: " & iFormatDebug.Print "OutputFormat: " & iFormatm_iFormat = iFormat

End Property Public Function StripFileName(path As String) As String

Dim iStart As IntegeriStart = 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 ObjectDim pdf As New ActiveReportsPDFExport.ARExportPDF

'Use App.LogEvents to debug compiled codeApp.LogEvent "RunReport Started"Debug.Print "RunReport Started"

Select Case m_iReportCase erptAnnualReports: Set rpt = New rptAnnualReportCase erptCatalog: Set rpt = New rptCatalogCase erptCustomerLabels: Set rpt = New rptCustomerLabelsCase Else

RunReport = FalseExit Function

End Select

App.LogEvent "Preparing to Run"Debug.Print "Preparing to Run"rpt.Run FalseApp.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 modulesIf Not GetTempFileName(sServerPath, "AR", -1, m_sFName) Then

RunReport = FalseExit Function

End If

m_sFName = Left$(m_sFName, InStr(m_sFName, Chr$(0)) - 1)App.LogEvent "File name = " & m_sFNameDebug.Print "File name = " & m_sFNameIf m_iFormat = eRDF Then

App.LogEvent "Exporting to RDF"Debug.Print "Exporting to RDF"rpt.Pages.Save m_sFNameApp.LogEvent "Export to RDF Complete"Debug.Print "Export to RDF Complete"

ElseIf m_iFormat = ePDF Thenpdf.FileName = m_sFNameApp.LogEvent "Exporting to PDF"Debug.Print "Exporting to PDF"pdf.Export rpt.PagesApp.LogEvent "Export to PDF Complete"Debug.Print "Export to PDF Complete"

End IfApp.LogEvent "RunReport Completed"

ActiveReports 2.0 Standard User's Guide | 140

Page 141: 83791925 Active Report 2 0 Standard Edition

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 = FalseEnd Function

Setting up the ASP scriptWhen 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 rptServerDim fname

Set rptServer = CreateObject("ARASPSample.ReportServer")rptServer.Report = Request.Form("cboReport")rptServer.OutputFormat = 1If 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 patharv.DataPath="Reports/<%Response.Write fname%>"

end sub--></script><%else%><BODY><P>

Error: Unable to create report.<BR>Please send email to <A HREF="mailto:[email protected]">ActiveReports.

[email protected]</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 DistributionTo serve reports to clients in a web environment, your web server should have arview2.cab (if using

ActiveReports 2.0 Standard User's Guide | 141

Page 142: 83791925 Active Report 2 0 Standard Edition

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 LicensingRegistration

Technical Support

Data Dynamics Web Site

Data Dynamics News Server

Upgrades

Suggestions

Defects Policy

License Agreement

ActiveReports Error Codes

Product RegistrationIn 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 SupportIf 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 [email protected] 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.

Support and Licensing

Production Registration

Technical Support

ActiveReports 2.0 Standard User's Guide | 142

Page 143: 83791925 Active Report 2 0 Standard Edition

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

[email protected]

Telephone and Fax

Fax: 614.899.2943

Telephone: 614.895.3142 (8 a.m. to 7 p.m. EST, M-F)

Web SiteOur 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

ForumsUse 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 UpgradesMinor 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.

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

Web Site

NewsGroups

Product Upgrades

Suggestions

ActiveReports 2.0 Standard User's Guide | 143

Page 144: 83791925 Active Report 2 0 Standard Edition

Media Defects PolicyData 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 WarrantyActiveReports 2.0Please 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:

LICENSEThe 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 Licensee’s proprietary applications. Please contact Data Dynamics if you require additional Licenses. Licensee may incorporate the sample code into Licensee’s 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 Licensee’s 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 LICENSEE’S 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:

Disk Defects Policy

License Agreement and Limited Warranty

ActiveReports 2.0 Standard User's Guide | 144

Page 145: 83791925 Active Report 2 0 Standard Edition

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

US GOVERNMENT RESTRICTED RIGHTSUse, 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.

TERMLicensee 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 WARRANTYThis 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 Description Object

2000 GridX/Y out of range. The valid range is 1 to 48 ActiveReport

2001 Section.Name is invalid. Only alphanumeric characters are allowed.

Section

2002 Duplicate Name. The Control or Section name already exists

Section, Control

2003 Invalid Property Value. The Property value is out of range or incorrect.

ActiveReport, CheckBox, Canvas, Field, TOC, Label, OleObject, Printer, RDOControl, Shape, Section, BarCode

2004 RDO control RowsetSize or KeysetSize was set to incorrect value.

RDO Data Control

2005 RDO control resultset was set to invalid object. The control was expecting a valid resultset object.

RDO Data Control

2006 RDO control connection property was set to invalid or empty object. The control was expecting a valid connection object.

RDO Data Control

2007 Printer driver doesn't support PaperBins. Printer

2008 Printer driver doesn't support custom PaperSize (256). Printer

2009 Printer.StartJob was called multiple times without ending prior job.

Printer

2010 Printer.EndJob called without a call to Printer.StartJob. Printer

2011 Printer.Escape method called but no printer job is active. Call Printer.StartJob to start sending escape codes to printer.

Printer

2012 Invalid call to Printer.StartPage, EndPage, PrintPage . Print job is not active. Call Printer.StartJob first.

Printer

2013 Passthrough escape sequences are not supported by the current printer driver

Printer

2014 Accessing SubReport.Object failed. The object property has not yet been set.

Subreport

ActiveReports 2.0 Standard User's Guide | 145

Page 146: 83791925 Active Report 2 0 Standard Edition

2015 SubReport.Object property was set to invalid object. The object property only supports a valid ActiveReport instance.

Subreport

2016 Controls.Item or Controls.Remove was called with incorrect index. The control name does not exist in the collection.

Controls

2017 ReplaceField called with field name that doesn't exist in the RTF document.

RichEdit

2018 Margins are too large ActiveReport

2019 Page header and footer are too large, can't process report layout

ActiveReport

2020 RDO (Remote Data Object) is not installed on this machine ActiveReport

2021 The filter parameter is not a valid export filter. Export

2100 Duplicate Field name. The report fields collection already has a member with same field name.

ActiveReport.Fields

2101 Report already started processing. Can't change Fields collection at this time.

ActiveReport.Fields

2102 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

2103 ActiveReport.Load failed. MSXML 3.0 is not installed or could not create XMLDOMDocument object.

ActiveReport

2104 ActiveReport.Load failed. Unknown error due to MSXML. ActiveReport

2105 ActiveReport.Load failed. The XML data is incorrect (wrong node hierarchy) or corrupt.

ActiveReport

2106 XMLControl.Load failed. Error due to empty FileURL property.

XML Control

2107 Field.Text property contains invalid expression. Parsing failure on script.

Field

2108 Field script expression failed during execution of report. Field

2109 Can't load RDF file. Invalid password. Please set password property before calling Pages.Load method.

Pages

2110 GetPagesInRange parameter is invalid. Incorrect page range.

Pages

2111 Can't modify Pages collection. This Pages collection was obtained using GetPagesInRange method and is read-only.

Pages

2112 PrintPage was called with invalid Left, Top, Width, Height parameters.

Printer

2113 Property access failed due to invalid section type. Example: detail sections don't support the GrpKeepTogether property.

Section

2114 Method failed due to invalid ADO control properties. Please check Connection string.

ADO Control

2115 XML Data Control was expecting a valid XMLDOMNodeList object.

XML Control

2116 Method failed due to empty pages collection. Pages, Export filters

2117 PrintAtBottom is being specified for a section that does not support it, such as a PageHeader or PageFooter.

Section

2120 An invalid index has been specified for the Parameters collection.

Parameters

5000 Report processing failed due to error in data source or a serious error. Please see description.

ActiveReport

5003 Bad parameter value All objects

5004 Method failed. Can't create file. Incorrect filename or target file exists or is read-only. See description

Canvas, Pages

5005 Method failed. Can't read file. Please check if the file exists and make sure you have access permissions to the file.

Canvas, Pages

ActiveReports 2.0 Standard User's Guide | 146

Page 147: 83791925 Active Report 2 0 Standard Edition

5006 The RDF file or canvas binary file is corrupt or has incorrect file format.

Canvas, Pages

5007 No printer installed. Can't run report. Either install a printer or set the Printer.DeviceName property to empty to use a virtual printer.

ActiveReport

5008 Report already processing. Can't modify sections collection at this time.

Sections

5009 Print Job has not yet been started, can't return Printer.hDC property.

Printer

5010 Printer.Escape method failed. The escape is not supported by driver or printer driver rejected parameters.

Printer

5011 Value out of range. All objects

5012 Printer timeout. Possible reason: network printer is offline. Printer

5013 Invalid DataPath property. The URL doesn't exist or failed. ARViewer

5014 Driver reported error when trying to set Printer.Port Printer

5015 Invalid printer port name or port name doesn't exist. Printer

5016 Subreport failed during processing of report. See description for error.

ActiveReport

5017 Invalid index provided in Sections.Add method. Sections

5704 Can't open ADO connection. Please check ADO connection string.

ADO Control

5706 Can't remove section. Section name is incorrect. Sections

5707 Can't set Printer.DeviceName. The device doesn't exist Printer

7000 Setting ReportSource failed due to incorrect object. Please pass a valid ActiveReport object from the same process.

ARViewer

7001 ReportSource failed to respond. ARViewer

7002 ReportSource.GetReport returned incorrect object type. ARViewer

ActiveReports 2.0 Standard User's Guide | 147

Page 148: 83791925 Active Report 2 0 Standard Edition

ReferenceConstants

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

ConstantsADOLockType

ADOCursorLocation

ADOCursorType

Reference

Constants

Value Mnemonic Description

-1 ddADOLockUnspecified

1 ddADOLockReadOnly Read-only, you cannot alter the data

2 ddADOLockPessimistic 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.

3 ddADOLockOptimistic The provider uses optimistic locking, locking records only when you call the update method.

4 ddADOLockBatchOptimistic Required for the batch update mode as opposed to immediate update mode.

Value Mnemonic Description

2 ddADOUseServer Create a server-side cursor.

3 ddADOUseClient Create a client-side cursor.

ActiveReports 2.0 Standard User's Guide | 148

Page 149: 83791925 Active Report 2 0 Standard Edition

BackStyle

BarCodeCaptionPosition

BarCodeDirection

BarCodeStyle

Value Mnemonic Description

0 ddADOOpenForwardOnly Default - Creates a forward-only cursor.

1 ddADOOpenKeyset Keyset cursor

2 ddADOOpenDynamic Dynamic Cursor

3 ddADOOpenStatic Static cursor

Value Mnemonic Description

0 ddBKTransparent Transparent opaque background, the objects behind the object show through the object.

1 ddBKNormal Normal, the object hides all controls behind it.

Value Mnemonic Description

0 ddbcCaptionNone Does not display the barcode's caption.

1 ddbcCaptionAbove The caption is positioned above the barcode.

2 ddbcCaptionBelow The caption is positioned below the barcode.

Value Mnemonic Description

0 ddbcLeftToRight Sets the barcode's direction left to right horizontally.

1 ddbcRightToLeft Sets the barcode's direction right to left horizontally.

2 ddbcTopToBottom Sets the barcode's direction down the page vertically.

3 ddbcBottomToTop Sets the barcode's direction up the page vertically

Value Mnemonic Description

0 ddbcNone None

1 ddbcAnsi39 ANSI 3 of 9 (Code 39) uses upper case, numbers, - , * $ / + %

2 ddbcAnsi39X ANSI Extended 3 of 9 (Extended Code 39) uses the complete ASCII character set

3 ddbcCode_2_of_5 2 of 5 uses only numbers

4 ddbcCode25intlv Interleaved 2 of 5 uses only numbers

5 ddbcCode25mat 25 Matrix

6 ddbcCode39 Code 39 uses numbers, % * $ /. , - +, and upper case.

7 ddbcCode39x Extended Code 39 uses the complete ASCII character set

8 ddbcCode_128_A 128 A uses control characters, numbers, punctuation, and upper case

9 ddbcCode_128_B 128 B uses punctuation, numbers, upper case, and lower case

10 ddbcCode_128_C 128 C uses only numbers

11 ddbcCode_128auto 128 Auto uses complete ASCII character set. Automatically selects between Code 128 A, B, and C to give the smallest barcode.

12 ddbcCode93 Code 93 uses uppercase, % $ * / , + -, and numbers

13 ddbcCode93x Extended Code 93 uses the complete ASCII character set

14 ddbcMSI MSI Code uses only number

15 ddbcPostNet PostNet uses only numbers with a check digit

16 ddbcCodabar Codabar uses A B C D + - : , / and numbers

17 ddbcEAN_8 EAN-8 uses only numbers (7 numbers and a check digit)

18 ddbcEAN_13 EAN-13 uses only numbers (12 numbers and a check digit)

ActiveReports 2.0 Standard User's Guide | 149

Page 150: 83791925 Active Report 2 0 Standard Edition

BorderLineStyle

ColumnDirections

DAOCursorType

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

DAODefaultType

19 ddbcUPC_A UPC-A uses only numbers (11 numbers and a check digit)

20 ddbcUPC_E0 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

21 ddbcUPC_E1 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.

22 ddbcRM4SCC 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

23 ddbcUCCEAN128 UCC/EAN – 128 uses the complete ASCII character Set. A Special version of Code 128 used in HIBC applications.

Value Mnemonic Description

0 ddBLNone Invisible, no border.

1 ddBLSolid

2 ddBLDash

3 ddBLDot

4 ddBLDashDot

5 ddBLDashDotDot

6 ddBLDouble

7 ddBLThickSolid

8 ddBLThickDash

9 ddBLThickDot

10 ddBLThickDashDot

11 ddBLThickDashDotDot

12 ddBLThickDouble

13 ddBLExtraThickSolid

Value Mnemonic Description

0 ddCDDownAcross Print each section down each column followed by the next column to its right.

1 ddCDAcrossDown Print sections right across the first row followed by the second row and so on.

Value Mnemonic Description

0 ddDAODefaultCursor Let the ODBC driver select the cursor type.

1 ddDAOODBCCursor Use the ODBC driver client-side cursor.

2 ddDAOServerSideCursor Let the server manage the cursor

Value Mnemonic Description

1 ddDAOUseODBC Use ODBCDirect to bypass the JET engine and access RDO directly.

ActiveReports 2.0 Standard User's Guide | 150

Page 151: 83791925 Active Report 2 0 Standard Edition

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

DAORecordsetType

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

FindConstants

GrpKeepTogether

Job Status

LayoutAction

LoadSaveConstants

LineStyle

2 ddDAOUseJet Use the Microsoft JET to access your data source.

Value Mnemonic Description

0 ddDAOTable Table type recordset object

1 ddDAODynaset Dynaset type recordset object

2 ddDAOSnapshot Snapshot type recordset object

Value Mnemonic Description

2 rtfWholeWord Find whole word

4 rtfMatchCase Case sensitive search

8 rtfDown Search forward in the text stream

16 rtfUp Search backward in the text stream.

Value Mnemonic Description

0 ddGrpNone A page can be broken immediately after a group header.

1 ddGrpFirstDetail The group header will print with the first detail section on the same page or column.

2 ddGrpAll The group header, detail and group footer will print together on the same page.

Value Mnemonic Description

0 ddJSIdle Indicates that the print job is idle.

1 ddJSPrinting Indicates that the job is printing.

2 ddJSCompleted Indicates that the job has completed printing.

3 ddJSAborted Indicates that the current print job has been aborted.

Value Mnemonic Description

1 ddLAPrintSection Specifies whether a section should be printed

2 ddLAMoveLayout Specifies whether ActiveReports should move to the next printing location on the page

4 ddLANextRecord Specifies whether a section should advance to the next record

Value Mnemonic Description

0 rtfRTF Save text stream to RTF file.

1 rtfText Save text stream to an ASCII text file.

Value Mnemonic Description

0 ddLSTransparent No line.

1 ddLSSolid

2 ddLSDash

ActiveReports 2.0 Standard User's Guide | 151

Page 152: 83791925 Active Report 2 0 Standard Edition

NewPageConstants

PictureAlignment

PrtCollate

PrtDuplex

PrtOrientation

PrtQuality

ReportStatus

3 ddLSDot

4 ddLSDashDot

5 ddLDDashDotDot

Value Mnemonic Description

0 ddNPNone No page-break before the section.

1 ddNPBefore Start printing the section on a new page.

2 ddNPAfter Start a new page after printing the section.

3 ddNPBeforeAfter Start printing the section on a new page and start a new page after printing it.

Value Mnemonic Description

0 ddPATopLeft Align the picture to the top left corner of the image control area.

1 ddPATopRight Align the picture to the top right corner of the image control area.

2 ddPACenter Align the picture in the center of the image control area.

3 ddPABottomLeft Align the picture to the bottom left corner of the image control area.

4 ddPABottomRight Align the picture to the bottom right corner of the image control area.

Value Mnemonic Description

-1 COLLATE_PRINTERDEFAULT The report will use the setting selected on the default printer

0 COLLATE_FALSE Do not collate multiple copies together.

1 COLLATE_TRUE Collate multiple copies together. All pages of each copy are printed as a group.

Value Mnemonic Description

-1 ddDXPrinterDefault The report will use the default setting on the selected printer

1 ddDXSimplex No duplex printing.

2 ddDXHorizontal Print to both sides of the paper horizontally.

3 ddDXVertical Print to both sides of the paper vertically.

Value Mnemonic Description

-1 ddODefault Uses printer's default orientation setting

1 ddOPortrait Print along the width of the paper.

2 ddOLandscape Print along the length of the paper.

Value Mnemonic Description

-1 ddPQDraft Draft, very low resolution.

-2 ddPQLow Low resolution.

-3 ddPQMedium Medium resolution.

-4 ddPQHigh High resolution.

ActiveReports 2.0 Standard User's Guide | 152

Page 153: 83791925 Active Report 2 0 Standard Edition

RDOCursorDriver

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

RDOLockType

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

RDOPrompt

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

RDOResultsetType

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

RepeatStyle

Value Mnemonic Description

0 ddStatIdle Indicates the report is idle.

1 ddStatRunning Indicates the report is running.

2 ddStatCompleted Indicates the report is completed

3 ddStatCancelled Indicates the report was cancelled.

Value Mnemonic Description

0 ddRDOUseIfNeeded The ODBC Driver will choose the appropriate driver to use.

1 ddRDOUseODBC Use the ODBC Driver cursor library.

2 ddRDOUseServer Use server side cursors.

3 ddRDOUseClientBatch Use optimistic client-side cursor

4 ddRDOUseNone Recordset is not returned as a cursor.

Value Mnemonic Description

1 ddRDOConcurReadOnly The recordset is read-only (not updateable)

2 ddRDOConcurLock Pessimistic concurrency

3 ddRDOConcurRowVer Optimistic concurrency (based on row id)

4 ddRDOConcurValues Optimistic concurrency (based on row values)

5 ddRDOConcurBatch Optimistic concurrency using batch mode. A status is returned for each successful update.

Value Mnemonic Description

0 ddRDODriverPrompt 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.

1 ddRDODriverNoPrompt The driver manager uses the connection string provided in connect. If sufficient information is not provided, the OpenConnection method returns a trappable error.

2 ddRDODriverComplete 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.

3 ddRDODriverCompleteRequired Behaves like ddRDODriverComplete except the driver disables the controls for any information not required to complete the connection.

Value Mnemonic Description

1 ddRDOOpenKeySet Creates a keyset resultset

3 ddRDOOpenStatic Creates a static resultset

Value Mnemonic Description

ActiveReports 2.0 Standard User's Guide | 153

Page 154: 83791925 Active Report 2 0 Standard Edition

SaveOptionTypes

SectionType

ShapeType

SizeMode

SplitType

SummaryFunctions

0 ddRepeatNone Do not reprint the group header.

1 ddRepeatOnPage Print the group header at the top of each page within the group's detail sections.

2 ddRepeatOnColumn Print the group header at the top of each column within the group's detail sections.

3 ddRepeatAll Print the group header at the top of each column and page within the group's detail sections.

4 ddRepeatOnPageIncludeNoDetail 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.

Value Mnemonic Description

1 ddSOFile Save report layout to a file.

2 ddSOByteArray Save report layout to a byte array.

Value Mnemonic Description

0 ddSTReportHeader A section that prints once per report before any other report section is printed.

1 ddSTReportFooter A section that prints once per report, after all detail and group sections are printed.

2 ddSTPageHeader A section that prints once at the top of each page in the report.

3 ddSTPageFooter A section that prints once at the bottom of each page in the report.

4 ddSTGroupHeader A section that prints once before detail sections whenever the group value or the group field value changes.

5 ddSTGroupFooter A section that prints once after detail sections whenever the group value or the group field value changes.

6 ddSTDetail A section that prints once for each record or detail line in the report.

Value Mnemonic Description

0 ddSHRectangle Rectangular shape.

1 ddSHEllipse Elliptical or circular shape.

2 ddSHRoundRectangle Rectangular shape with rounded corners.

Value Mnemonic Description

0 ddSMClip Displays the picture at its actual size. The picture is clipped (cut off) if it is larger than the controls defined area.

1 ddSMStretch Sizes the picture to fit the area of the control.

2 ddSMZoom Scales the image to either the height or width of the control to fit it within the specified area without distorting it.

Value Mnemonic Description

0 ddTopSplit Places the splitter on top

1 ddBottomSplit Places the splitter on the bottom

2 ddLeftSplit Places the splitter on the left

3 ddRightSplit Places the splitter on the right

ActiveReports 2.0 Standard User's Guide | 154

Page 155: 83791925 Active Report 2 0 Standard Edition

SummaryRunningType

SummaryType

TextAlignment

Value Mnemonic Description

0 ddSFSum Calculates the total of all values within the specified summary region (group, page report).

1 ddSFAvg Calculates the average of all values within the specified summary region (group, page or report).

2 ddSFCount Calculates the count of all values within the specified summary region (group, page or report).

3 ddSFMin Calculates the minimum of all values within the specified summary region (group, page or report).

4 ddSFMax Calculates the maximum of all values within the specified summary region (group, page or report).

5 ddSFVar Calculates the variance of all values within the specified summary region (group, page or report).

6 ddSFVarP Calculates the population variance of all values within the specified summary region (group, page or report).

7 ddSFStdDev Calculates the standard deviation of all values within the specified summary region (group, page or report).

8 ddSFStdDevP Calculates the population standard deviation of all values within the specified summary region (group, page or report).

9 ddSFDSum Calculates the total based on the distinct values of another field within the specified summary region (group, page or report).

10 ddSFDAvg Calculates the average based on the distinct values of another field within the specified summary region (group, page or report).

11 ddSFDCount Calculates the distinct count based on the distinct values of another field within the specified summary region (group, page or report).

12 ddSFDVar Calculates the variance based on the distinct values of another field within the specified summary region (group, page or report).

13 ddSFDVarP Calculates the population distinct variance based on the distinct values of another field within the specified summary region (group, page or report).

14 ddSFDStdDev Calculates the standard deviation based on the distinct values of another field within the specified summary region (group, page or report).

15 ddSFDStdDevP Calculates the population standard deviation based on the distinct values of another field within the specified summary region (group, page or report).

Value Mnemonic Description

0 ddSRNone Do not calculate a running summary.

1 ddSRGroup Calculates a running summary (each value is the sum of the current value and all preceding values) within the same group level.

2 ddSRAll Calculates a running summary for all values.

Value Mnemonic Description

0 ddSMNone No summarization.

1 ddSMGrandTotal Specifies a report level summary, evaluates the summary function for all records in the report.

2 ddSMPageTotal Specifies a page level summary, evaluates the summary function for all records on each page.

3 ddSMSubTotal Specifies a group level summary, evaluates the summary function for all records in each group level.

4 ddSMPageCount Specifies a Page Count field.

Value Mnemonic Description

0 ddTXLeft Aligns the text to the left edge of the object area.

ActiveReports 2.0 Standard User's Guide | 155

Page 156: 83791925 Active Report 2 0 Standard Edition

VerticalTextAlignment

ViewerStatus

ActiveReports' ArchitectureReport Sections

Report Processing

Events

Reports Passes

Printing Process

Report SectionsA 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:

1 ddTXRight Aligns the text to the right edge of the object area.

2 ddTXCenter Center the text horizontally within the object area.

Value Mnemonic Description

0 ddTXTop Aligns the text to the top of the object area.

1 ddTXMiddle Centers the text vertically within the object area.

2 ddTXBottom Align the text to the bottom of the object area.

Value Mnemonic Description

0 ddVStatusIdle Viewer has completed loading the pages into its cache.

1 ddVStatusReadingData Viewer is reading report pages into its cache.

ActiveReports' Architecture

Report Sections

ActiveReports 2.0 Standard User's Guide | 156

Page 157: 83791925 Active Report 2 0 Standard Edition

Report HeaderAn 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 FooterAn 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 HeaderAn 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 FooterAn 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 FooterAn 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 | 157

Page 158: 83791925 Active Report 2 0 Standard Edition

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

Report ProcessingActiveReports 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.

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

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

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

AfterPrintFired 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 PassesThe speed in processing and output generation of ActiveReports is attributed to its intelligent, multi-threaded, 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

Report Processing

Events

Reports Passes

ActiveReports 2.0 Standard User's Guide | 158

Page 159: 83791925 Active Report 2 0 Standard Edition

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 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, 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 PropertiesThese properties are shared with several objects in ActiveReports.

BackColor (Common Properties)DescriptionSets 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 TypeOLE_COLOR

Availability

Printing Process

Common Properties

Property Data Type Description

BackColor OLE_COLOR Sets or returns the background color of the object.

BackStyle BackStyle Sets or returns whether the control is rendered in transparent (opaque) or normal mode.

DataField String Sets or returns the database field a control will pull its data from.

Font stdFont Sets or returns the font settings for a control or canvas object.

ForeColor OLE_COLOR Sets or returns the foreground color for a control or the canvas object. Changing the foreground color will change the font color.

BackColor

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 159

Page 160: 83791925 Active Report 2 0 Standard Edition

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

BackStyle (Common Properties)DescriptionSets 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 TypeBackStyle

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

DataField (Common Properties)DescriptionSets 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

BackStyle

Design time Read / Write

Run time Read / Write

DataField

ActiveReports 2.0 Standard User's Guide | 160

Page 161: 83791925 Active Report 2 0 Standard Edition

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 TypeString

Availability

Example

Private Sub CreateReport()Dim ar As rptTemplate ' rptTemplate is a predefined report

' Template already has a data control named dcRptData' in the Detail SectionSet ar = New rptTemplateWith ar.Sections("Detail").Controls

' Add a field to reportSet ctl = .Add("DDActiveReports2.Field")' Set the new field's propertiesctl.Name = "CompanyName"ctl.Top = 0ctl.Left = 0ctl.Width = 1500ctl.Height = 285' Assign as DataSource and DataField to the fieldctl.DataSource = "dcRptdata"ctl.DataField = "CompanyName"' .. Set up the rest of the fields

End With' Preview the reportar.Show

End Sub

Font (Common Properties)DescriptionSets 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 TypestdFont

Availability

Example

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

Design time Read / Write

Run time Read / Write

Font

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 161

Page 162: 83791925 Active Report 2 0 Standard Edition

If txtSales.DataValue > 10000 ThentxtSales.Font.Bold = TruetxtSales.Font.Underline = True

ElsetxtSales.Font.Bold = FalsetxtSales.Font.Underline = False

End IfEnd Sub

ForeColor (Common Properties)DescriptionSets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data TypeOLE_COLOR

Availability

Example

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

End Sub

Common Methods

ZOrder (Common Methods)DescriptionThis 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 TypeNone

ForeColor

Design time Read / Write

Run time Read / Write

Common Methods

Method Description

ZOrder 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

ActiveReports 2.0 Standard User's Guide | 162

Page 163: 83791925 Active Report 2 0 Standard Edition

SyntaxSub Zorder(Position As Integer)

Parameters

Settings

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0txtEndNote.ZOrder 0txtDescription.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 descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.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

ActiveReportActiveReport Properties

ActiveReport Methods

ActiveReport Events

ActiveReport Properties

Name Type Description

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

1 Setting the ZOrder to 1 sends the control to the back.

ActiveReport

ActiveReport Properties

Property Data Type Description

AllowSplitter Boolean Sets or returns whether or not the print preview can be split into two windows.

Canvas Canvas The canvas property provides complete access to each page's drawing

ActiveReports 2.0 Standard User's Guide | 163

Page 164: 83791925 Active Report 2 0 Standard Edition

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 String 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 RptFields 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.

LayoutAction Integer 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.

MaxPages Long 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.

PageBorder Border 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.

PageNumber Long Returns the page number the report is currently on.

Pages Pages Collection Returns a reference to the pages collection, which contains the canvas objects for all printed pages.

Parameters ARParameters Returns a reference to the query parameters collection.

ParentReport Object Returns a reference to the subreport's parent report object. This allows the subreport to retrieve information from its parent.

Printer Printer Returns a reference to the printer object.

PrintWidth Single Sets or returns the report's printable width in twips (1440 twips = 1 inch).

RulerVisible Boolean Sets or returns whether or not the report's top and side rulers are shown during run-time.

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

Script String 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.

ScriptDebuggerEnabled Boolean Sets or returns whether or not the report will use an ActiveScript debugger to debug the script code.

ScriptLanguage String Sets or returns the scripting language ActiveReports will use to write and interpret the script properties.

ShowMessages Boolean Sets or returns whether or not alerts and error messages will be shown at runtime.

ShowParameterUI Boolean Sets or returns whether or not the query parameters dialog box will appear when the report is run.

Status ReportStatus Returns if the report is running, idle, completed or cancelled.

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

TOCEnabled Boolean Sets or returns whether or not the table of contents tree view is enabled when the report is shown.

TOCVisible Boolean Sets or returns whether or not the table of contents tree view is displayed in the viewer when the report is shown.

TOCWidth Single Sets or returns the table of contents tree width in twips (1440 twips = 1 inch).

ToolbarVisible Boolean Sets or returns whether or not the toolbar is displayed in the preview window.

UserData Variant Sets or returns users specified information.

Version String Returns the products version and build number.

WaterMark stdPicture Adds a specified image to the report's background. The watermark image can be positioned, sized, aligned and placed on specified pages by using

ActiveReports 2.0 Standard User's Guide | 164

Page 165: 83791925 Active Report 2 0 Standard Edition

AllowSplitter (ActiveReport)DescriptionSets 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 TypeBoolean

Availability

Example

Private Sub Form_Load()If mFlagEditor then

rptMain.AllowSplitter = TrueElse

rptMain.AllowSplitter=FalseEnd If

End Sub

CanvasDescriptionThe 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 TypeCanvas

Availability

Example

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

the other watermark properties.

WaterMarkAlignment PictureAlignment Sets or returns the watermark's general vertical and horizontal positions when it is added to the canvas.

WaterMarkPrintOnPages String Sets or returns a value indicating the specific pages the watermark should be added to.

WaterMarkSizeMode SizeMode Sets or returns how the watermark will be sized when the image is rendered on the canvas.

Zoom Integer Sets or returns the zoom factor for the displayed page.

AllowSplitter

Run time Read / Write

Canvas

Design time N/A

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 165

Page 166: 83791925 Active Report 2 0 Standard Edition

Private Sub PageHeader_Format()Dim lW As Long, lH As LongWith Canvas

.Font.Size = 48

.MeasureText "Confidential", lW, lH

.ForeColor = &HE0E0E0

.DrawText "Confidential", _(Me.PrintWidth - lW) / 2, _(Me.Printer.PaperHeight - lH) / 2, _5200, 2400

End WithEnd Sub

DocumentNameDescriptionSets 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 TypeString

Availability

Example

' Sets a clearly identifiable document name for easy ' identificationPrivate Sub ActiveReport_ReportStart()

Me.documentName = "TOL Annual Report Summary"End Sub

FieldsDescriptionFields 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

DocumentName

Design time Read / Write

Run time Read / Write

Fields

ActiveReports 2.0 Standard User's Guide | 166

Page 167: 83791925 Active Report 2 0 Standard Edition

rptField

Availability

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 hereFields.Add "OrderID"Fields.Add "ProductID"Fields.Add "ProductName"Fields.Add "Qty"Fields.Add "Price"Fields.Add "Amount"' iRow is the current record pointeriRow = 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 reportIf iRow > UBound(arr) Then Exit SubFields("OrderID").Value = arr(iRow).OrderNoFields("ProductID").Value = arr(iRow).ProductIDFields("ProductName").Value = arr(iRow).ProductNameFields("Qty").Value = arr(iRow).QtyFields("Price").Value = arr(iRow).PriceFields("Amount").Value = arr(iRow).AmountiRow = iRow + 1' We must set the eof parameter to True as' long as there is more data to be processedeof = False

End Sub

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

Design time N/A

Run time Read / Write

LayoutAction

Value Print Layout NextR Description

7 True True True (Default) Move to next print location, get next record, and print data.

3 True True False Move to the next print location, don't advance to the next record, but print the data.

4 False False True Skip a record without leaving a blank space on the page.

6 False True True Skip a record and leave a blank space on the page.

2 False True False Leave a blank space without skipping a record.

ActiveReports 2.0 Standard User's Guide | 167

Page 168: 83791925 Active Report 2 0 Standard Edition

Data TypeInteger

Settings

Availability

Example

Dim iSkipLabels As IntegerPrivate Sub Detail_Format()

' Skip 5 labelsIf iSkipLabels < 5 Then

LayoutAction = ddLAMoveLayoutEnd If

End Sub

MaxPagesDescriptionSets 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 TypeLong

Availability

ExamplerptSales.MaxPages = 10

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

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

Value Mnemonic Description

1 ddLAPrintSection Specifies whether a section should be printed

2 ddLAMoveLayout Specifies whether ActiveReports should move to the next printing location on the page

4 ddLANextRecord Specifies whether a section should advance to the next record

Design time Read / Write

Run time N/A

MaxPages

Design time Read / Write

Run time Read / Write

PageBorder

ActiveReports 2.0 Standard User's Guide | 168

Page 169: 83791925 Active Report 2 0 Standard Edition

Data TypeBorder

Availability

Example

' Set The PageBorder to Single Blue BorderPageBorder.BottomColor = vbBluePageBorder.LeftColor = vbBluePageBorder.RightColor = vbBluePageBorder.TopColor = vbBluePageBorder.BottomStyle = ddBLSolidPageBorder.LeftStyle = ddBLSolidPageBorder.RightStyle = ddBLSolidPageBorder.TopStyle = ddBLSolid

PageNumber (ActiveReport)DescriptionReturns 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 TypeLong

Availability

Example

Private Sub PageFooter_BeforePrint()' Print page number in the page footerfrmProgress.lblPage.Caption = me.PageNumber

End Sub

Pages (ActiveReport)DescriptionReturns 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.

Design time N/A

Run time Read / Write

PageNumber

Design time N/A

Run time Read

Pages

ActiveReports 2.0 Standard User's Guide | 169

Page 170: 83791925 Active Report 2 0 Standard Edition

Note: The Pages collection is zero based.

Data TypePages Collection

Availability

Example

Private Sub OverlayForm(cvFormLayout As Canvas)Dim cv As Canvas' Apply a preprinted canvas object tyo all pages' in the reportFor Each cv In Pages

cv.Overlay cvFormaLayoutNext

End Sub Private Sub PrintDuplex(ar As DDActiveReport)

Dim I As IntegerPrinter.StartJob' print all odd pages, pause, then print all even pagesFor I = 0 To Pages.Count – 1 Step 2

Printer.PrintPage Pages(I)Next Is = "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 ThenFor I = 1 To Pages.Count – 1 Step 2

Printer.PrintPage Pages(I)Next I

End IfPrinter.EndJob

End Sub

Parameters (ActiveReport)DescriptionReturns 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 TypeARParameters

Availability

Example

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

Design time N/A

Run time Read-Only

Parameters

Design time N/A

Run time Read-Only

ActiveReports 2.0 Standard User's Guide | 170

Page 171: 83791925 Active Report 2 0 Standard Edition

If Cancelled = True Then

Me.CancelExit Sub

End IfForm1.EventListBox.ClearFor i = 0 To Me.Parameters.Count - 1

Set myprop = New PropNodemyprop.Name = Me.Parameters(i).Keymyprop.Value = Me.Parameters(i).ValueForm1.EventListBox.Properties.Add myprop

NextEnd Sub

ParentReportDescriptionReturns 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 TypeObject

Availability

Example

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

End Sub

Printer (ActiveReport)DescriptionReturns 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 TypePrinter

Availability

ParentReport

Design time N/A

Run time Read-Only

Printer

Design time N/A

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 171

Page 172: 83791925 Active Report 2 0 Standard Edition

Example

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

End Sub

PrintWidthDescriptionSets 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 run-time, 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 TypeSingle

Default Value1440 twips = 1 inch

Availability

Example

Private Sub ActiveReport_ReportStart()' Set the report width to 6 inchesme.PrintWidth = 6 * 1440

End Sub

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

Data TypeBoolean

Availability

PrintWidth

Design time Read / Write

Run time Read / Write

RulerVisible

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 172

Page 173: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub cmdSetRuler_Click()If not bShowRuler Then

me.RulerVisible = FalseElse

me.RulerVisible = TrueEnd If

End Sub

Sections (ActiveReport)DescriptionSets 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 TypeSections collection

Availability

Example

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

Script (ActiveReport)DescriptionSets 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()

Sections

Design time N/A

Run time Read / Write

Script

ActiveReports 2.0 Standard User's Guide | 173

Page 174: 83791925 Active Report 2 0 Standard Edition

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 TypeString

Availability

Example

Private Sub Command1_Click()Dim vbScript As StringvbScript = "sub OnFormat" & vbCrLfvbScript = 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 = vbScriptActiveReport1.Show

End Sub

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

Design time Read / Write

Run time Read / Write

ScriptDebuggerEnabled

ActiveReports 2.0 Standard User's Guide | 174

Page 175: 83791925 Active Report 2 0 Standard Edition

Data TypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()Me.ScriptDebuggerEnabled = True

End Sub

ScriptLanguageDescriptionSets 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 TypeString

Availability

Example

Private Sub ActiveReport_ReportStart()If myScriptLang = "VB" then

Me.ScriptLanguage = "VBScript"Else

Me.ScriptLanguage = "JScript"EndIf

End Sub

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

DataTypeBoolean (Default = True)

Availability

Design time Read / Write

Run time Read / Write

ScriptLanguage

Design time Read / Write

Run time Read / Write

ShowMessages

ActiveReports 2.0 Standard User's Guide | 175

Page 176: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()Me.ShowMessages = False

End Sub

ShowParameterUIDescriptionSets 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 TypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()Me.ShowParameterUI = False

End Sub

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

Data TypeReportStatus

Settings

Availability

Design time N/A

Run time Read / Write

ShowParameterUI

Design time Read / Write

Run time Read / Write

Status

Value Mnemonic Description

0 ddStatIdle Indicates the report is idle

1 ddStatRunning Indicates the report is running

2 ddStatCompleted Indicates the report is completed

3 ddStatCancelled Indicates the report was cancelled

Design time N/A

Run time Read-Only

ActiveReports 2.0 Standard User's Guide | 176

Page 177: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub Timer1_Timer()Select Case ActiveReport1.Status

Case Is = 1frmMain.Caption = "Running..."

Case Is = 2frmMain.Caption = "Completed"Timer1.Enabled = False

End SelectEnd Sub

TOC (ActiveReport)DescriptionReturns 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 TypeTOC

Availability

Example

Private Sub ghCustomer_AfterPrint()TOC.Add txtCompanyName.Text

End Sub Private Sub Detail_AfterPrint()

TOC.Add txtCompanyName & "\" & txtOrderID.TextEnd Sub

TOCEnabled (ActiveReport)DescriptionSets 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 TypeBoolean

Availability

TOC

Design time N/A

Run time Read / Write

TOCEnabled

ActiveReports 2.0 Standard User's Guide | 177

Page 178: 83791925 Active Report 2 0 Standard Edition

Example' Disable the table of contents treerpt.TOCEnabled = False

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

Data TypeBoolean

Availability

Example

Private Sub btnViewReport_Click()Load rptInvoicerptInvoice.TOCVisible = TruerptInvoice.Show

End Sub

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

Data TypeSingle

Availability

Examplerpt.TOCWidth = 2880

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

Design time Read / Write

Run time Read / Write

TOCVisible

Design time Read / Write

Run time Read / Write

TOCWidth

Design time N/A

Run time Read / Write

ToolbarVisible

ActiveReports 2.0 Standard User's Guide | 178

Page 179: 83791925 Active Report 2 0 Standard Edition

Data TypeBoolean

Availability

Example

' Turn the toolbar off Load rptInvoicerptInvoice.ToolbarVisible = FalserptInvoice.Show

UserDataDescriptionSets 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 TypeVariant

Availability

ExampleActRpt1.UserData = "Annual Report Build 106"

Version (ActiveReport)DescriptionReturns the product's version number.

Data TypeString

Availability

Example

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

End Sub

Design time Read / Write

Run time Read / Write

UserData

Design time Read / Write

Run time Read / Write

Version

Design time Read

Run time Read

ActiveReports 2.0 Standard User's Guide | 179

Page 180: 83791925 Active Report 2 0 Standard Edition

WaterMarkDescriptionAdds 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 TypestdPicture

Availability

Example

Private Sub ActiveReport_ReportStart()Me.WatermarkAlignment = ddPATopRightMe.WatermarkPrintOnPages = "1,3,5,7,9"Me.WatermarkSizeMode = ddSMClipMe.Watermark = LoadPicture(App.Path & _

"\WaterMark.jpg")End Sub

WaterMarkAlignmentDescriptionSets 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 TypePictureAlignment

Settings

Availability

WaterMark

Design time Read / Write

Run time Read / Write

WaterMarkAlignment

Value Mnemonic Description

0 ddPATopLeft Aligns the image to the top and left.

1 ddPATopRight Aligns the image to the top and right.

2 ddPACenter (Default) Aligns the image to the center.

3 ddPABottomLeft Aligns the image to the bottom and left.

4 ddPABottomRight Aligns the image to the bottom and right.

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 180

Page 181: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()Me.WatermarkAlignment = ddPATopRightMe.WatermarkPrintOnPages = "1,3,5,7,9"Me.WatermarkSizeMode = ddSMClipMe.Watermark = LoadPicture(App.Path & _

"\WaterMark.jpg")End Sub

WaterMarkPrintOnPagesDescriptionSets 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 TypeString

Availability

Example

Private Sub ActiveReport_ReportStart()Me.WatermarkAlignment = ddPATopRightMe.WatermarkPrintOnPages = "1,3,5-7,9"Me.WatermarkSizeMode = ddSMClipMe.Watermark = LoadPicture(App.Path & _

"\WaterMark.jpg")End Sub

WaterMarkSizeModeDescriptionSets 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 TypeSizeMode

Settings

WaterMarkPrintOnPages

Design time Read / Write

Run time Read / Write

WaterMarkSizeMode

Value Mnemonic Description

0 ddSMClip (Default) Clips the image.

1 ddSMStretch Stretches the image to fill the print area.

ActiveReports 2.0 Standard User's Guide | 181

Page 182: 83791925 Active Report 2 0 Standard Edition

Availability

Example

Private Sub ActiveReport_ReportStart()Me.WatermarkAlignment = ddPATopRightMe.WatermarkPrintOnPages = "1,3,5,7,9"Me.WatermarkSizeMode = ddSMClipMe.Watermark = LoadPicture(App.Path & _

"\WaterMark.jpg")End Sub

Zoom (ActiveReport)DescriptionSets 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 TypeInteger

Availability

Example

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

ActiveReport Methods

2 ddSMZoom Zooms in on the image.

Design time Read / Write

Run time Read / Write

Zoom

Design time Read / Write

Run time Read / Write

ActiveReport Methods

Method Description

About 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 | 182

Page 183: 83791925 Active Report 2 0 Standard Edition

AboutDescriptionDisplays the product's information dialog box.

Return TypeNone

SyntaxSub About()

ParametersNone

Example

Private Sub ActiveReport_ReportStart()Me.About

End Sub

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()

Restart Resets the database connection properties and re-starts the report. Sub 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

AddCode

ActiveReports 2.0 Standard User's Guide | 183

Page 184: 83791925 Active Report 2 0 Standard Edition

AddCodeDescriptionAdds 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 TypeNone

SyntaxSub AddCode(script As String)

Parameters

Example

Private Sub AddSpecialScripts()Dim sScript As StringsScript = "Sub SetCnnString " & vbCrLfsScript = 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 OnDataInitializeSetCnnString

End Sub

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

Return TypeNone

SyntaxSub AddControlLicense(progID As String, licenseKey As String)

Parameters

Name Type Description

Script String An ActiveScript string expression containing the full code to be added.

AddControlLicense

Name Type Description

ProgID String String value indicating the full program ID for the added control

ActiveReports 2.0 Standard User's Guide | 184

Page 185: 83791925 Active Report 2 0 Standard Edition

Example

Dim rpt As ActiveReportPrivate Sub genRPT()

Dim ctl as ControlSet 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, sLicenseKeySet ctl = rpt.Sections(sSection).Controls.Add(sProgID)Set addLicensedControl = ctl

End Function

AddNamedItemDescriptionAdds 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 TypeNone

SyntaxSub AddNamedItem(Name As String,Value As Object)

Parameters

ExampleRptMain.addNamedItem "GetCos", new clsMath

In the Script Code

Sub OnReportStartmyCos = GetCos.ReturnCos

End Sub

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

LicenseKey String String value indicating the full LicenseKey for the added control

AddNamedItem

Name Type Description

Name String The name of the item being added

Value Object The value of the item being added

Cancel

ActiveReports 2.0 Standard User's Guide | 185

Page 186: 83791925 Active Report 2 0 Standard Edition

Return TypeNone

SyntaxSub Cancel()

ParametersNone

Example

' on a report progress form, place a cancel commandPrivate Sub btnCancel()

ar.CancelUnload ar

End Sub Private Sub ProcessReport()

Dim ar As rptInvoicesSet ar = New rptInvoicesar.PrintReport False' show the progress windowfrmProgress.Show

End Sub

ExportDescriptionExports the report pages collection using the specified export filter object.

See the separately included export filters documentation in your installation directory.

Return TypeNone

SyntaxSub Export(Export As Object)

Parameters

Example

Private Sub ExportToPDF()' You need to add the PDF Export Filter to your project' referencesDim oPDF As ARExportPDFSet oPDF = New ARExportPDFoPDF.FileName = App.Path & "\Invoice.PDF"rptInvoice.Export oPDF

End Sub

LoadLayout

Export

Name Type Description

Export Object A valid reference to an export filter object

LoadLayout

ActiveReports 2.0 Standard User's Guide | 186

Page 187: 83791925 Active Report 2 0 Standard Edition

DescriptionLoads 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 TypeNone

SyntaxSub LoadLayout(Data)

Parameters

Example

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

End Sub

Localize (ActiveReport)DescriptionLocalizes 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 TypeNone

SyntaxSub Localize(stringid text As String)

Parameters

Settings

Example

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

Name Type Description

Data Variant Value indicating either a path and file name or a byte array.

Localize

Name Type Description

stringid Integer Any of the valid index values.

text String New string to replace the caption at the specified index

Value Mnemonic Description

0 ddLViewerTOCHeader Changes the Table Of Contents header caption.

1 ddLTPageWidth Changes the "Page Width" caption in the zoom dropdown ComboBox.

2 ddLTWholePage Changes the "Whole Page" caption in the zoom dropdown ComboBox.

ActiveReports 2.0 Standard User's Guide | 187

Page 188: 83791925 Active Report 2 0 Standard Edition

ActiveReport1.Localize 2, "Whole Page"End Sub

PageSetupDescriptionDisplays 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 TypeBoolean

Syntax

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

Parameters

Settings

Example

Private Sub miFPageSetup()rpt.PageSetup

End Sub

PrintReport (ActiveReport)DescriptionAutomatically 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.

PageSetup

Name Type Description

hWndParent Long Optional - Parent window handle. The dialog will be centered within the window.

Flags Integer Optional – Dialogs flags as described in Settings. You can combine different flags using the Or operator.

Value Description

&H10 Disables the margin controls, preventing the user from setting the margins

&H20 Disables the Printer button, preventing the user from invoking a dialog box that contains additional printer setup

&H80 Prevents the system from displaying a warning message when there is no default printer.

&H100 Disables the orientation controls, preventing the user from setting the page orientation

&H200 Disables the paper controls, preventing the user from setting page parameters such as the paper size and source

&H200000 Hides and disables the Network button.

PrintReport

ActiveReports 2.0 Standard User's Guide | 188

Page 189: 83791925 Active Report 2 0 Standard Edition

Note: PrintReport will automatically run the report if it has not been run already.

Return TypeNone

SyntaxSub PrintReport(bDisplayDialog As Boolean)

Parameters

Example

Private Sub btnPrint()Load rptInvoicerptInvoice.dcRptData.RecordSource = _

"SELECT * FROM Invoices " & _"WHERE OrderID = " & Str(lSelectedOrder)

rptInvoice.PrintReport FalseUnload rptInvoice

End Sub

ResetScriptsDescriptionClears 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 TypeNone

SyntaxSub ClearNamedItems()

ExampleRptMain.ClearNamedItems

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

Return TypeNone

SyntaxSub Restart()

ParametersNone

Name Type Description

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

ResetScripts

Restart

ActiveReports 2.0 Standard User's Guide | 189

Page 190: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub cmdRunReport_Click()arMain.DataControl1.Source = "Select * from authors where au_id = "& i_IDarMain.RestartarMain.Show

End Sub

RunDescriptionExecutes 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 TypeNone

SyntaxSub Run(RunInBackground As Boolean)

Parameters

Example

Dim pdf As New PDFExportpdf.FileName = App.Path & "sales.pdf"rptSales.Run FalserptSales.Export pdf

SaveLayoutDescriptionSaves 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 TypeNone

SyntaxFunction SaveLayout(FileName As String, SerializeOptions As SaveOptionTypes)

Parameters

Run

Name Type Description

RunInBackground Boolean 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.

SaveLayout

ActiveReports 2.0 Standard User's Guide | 190

Page 191: 83791925 Active Report 2 0 Standard Edition

Settings

Example

Private Sub ActiveReport_ReportEnd()Me.SaveLayout app.path "\Mods\Account.RPX", ddSOXMLFormat

End Sub Private Sub ActiveReport_ReportEnd()

Dim brpt() as byteBrpt = me.SaveLayout("",ddSOByteArray)

End Sub

StopDescriptionStop 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 TypeNone

SyntaxSub Stop()

ParametersNone

Example

Private Sub PageFooter_AfterPrint()' We need to print only 10 PagesIf CurrentPage = 10 Then

' Stop the reportrptInvoice.Stop

End IfEnd Sub

ActiveReport Events

Name Type Description

FileName String String value indicating the path and filename for saving.

SerializeOptions SaveOptionTypes Indicates the format the report should be saved as.

Value Mnemonic Description

1 DdSOFile Save report layout to a file.

2 DdSOByteArray Save report layout to a byte array.

Stop

ActiveReport Events

Event Description

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

ActiveReports 2.0 Standard User's Guide | 191

Page 192: 83791925 Active Report 2 0 Standard Edition

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 | 192

Page 193: 83791925 Active Report 2 0 Standard Edition

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

SyntaxSub DataInitialize()

ParametersNone

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 pointeriRow = LBound(arr)

End Sub

Error (ActiveReport)DescriptionOccurs 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.

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

Parameters

Example

DataInitialize

Error

Name Description

Number An ActiveReports error number

Description Brief description of the error

SCode Subsystem error code

Source Source of the error

HelpFile Help file name and path

HelpContext Context number of the error help topic

CancelDisplay An action setting corresponding to the action you want to take

ActiveReports 2.0 Standard User's Guide | 193

Page 194: 83791925 Active Report 2 0 Standard Edition

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 IfCancelDisplay = True

End Sub

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

SyntaxSub FetchData(eof As Boolean)

Parameters

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 reportIf iRow > UBound(arr) Then Exit SubFields("OrderID") = arr(iRow).OrderNoFields("ProductID") = arr(iRow).ProductIDFields("ProductName") = arr(iRow).ProductNameFields("Qty") = arr(iRow).QtyFields("Price") = arr(iRow).PriceFields("Amount") = arr(iRow).AmountiRow = iRow + 1' We must set the eof parameter to False as' long as there is more data to be processedeof = False

End Sub

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

SyntaxSub ActiveReport_FindProgress(ByVal Result As DDActiveReports2.FindResults)

FetchData

Name Description

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

FindProgress

ActiveReports 2.0 Standard User's Guide | 194

Page 195: 83791925 Active Report 2 0 Standard Edition

Parameters

Settings

Example

Private Sub ActiveReport_FindProgress(ByVal Result As DDActiveReports2.FindResults)'If the end of the report is reached show a messageIf Result = ddFEndofPages Then

MsgBox "You have reached the end of the report."End If

End Sub

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

SyntaxSub hyperLink(ByVal Button As Integer, Link As String)

Parameters

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 (ActiveReport)DescriptionOccurs when the user presses a key while the viewer has focus.

Syntax

Name Type Description

Type FindResults An Enumerated list of possible progress results.

Value Mnemonic Description

1 ddFRFound The search found as instance of the string.

2 ddFREndofPages The search is at the end of the report.

3 ddFRBeginningofPages The search is at the beginning of the report.

HyperLink

Name Type Description

Button Integer Integer indicating the mouse button used to click on the hyperlink.

Link String String value indicating the hyperlink.

KeyDown

ActiveReports 2.0 Standard User's Guide | 195

Page 196: 83791925 Active Report 2 0 Standard Edition

Sub KeyDown(KeyCode As Integer, Shift As Integer)

Parameters

KeyPress (ActiveReport)DescriptionOccurs when the user presses and releases an ANSI key.

SyntaxSub KeyPress(KeyAscii As Integer)

Parameters

KeyUp (ActiveReport)DescriptionOccurs when the user releases a key while the viewer has focus.

SyntaxSub KeyUp(KeyCode As Integer, Shift As Integer)

Parameters

MouseOver (ActiveReport)DescriptionThis 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.

SyntaxSub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal hyperLink As String)

Parameters

Name Type Description

KeyCode Integer The pressed Key Code from VB object library

Shift Integer An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2).

KeyPress

Name Type Description

KeyAscii Integer The standard numeric ANSI code of the pressed key.

KeyUp

Name Type Description

KeyCode Integer The released Key Code from VB object library

Shift Integer An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2).

MouseOver

Name Type Description

PageX Long Value of the X coordinate for the mouse

PageY Long Value of the Y coordinate for the mouse

ActiveReports 2.0 Standard User's Guide | 196

Page 197: 83791925 Active Report 2 0 Standard Edition

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' captionMe.Caption = "Annual Report: Fall Quarter"

End If End Sub

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

SyntaxSub NoData()

Example

Private Sub ActiveReport_NoData()Dim sMsg As StringsMsg = "Report has no data, " & _"click Cancel to abort, " & _"OK to print without data"If MsgBox(sMsg, vbOKCancel, "No Data") = vbCancel Then

rptInvoice.CancelEnd If

End Sub

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

SyntaxSub PageEnd()

Example

Private Sub ActiveReport_PageEnd()' Update the total number of pages

HyperLink String String value for the hyperlink

NoData

PageEnd

ActiveReports 2.0 Standard User's Guide | 197

Page 198: 83791925 Active Report 2 0 Standard Edition

iTotalPages = iTotalPages + 1End Sub

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

SyntaxSub PageStart()

Example

Private Sub ActiveReport_PageStart()' Reset the page totallPageTotal = 0

End Sub

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

SyntaxSub PrintAborted()

Example

Private Sub ActiveReport_PrintAborted()bPrintFlag = False

End Sub

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

SyntaxSub PrintProgress(PageNumber As Long)

Parameters

Example

PageStart

PrintAborted

PrintProgress

Name Description

PageNumber The current page number being printed.

ActiveReports 2.0 Standard User's Guide | 198

Page 199: 83791925 Active Report 2 0 Standard Edition

' in your progress dialog formPublic bCancelled As Boolean Private Sub btnCancel_Click()

bCancelled = TrueEnd Sub ' In the report PrintProgress EventPrivate Sub ActiveReport_PrintProgress(PageNumber As Long)

frmProgress.lblCurrPage.Caption = Str(PageNumber)If bCancelled Then rpt.Cancel

End Sub

PromptDialogClosedDescriptionFired after parameter values for a query are entered or the parameters dialog is cancelled.

SyntaxSub PromptDialogClosed(ByVal Cancelled As Boolean)

Parameters

Example

Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean)Dim i As IntegerIf Cancelled = True Then

Me.CancelExit Sub

End If 'If date parameter is empty set the default dateIf Me.Parameters(0).Value = "" Then

Me.Parameters(0).Value = "1/1/95"End If

'if orderID parameter is empty set the default to zeroIf Me.Parameters(1).Value = "" Then

Me.Parameters(1).Value = "0"End If

End Sub

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

SyntaxSub ReportEnd()

Example

PromptDialogClosed

Name Type Description

Cancelled Boolean Returns true if the parameters dialog is cancelled.

ReportEnd

ActiveReports 2.0 Standard User's Guide | 199

Page 200: 83791925 Active Report 2 0 Standard Edition

' When Report is completed, close all open recordsets.Private Sub ActiveReport_ReportEnd()

rsInvoices.CloseSet rsInvoices = Nothing

End Sub

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

SyntaxSub ReportStart()

Example

Private Sub ActiveReport_ReportStart()' Open the recordset for unbound reportSet rs = db.OpenRecordset("SELECT * FROM Invoices")

End Sub

TOCClickDescriptionThis event is fired when mouse is clicked inside the table of contents area.

SyntaxSub TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long)

Parameters

Settings

ReportStart

TOCClick

Name Type Description

Button Integer 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.

ItemIndex Long The index of the TOC entry item that was selected.

Flags Long Holds information about the mouse click hit test. See settings for a description of the bit values.

Value Mnemonic Description

&H1 ddHT_NOWHERE In the TOC client area, but below the last item.

&H2 ddHT_ONITEMICON On the bitmap associated with an item.

&H4 ddHT_ONITEMLABEL On the label (caption) associated with an item.

&H8 ddHT_ONITEMINDENT In the indentation associated with an item.

&H10 ddHT_ONITEMBUTTON On the button associated with an item.

&H20 ddHT_ONITEMRIGHT In the area to the right of an item

TOCSelChange

ActiveReports 2.0 Standard User's Guide | 200

Page 201: 83791925 Active Report 2 0 Standard Edition

TOCSelChange (ActiveReport)DescriptionFired when the TOC selection changes.

SyntaxSub TOCSelChange (ByVal ItemIndex As Long)

Parameters

ToolbarClick (ActiveReport)DescriptionFired when the user clicks on one of the preview window tools.

SyntaxSub ToolbarClick(ByVal Tool As DDTool)

Parameters

Example

Private Sub ActiveReport_ToolbarClick(ByVal tool As _DDActiveReports2.DDTool)If tool.Caption = "Printer Setup" Then

rpt.Printer.SetupDialogEnd If

End Sub

ARViewer ControlARViewer Properties

ARViewer Methods

ARViewer Events

ARViewer Properties

Name Type Description

ItemIndex Long The index of the TOC entry item that was selected.

ToolbarClick

Name Type Description

Tool DDTool A reference to the tool object that specified the clicked tool.

ARViewer Control

ARViewer Properties

Property Data Type Description

AllowSplitter Boolean Sets or returns whether or not the viewer can be split into two windows.

BackColor OLE_COLOR Sets or returns the background color of the

ActiveReports 2.0 Standard User's Guide | 201

Page 202: 83791925 Active Report 2 0 Standard Edition

AllowSplitter (ARViewer)DescriptionSets 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 TypeBoolean

Availability

Example

Private Sub Form_Load()If mFlagEditor then

ARViewer21.AllowSplitter = TrueElse

ARViewer21.AllowSplitter=FalseEnd If

End Sub

viewer.

BorderStyle BorderStyle Sets or returns the border style.

DataPath String Report file (RDF) URL for asynchronous downloads.

Object Object Returns an object in a collection

Pages Pages collection Returns a reference to the current pages collection displayed in the viewer.

PaperColor OLE_COLOR Sets or returns the paper background color.

Printer Printer Returns a reference to the viewer's printer object.

ReportSource Object Sets or returns a reference to the linked subreport.

RulerVisible Boolean Sets or returns whether or not the viewer's top and side rulers are shown at run-time.

Status ViewerStatus Returns the status of loading pages into the viewer cache.

TOC TOC Returns a reference to the table of contents object,

TOCEnabled Boolean Disables or enables the TOC tree.

TOCVisible Boolean Determines whether the table of contents tree is visible.

TOCWidth Single Sets or returns the width of the TOC tree when displayed.

Toolbar DDToolbar Returns a reference to the built-in toolbar object,

ToolbarVisible Boolean Determines whether the built-in toolbar is visible.

UseSourcePrinter Boolean Sets/return whether the viewer or ReportSource printer is used to print the report.

Zoom Integer Sets or returns the zoom level of the current page view.

AllowSplitter

Run time Read / Write

BackColor

ActiveReports 2.0 Standard User's Guide | 202

Page 203: 83791925 Active Report 2 0 Standard Edition

BackColor (ARViewer)DescriptionSets or returns the background color of the viewer control.

Data TypeOLE_COLOR

Availability

BorderStyleDescriptionSets or returns the viewer control's border style.

Data TypeInteger

Settings

Availability

DataPathDescriptionSets or returns the report file (RDF) URL to download and view in an HTML page.

Data TypeString (URL)

Availability

Example

<script LANGUAGE="VBScript"><!--Sub window_onload()

' set the initial reportsource data path

Design time Read / Write

Run time Read / Write

BorderStyle

Value Mnemonic Description

0 ddBSNone No border is displayed

1 ddBSFixedSingle Displays single pixel border around control

Design time Read / Write

Run time Read / Write

DataPath

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 203

Page 204: 83791925 Active Report 2 0 Standard Edition

arv.DataPath="reports/catalog.rdf"End Sub Sub cboReport_OnChange()

Select case cboReport.ValueCase "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 (ARViewer)DescriptionReturns an object in a collection.

Data TypeObject

Availability

Pages (ARViewer)DescriptionReturns a reference to the pages displayed in the viewer.Note: The pages collection is zero based.

Data TypePages Collection

Availability

Example

Object

Run time Read-Only

Pages

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 204

Page 205: 83791925 Active Report 2 0 Standard Edition

' Run two or more reports and display both in the viewer by inserting their pages' into the viewer's pages collectionDim pg As CanvasReport1.Run FalseReport2.Run FalseFor Each pg In Report1.Pages

ARViewer1.Pages.Insert ARViewer1.Pages.Count, pgNextFor Each pg In Report2.Pages

ARViwer.Pages.Insert ARViewer1.Pages.Count, pgNext

PaperColorDescriptionSets or returns the background color of the paper in the viewer window.

Data TypeOLE_COLOR

Availability

Example

Private Sub btnViewReport_Click()Load frmRptViewer' Change the Paper Color from White to GreyfrmRptViewer.arv.PaperColor = &HC0C0C0' Set the Table of Contents Tree to VisiblefrmRptViewer.arv.TOCVisible = TruefrmRptViewer.arv.ToolBar.Tools.Add "Printer Setup"frmRptViewer.Show

End Sub

Printer (ARViewer)DescriptionReturns a reference to the viewer's printer object. You can use this property to set or modify printer settings at run time.

Data TypePrinter

Availability

Example

' Set the number of copies to printPrinter.Copies = 2

PaperColor

Design time Read / Write

Run time Read / Write

Printer

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 205

Page 206: 83791925 Active Report 2 0 Standard Edition

ReportSourceDescriptionSets 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 TypeObject

Availability

Example

Private Sub cmdOpenReport_Click()ARViewer1.ReportSource = New rptCustomerInfo

End Sub

RulerVisible (ARViewer)DescriptionSets or returns whether or not the viewer's top and side rulers are shown at run time.

Data TypeBoolean

Availability

Example

Private Sub cmdSetRuler_Click()If ARViewer1.RulerVisible Then

cmdSetRuler.Caption = "&Show Ruler"ARViewer1.RulerVisible = False

ElsecmdSetRuler.Caption = "&Hide Ruler"ARViewer1.RulerVisible = True

End IfEnd Sub

Status (ARViewer)DescriptionReturns 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.

ReportSource

Run time Read / Write

RulerVisible

Design time Read / Write

Run time Read / Write

Status

ActiveReports 2.0 Standard User's Guide | 206

Page 207: 83791925 Active Report 2 0 Standard Edition

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 TypeViewerStatus

Availability

TOC (ARViewer)DescriptionReturns 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 TypeTOC

Availability

Example

' Command button implementations of a custom toolbarPrivate Sub btnBack()

With arv.TOC.History.BackbtnBack.Enabled = (.Position = 0)btnForward.Enabled = (.Position = .Count)

End WithEnd Sub Private Sub btnForward()

With arv.TOC.History.ForwardbtnBack.Enabled = (.Position = 0)btnForward.Enabled = (.Position = .Count)

End WithEnd Sub

TOCEnabled (ARViewer)

Design time N/A

Run time Read

TOC

Design time N/A

Run time Read / Write

TOCEnabled

ActiveReports 2.0 Standard User's Guide | 207

Page 208: 83791925 Active Report 2 0 Standard Edition

DescriptionEnables or disables the table of contents tree.

Data TypeBoolean

Availability

Example

' Disable the table of contents treearv.TOCEnabled = False

TOCVisible (ARViewer)DescriptionDetermines whether the viewer's toolbar is displayed in the viewer window.

Data TypeBoolean

Availability

Example

Private Sub btnViewReport_Click()Load frmRptViewerfrmRptViewer.arv.TOCVisible = TruefrmRptViewer.arv.ToolBar.Tools.Add "Printer Setup"frmRptViewer.Show

End Sub

TOCWidth (ARViewer)DescriptionSets or returns the width of the table of contents tree in twips.

Data TypeSingle

Availability

Design time Read / Write

Run time Read / Write

TOCVisible

Design time Read / Write

Run time Read / Write

TOCWidth

Design time N/A

ActiveReports 2.0 Standard User's Guide | 208

Page 209: 83791925 Active Report 2 0 Standard Edition

Examplearv.TOCWidth = 2880

ToolbarDescriptionReturns a reference to the viewer's toolbar object. The toolbar object allows you modify the toolbar's icons and tools.

Data TypeToolbar

Availability

Example

Private Sub btnViewReport_Click()Load frmRptViewerfrmRptViewer.arv.TOCVisible = TruefrmRptViewer.arv.ToolBar.Tools.Add "Printer Setup"frmRptViewer.Show

End Sub

ToolbarVisible (ARViewer)DescriptionDetermines whether the viewer's toolbar is displayed in the viewer window.

Data TypeBoolean

Availability

Example

' Turn the toolbar off and use our own custom toolbarLoad frmViewerfrmViewer.arv.ToolbarVisible = False

UseSourcePrinter

Run time Read / Write

ToolBar

Run time Read

ToolbarVisible

Design time Read / Write

Run time Read / Write

UseSourcePrinter

ActiveReports 2.0 Standard User's Guide | 209

Page 210: 83791925 Active Report 2 0 Standard Edition

DescriptionSets or returns whether the viewer's printer (False) or ReportSource printer (True) is used to print the report.

Data TypeBoolean

Availability

Zoom (ARViewer)DescriptionSets or returns the zoom factor of the displayed page.

Data TypeInteger - Valid range is 10-800 or -1 for Fit PageWidth and -2 for Fit Whole Page.

Availability

Example

' Load the viewer form and set the zoom to 75%frmViewer.ShowfrmViewer.arv.Zoom = 75

ARViewer Methods

Design time Read / Write

Run time Read / Write

Zoom

Design time Read / Write

Run time Read / Write

ARViewer Methods

Method Description

CopyPageToClipboard 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 | 210

Page 211: 83791925 Active Report 2 0 Standard Edition

CopyPageToClipboardDescriptionCopies 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 TypeNone

SyntaxSub CopyPageToClipboard([Page])

Parameters

Example

Private Sub cmdCopy_Click()ARV.CopyPageToClipboard 0 'Copies the first page

End Sub

Find (ARViewer)DescriptionSearches the report for a specified string.

Return TypeNone

SyntaxSub Find(View As SplitViewTypes, SearchText As String, DirectionAs SearchDirectionTypes, MatchCase As Boolean, MatchWord As Boolean)

Parameters

Sub Refresh()

SinglePage Switches the viewer back to displaying a single page. Sub SinglePage(View As SplitViewTypes)

CopyPageToClipboard

Name Type Description

Page (optional) Integer Copies the current page to the clipboard, unless a different page is specified.

Find

Name Type Description

View SplitViewTypes Determines which split window (top, bottom, or both) to search.

SearchText String The string value being searched for.

Direction SearchDirectionTypes The direction, either up or down, the search will use to scan the report.

MatchCase Boolean Determines whether the search is case sensitive or not.

ActiveReports 2.0 Standard User's Guide | 211

Page 212: 83791925 Active Report 2 0 Standard Edition

SettingsSplitViewTypes

SearchDirectionTypes

Example

Private Sub cmdSearch_Click()ARV.Find ddSVFirst, txtSrch.Text, ddSDDown, False, True

End Sub

Localize (ARViewer)DescriptionAllows 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 TypeNone

SyntaxSub Localize(Type As LocalizeTypes, text As String)

Parameters

Settings

Example

Private Sub Form_Load()

MatchWord Boolean Determines whether the search should find only the whole word or not.

Value Mnemonic Description

0 ddSVFirst Only searches the top window if the viewer is split, or the single window if it is not.

1 ddSVSecond Only searches the bottom window if the viewer is split, or the single window if it is not.

2 ddSVAll Searches both windows if the viewer is split, or the single window if it is not.

Value Mnemonic Description

0 ddSDUp Searches from the current page to page 1.

1 ddSDDown Searches from the current page to the end.

Localize

Name Type Description

Type LocalizeTypes Any of the valid LocalizeType enums.

text String New string to replace the caption at the specified index.

Value Mnemonic Description

0 ddLViewerTOCHeader Changes the Table Of Contents header caption.

1 ddLTPageWidth Changes the "Page Width" caption in the zoom dropdown ComboBox.

2 ddLTWholePage Changes the "Whole Page" caption in the zoom dropdown ComboBox.

ActiveReports 2.0 Standard User's Guide | 212

Page 213: 83791925 Active Report 2 0 Standard Edition

'Change "Page Width" captionarv.Localize ddLTPageWidth, "Largura Da Página "'Change TOC Header captionarv.Localize ddLTViewerTocHeader, "Índice "'Change "Whole Page" captionarv.Localize ddLTWholePage, "Página Inteira "

End Sub

MultiplePageDescriptionSwitches the viewer settings so multiple pages can be displayed at one time.

Return TypeNone

SyntaxSub MultiplePage(View As SplitViewTypes, rows As Integer, cols As Integer)

Parameters

Settings

PrintReport (ARViewer)DescriptionPrints the viewer pages collection to the selected device.

Return TypeNone

SyntaxSub PrintReport(bDisplayDialog As Boolean)

Parameters

MultiplePage

Name Type Description

View SplitViewTypes Determines which split window (top, bottom, or both) to apply the setting to.

rows Integer Indicates how many rows (horizontal) of pages should be shown.

cols Integer Indicates how many columns (vertical) of pages should be shown.

Value Mnemonic Description

0 ddSVFirst Applies the MultiplePage setting to the top window if the viewer is split, or to the single window if it is not.

1 ddSVSecond Applies the MultiplePage setting to the bottom window if the viewer is split, or to the single window if it is not.

2 ddSVAll Applies the MultiplePage setting to both windows if the viewer is split, or to the single window if it is not.

PrintReport

Name Type Description

bDisplayDialog Boolean Specifies whether ActiveReports should display the

ActiveReports 2.0 Standard User's Guide | 213

Page 214: 83791925 Active Report 2 0 Standard Edition

Example

' Menu Item PrintPrivate Sub miFPrint_Click()

ARViewer1.PrintReport FalseEnd Sub

Refresh (ARViewer)DescriptionForces the viewer control to repaint itself.

Return TypeNone

SyntaxSub Refesh()

ParametersNone

Examplearv.Refresh

SinglePageDescriptionSwitches the Viewer back to displaying a single page.

Return TypeNone

SyntaxSub SinglePage(View As SplitViewTypes)

Parameters

Settings

print dialog before printing the report.

Refresh

SinglePage

Name Type Description

View SplitViewTypes Determines which split window (top, bottom, or both) to apply the setting to.

Value Mnemonic Description

0 ddSVFirst Applies the SinglePage setting to the top window of the viewer is split, or the single window if it is not.

1 ddSVSecond Applies the SinglePage setting to the bottom window of the viewer is split, or the single window if it is not.

2 ddSVAll 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 | 214

Page 215: 83791925 Active Report 2 0 Standard Edition

ARViewer Events

ARViewer Events

Event Description

ControlLoaded (on-line documentation)

Used for setting the DataPath in Microsoft Internet Explorer Sub ControlLoaded()

DblClick 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)

DragOver (on-line documentation)

Fired when a drag-and-drop operation is in progress. Sub DragOver(Source As Control, x As Single, y As Single, State As Integer)

Error 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)

This event fires when an object receives focus. Sub GotFocus()

HyperLink 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)

Fired when an object loses focus. Sub LostFocus()

MouseDown Fired when a mouse button is pressed down. Sub MouseDown(Button As Integer, Shift As Integer, XAs Single,Y As Single)

MouseMove Fired as the mouse moves over the viewer area. Sub MouseMove(Button As Integer, Shift As Integer, XAs 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.

ActiveReports 2.0 Standard User's Guide | 215

Page 216: 83791925 Active Report 2 0 Standard Edition

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.

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

SyntaxSub DblClick()

ParametersNone

Error (ARViewer)DescriptionOccurs 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.

SyntaxSub 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

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)

Fired when a control loses focus to a control that causes validation. Sub Validate(Cancel As Boolean)

ZoomChanged Fired when the viewer's zoom percentage changes. Sub ZoomChanged()

DblClk

Error

ActiveReports 2.0 Standard User's Guide | 216

Page 217: 83791925 Active Report 2 0 Standard Edition

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 = TrueApp.LogEvent "Error Number: " & str(Number) & " " & _

Description & " Source: " & Source End Sub

FindProgress (ARViewer)DescriptionThis 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.

SyntaxSub arv_FindProgress(ByVal Results As DactiveReportsViewer2Ctl.FindResults)

Parameters

Settings

Example

Private Sub arv_FindProgress(ByVal Result As DDActiveReportsViewer2Ctl.FindResults)'If the end of the report is reached show a messageIf Result = ddFRNotFount Then

MsgBox "No Matching Records"End If

End Sub

Name Description

Number An ActiveReports error number.

Description Brief description of the error.

SCode Subsystem error code

Source Source of the error

HelpFile Help file name and path

HelpContext Context number of the error help topic

CancelDisplay An action setting corresponding to the action you want to take.

FindProgress

Name Type Description

Type FindResults An Enumerated list of possible progress results.

Value Mnemonic Description

1 ddFRFound The search found as instance of the string.

2 ddFREndofPages The search is at the end of the report.

3 ddFRBeginningofPages The search is at the beginning of the report.

ActiveReports 2.0 Standard User's Guide | 217

Page 218: 83791925 Active Report 2 0 Standard Edition

hyperLink (ARViewer)DescriptionThis event fires when a hyperlink is clicked. The event can be used to redirect the hyperlink or prevent the link from activating.

SyntaxSub hyperLink(ByVal Button As Integer, Link As String)

Parameters

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 (ARViewer)DescriptionOccurs when the user presses a key while the viewer has focus.

SyntaxSub KeyDown(KeyCode As Integer, Shift As Integer)

Parameters

KeyPress (ARViewer)DescriptionOccurs when the user presses and releases an ANSI key.

SyntaxSub KeyPress(KeyAscii As Integer)

hyperLink

Name Type Description

Button Integer Integer indicating the mouse button used to click on the hyperlink.

Link String String value indicating the hyperlink.

KeyDown

Name Type Description

KeyCode Integer The pressed Key Code from VB object library

Shift Integer An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2).

KeyPress

ActiveReports 2.0 Standard User's Guide | 218

Page 219: 83791925 Active Report 2 0 Standard Edition

Parameters

KeyUp (ARViewer)DescriptionOccurs when the user releases a key while the viewer has focus.

SyntaxSub KeyUp(KeyCode As Integer, Shift As Integer)

Parameters

LoadCompletedDescriptionLoadCompleted is fired when all the pages from the ReportSource are loaded into the viewer control.

SyntaxSub LoadCompleted()

ParametersNone

Example

' Update a PageCount label and enable the TOC button' when all pages are loadedPrivate Sub LoadCompleted()

lblPages.Caption = Str(arv.Pages.Count)arv.TOCEnabled = True

End Sub

MouseDownDescriptionFired when the user presses one of the mouse buttons in the viewer area.

SyntaxSub MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Parameters

Name Type Description

KeyAscii Integer The standard numeric ANSI code of the pressed key.

KeyUp

Name Type Description

KeyCode Integer The released Key Code from VB object library

Shift Integer An integer that specified the state of the shift keys SHIFT (bit 0), ALT (bit 1)and CTRL (bit 2).

LoadCompleted

MouseDown

ActiveReports 2.0 Standard User's Guide | 219

Page 220: 83791925 Active Report 2 0 Standard Edition

MouseMoveDescriptionOccurs when the user moves the mouse over the viewer control area.

SyntaxSub MouseMove( Button As Integer, Shift As Integer, X As Single, Y As Single)

Parameters

MouseOver (ARViewer)DescriptionThis 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.

SyntaxSub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal hyperLinkAs String)

Parameters

Example

Private Sub ActiveReport_MouseOver(ByVal PageX As Long, _ ByVal PageY As Long, ByVal hyperLink As String)

Name Type Description

Button Integer 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.

Shift Integer 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.

X,Y Single The mouse coordinates (in pixels) within the viewer control area.

MouseMove

Name Type Description

Button Integer 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.

Shift Integer 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.

X,Y Single The mouse coordinates (in pixels) within the viewer control area.

MouseOver

Name Type Description

PageX Long Value of the X coordinate for the mouse

PageY Long Value of the Y coordinate for the mouse

HyperLink String String value for the hyperlink

ActiveReports 2.0 Standard User's Guide | 220

Page 221: 83791925 Active Report 2 0 Standard Edition

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 ' captionarv1.Caption = "Annual Report: Fall Quarter"

End If End Sub

MouseUpDescriptionFired when the user releases the pressed mouse button in the viewer area.

SyntaxSub MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Parameters

PageModeChangedDescriptionFired when the viewer switches between displaying a single page and multiple pages.

SyntaxSub PageModeChanged(ByVal MultiplePage As Boolean)

Parameters

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

MouseUp

Name Type Description

Button Integer 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.

Shift Integer 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.

X,Y Single The mouse coordinates (in pixels) within the viewer control area.

PageModeChanged

Name Type Description

MultiplePage Boolean Returns true if the viewer's page mode switches to displaying multiple pages and false if the viewer only displays a single page.

PrintAborted

ActiveReports 2.0 Standard User's Guide | 221

Page 222: 83791925 Active Report 2 0 Standard Edition

SyntaxSub PrintAborted()

Example

Private Sub ARViewer21_PrintAborted()bPrintFlag = False

End Sub

TOCClickDescriptionThis event is fired when mouse is clicked inside the table of contents area.

SyntaxSub TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal FlagsAs Long)

Parameters

Settings

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 (ARViewer)DescriptionFired when the TOC selection changes.

SyntaxSub TOCSelChange (ByVal ItemIndex As Long)

Parameters

TOCClick

Name Type Description

Button Integer 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.

ItemIndex Long The index of the TOC entry item that was selected.

Flags Long Holds information about the mouse click hit test. See settings for a description of the bit values.

Value Mnemonic Description

&H1 ddHT_NOWHERE In the TOC client area, but below the last item.

&H2 ddHT_ONITEMICON On the bitmap associated with an item.

&H4 ddHT_ONITEMLABEL On the label (caption) associated with an item.

&H8 ddHT_ONITEMINDENT In the indentation associated with an item.

&H10 ddHT_ONITEMBUTTON On the button associated with an item.

&H20 ddHT_ONITEMRIGHT In the area to the right of an item

TOCSelChange

ActiveReports 2.0 Standard User's Guide | 222

Page 223: 83791925 Active Report 2 0 Standard Edition

ToolbarClick (ARViewer)DescriptionFired when the user clicks on one of the viewer's toolbar tools.

SyntaxSub ToolbarClick(ByVal Tool As DDTool)

Parameters

Example

Private Sub arv_ToolbarClick(ByVal tool As _DDActiveReportsViewer2Ctl.DDTool)If tool.Caption = "Printer Setup" Then

arv.Printer.SetupDialogEnd 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.

ZoomChangedDescriptionFired when the viewer's zoom percentage changes.

SyntaxSub ZoomChanged()

Border Properties

Name Type Description

ItemIndex Long The index of the TOC entry item that was selected.

ToolbarClick

Name Type Description

Tool DDTool A reference to the tool object that specified the clicked tool.

ZoomChanged

Border Properties

Property Data Type Description

BottomColor OLE_COLOR The line color of the bottom edge.

BottomStyle BorderLineStyle The line style of the bottom edge.

LeftColor OLE_COLOR The line color of the left edge.

LeftStyle BorderLineStyle The line style of the left edge.

RightColor> OLE_COLOR The line color of the right edge.

RightStyle BorderLineStyle The line style of the right edge.

ActiveReports 2.0 Standard User's Guide | 223

Page 224: 83791925 Active Report 2 0 Standard Edition

BottomColor, LeftColor, RightColor, TopColorDescriptionSets or returns the color of the line drawn at the specified edge.

Data TypeOLE_COLOR

Availability

Example

' Set The PageBorder to Single Blue BorderPageBorder.BottomColor = vbBluePageBorder.LeftColor = vbBluePageBorder.RightColor = vbBluePageBorder.TopColor = vbBluePageBorder.BottomStyle = ddBLSolidPageBorder.LeftStyle = ddBLSolidPageBorder.RightStyle = ddBLSolidPageBorder.TopStyle = ddBLSolid

BottomStyle, LeftStyle, RightStyle, TopStyleDescriptionSets or returns the line style at the specified edge.

Data TypeBorderLineStyle

Availability

Example

' Set The PageBorder to Single Blue BorderPageBorder.BottomColor = vbBluePageBorder.LeftColor = vbBluePageBorder.RightColor = vbBluePageBorder.TopColor = vbBluePageBorder.BottomStyle = ddBLSolidPageBorder.LeftStyle = ddBLSolid

Shadow Boolean Determines whether to draw a shadow around the control or not.

TopColor OLE_COLOR The line color of the top edge.

TopStyle BorderLineStyle The line style of the top edge.

BottomColor, LeftColor, RightColor, TopColor

Design time Read / Write (Borders Property Sheet)

Run time Read / Write

BottomStyle, LeftStyle, RightStyle, TopStyle

Design time Read / Write (Borders Property Sheet)

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 224

Page 225: 83791925 Active Report 2 0 Standard Edition

PageBorder.RightStyle = ddBLSolidPageBorder.TopStyle = ddBLSolid

ShadowDescriptionDetermines whether to draw a shadow around the control.

Data TypeBoolean

Availability

Example

Private Sub Detail_Format()If txtSlaes.Datavalue > 10000 Then

txtCompanyName.Border.Shadow = TrueEnd If

End Sub

Canvas ObjectCanvas Properties

Canvas Methods

Canvas Properties

Shadow

Design time Read / Write (Borders Property Sheet)

Run time Read / Write

Canvas

Canvas Properties

Property Data Type Description

Alignment Integer Controls how the DrawText method aligns the text.

BackColor OLE_COLOR Sets the background color of the following non-transparent (BackStyle = 1) output.

BackStyle BackStyle Sets the BackStyle to either transparent or solid fill.

Font StdFont Sets the font of the following DrawText output.

ForeColor OLE_COLOR Sets the foreground color of the following output,

Height Long Sets or returns the vertical drawing area for the canvas.

Orientation PrtOrientation Sets the page orientation of the canvas.

PenStyle Integer Sets the drawing pen style

PenWidth Integer Sets the drawing pen width

Tag Variant Sets or returns a user defined value associated with the page.

TextAngle Long Sets the angle of the text printed using the DrawText method.

ActiveReports 2.0 Standard User's Guide | 225

Page 226: 83791925 Active Report 2 0 Standard Edition

Alignment (Canvas)DescriptionSets or returns the horizontal alignment of the text drawn using DrawText method.

Data TypeInteger

Settings

Availability

Example

Private Sub PageHeader_Format()<' Draw a round rectangle with Top Secret centeredWith Canvas

.DrawRoundRect 100, 100, 1500, 300, 10, 10

.Alignment = ddTXCenter

.DrawText "Top Secret", 100, 100, 1500, 300End With

End Sub

BackColor (Canvas)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

VerticalAlignment Integer Sets the vertical alignment of the text printed using the DrawText method.

Width Long Sets or returns the horizontal drawing area for the canvas.

Alignment

Value Mnemonic Description

0 ddTXLeft Aligns the text to the left edge of the object area.

1 ddTXRight Aligns the text to the right edge of the object area.

2 ddTXCenter Center the text horizontally within the object area.

Design time N/A

Run time Read / Write

BackColor (Canvas)

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 226

Page 227: 83791925 Active Report 2 0 Standard Edition

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

BackStyle (Canvas)DescriptionSets 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 TypeBackStyle

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

Font (Canvas)DescriptionSets 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 TypestdFont

Availability

BackStyle (Canvas)

Design time Read / Write

Run time Read / Write

Font (Canvas)

Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 227

Page 228: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub Detail_Format()' Set sales figures > $10000 to bold underlineIf txtSales.DataValue > 10000 Then

txtSales.Font.Bold = TruetxtSales.Font.Underline = True

ElsetxtSales.Font.Bold = FalsetxtSales.Font.Underline = False

End IfEnd Sub

ForeColor (Canvas)DescriptionSets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data TypeOLE_COLOR

Availability

Example

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

End Sub

Height (Canvas)DescriptionSets or returns the vertical drawing area for the canvas in twips.

Data TypeLong

Availability

Run time Read / Write

ForeColor (Canvas)

Design time Read / Write

Run time Read / Write

Height

Design time N/A

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 228

Page 229: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_PageStart()'sets the canvas to be 4in X 5in and draws red box'on top of it. Me.Canvas.BackColor = vbRedMe.Canvas.BackStyle = 1Me.Canvas.Width = 4 * 1440Me.Canvas.Height = 5 * 1440Me.Canvas.DrawRect 0, 0, Canvas.Width, Canvas.Height

End Sub

Orientation (Canvas)DescriptionSets 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 TypePrtOrientation

Availability

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 toARViewer1.Pages.InsertNew(0)ARViewer1.Pages(0).Orientation = ddPOLandscape' draw text on the page.

End Sub

PenStyleDescriptionSets the pen style that is used to draw lines and shapes to the canvas.

Data TypeInteger

Settings

Orientation

Run time Read / Write

PenStyle

Value Mnemonic Description

0 ddLSTransparent No line.

ActiveReports 2.0 Standard User's Guide | 229

Page 230: 83791925 Active Report 2 0 Standard Edition

Availability

Example

Private Sub PageHeader_Format()' Draw a round rectangle with Top Secret centeredWith Canvas

.PenStyle = ddLSSolid

.PenWidth = 2

.DrawRoundRect 100, 100, 1500, 300, 10, 10

.Alignment = ddTXCenter

.DrawText "Top Secret", 100, 100, 1500, 300End With

End Sub

PenWidthDescriptionSets or returns the line weight used to draw lines and shapes to the canvas object.

Data TypeInteger (line width 1lw=10 twips)

Availability

Example

Private Sub PageHeader_Format()' Draw a round rectangle with Top Secret centeredWith Canvas

.PenStyle = ddLSSolid

.PenWidth = 2

.DrawRoundRect 100, 100, 1500, 300, 10, 10

.Alignment = ddTXCenter

.DrawText "Top Secret", 100, 100, 1500, 300End With

End Sub

1 ddLSSolid

2 ddLSDash

3 ddLSDot

4 ddLSDashDot

5 ddLDDashDotDot

Design time N/A

Run time Read / Write

PenWidth

Design time N/A

Run time Read / Write

Tag

ActiveReports 2.0 Standard User's Guide | 230

Page 231: 83791925 Active Report 2 0 Standard Edition

Tag (Canvas)DescriptionSets 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 TypeVariant

Availability

Example

Private Sub ghCustomer_AfterPrint()

'Set the tag to the customer fax number'Use it later to change printer settings to send the faxCanvas.Tag = txtCustomerFax.DataValue

End Sub

TextAngleDescriptionSets 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 TypeLong

Availability

Example

' Draw Confidential Message at 45 degree angleCanvas.TextAngle = 450Canvas.Font.Name = "Arial"Canvas.Font.Size = 48Canvas.DrawText("Confidential", _

3*1440, 2*1440, 3*1440, 4*1440)

VerticalAlignment (Canvas)DescriptionSets or returns the vertical position of the text relative to the containing area.

Design time N/A

Run time Read / Write

TextAngle

Design time N/A

Run time Read / Write

VerticalAlignment

ActiveReports 2.0 Standard User's Guide | 231

Page 232: 83791925 Active Report 2 0 Standard Edition

Data TypeInteger

Settings

Availability

ExampleCanvas.VerticalAlignment = ddTXTop

WidthDescriptionSets or returns the horizontal drawing area for the canvas in twips.

Data TypeLong

Availability

Example

Private Sub ActiveReport_PageStart()'sets the canvas to be 4in X 5in and draws red box'on top of it. Me.Canvas.BackColor = vbRedMe.Canvas.BackStyle = 1Me.Canvas.Width = 4 * 1440Me.Canvas.Height = 5 * 1440Me.Canvas.DrawRect 0, 0, Canvas.Width, Canvas.Height

End Sub

Canvas Methods

Value Mnemonic Description

0 ddTXTop Aligns the text to the top of the object area.

1 ddTXMiddle Centers the text vertically within the object area.

2 ddTXBottom Align the text to the bottom of the object area.

Design time N/A

Run time Read / Write

Width

Design time N/A

Run time Read / Write

Canvas Methods

Method Description

Clear Clear the canvas object. Sub Clear()

DrawEllipse Draws an elliptical shape to the canvas at the specified

ActiveReports 2.0 Standard User's Guide | 232

Page 233: 83791925 Active Report 2 0 Standard Edition

coordinates. Sub DrawEllipse(left As Long, top As Long, widthAs 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 , YAs 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 , widthAs 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 , wAs 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 | 233

Page 234: 83791925 Active Report 2 0 Standard Edition

Clear (Canvas)DescriptionClears the canvas of all prior output

Return TypeNone

SyntaxSub Clear()

ParametersNone

Example

Dim cv As New Canvascv.TextOut "Sales Report", 1440, 1000'Add this page to the pages collectionrpt.Pages.Insert rpt.Pages.Count, cvcv.Clear'Create the second page

DrawEllipseDescriptionDrawEllipse method draws an elliptical shape to the canvas object at the specified coordinates.

Return TypeNone

SyntaxSub DrawEllipse(left As Long, top As Long, width As Long, height As Long)

Parameters

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

DrawEllipse

Name Type Description

Left Long Left coordinate of the ellipse shape (Twips).

Top Long Top coordinate of the ellipse shape (Twips)

ActiveReports 2.0 Standard User's Guide | 234

Page 235: 83791925 Active Report 2 0 Standard Edition

ExampleCanvas.DrawEllipse 1440, 1440, 1440, 2880

DrawLineDescriptionDrawLine 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 TypeNone

SyntaxSub DrawLine(x1 As Long, y1 As Long, x2 As Long, y2 As Long)

Parameters

Example

Canvas.PenWidth = 2Canvas.DrawLine 0, 1440, PrintWidth, 1440

DrawPictureDescriptionDraws the specified picture to the canvas surface at the specified coordinates.

Return TypeNone

SyntaxSub DrawPicture(hPic As stdPicture, left As Long, top As Long, width As Long, height As Long)

Parameters

Example

Dim pic As StdPicture

Width Long Width of the ellipse shape (Twips)

Height Long Height of the ellipse shape (Twips)

DrawLine

Name Type Description

x1, y1 Long Coordinates of the line's starting point (Twips).

x2, y2 Long Coordinates of the line's ending point (Twips).

DrawPicture

Name Type Description

hPic StdPicture Picture object to be drawn to the canvas

left, top Long Coordinates of the picture.

width, height Long Dimensions of the picture.

ActiveReports 2.0 Standard User's Guide | 235

Page 236: 83791925 Active Report 2 0 Standard Edition

Set pic = LoadPicture App.Path & "\TopSecret.WMF"Canvas.DrawPicture pic, 0,0,Canvas.Width, Canvas.Height

DrawPictureLinkDescriptionDraws the specified picture, with an embedded hyperlink, to the canvas surface at the coordinates indicated.

Return TypeNone

SyntaxSub DrawPictureLink(Picture As stdPicture, Left As Long, Top As Long, Width As Long, HeightAs Long, Hyperlink As String)

Parameters

Example

Private Sub ActiveReport_PageStart()Dim pic As StdPictureDim str As String

'Set the picture to load for DrawPictureLinkSet pic = LoadPicture(App.Path & "\ARLogo.jpg")

'Set the text to use with DrawTextLinkstr = "Link To DataDynamics Web Page"'Draw image to canvas and attach a hyperlinkCanvas.DrawPictureLink pic, 1 * 1440, 1 * 1440, _2 * 1440, 2 * 1440, "www.datadynamics.com"

'Set a font name and size to use on the canvasCanvas.Font.Name = "Arial"Canvas.Font.Size = 18'Draw text to canvas and attach a hyperlinkCanvas.DrawTextLink str, 1 * 1440, 4 * 1440, _

3 * 1440, 4 * 1440, "www.datadynamics.com"End Sub

DrawRectDescriptionDrawRect 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 TypeNone

DrawPictureLink

Name Type Description

Picture stdPicture Picture object to be drawn to the canvas

Left, Top Long Coordinates of the picture.

Width, Height Long Dimensions of the picture.

Hyperlink String String indicating the URL for the hyperlink

DrawRect

ActiveReports 2.0 Standard User's Guide | 236

Page 237: 83791925 Active Report 2 0 Standard Edition

SyntaxSub DrawRect(left As Long, top As Long, width As Long, height As Long)

Parameters

Example

For i = 1440 to 3 * 1440 Step 300Canvas.DrawRect 100, I, PrintWidth – 200, 300

Next i

DrawRoundRectDescriptionDrawRoundRect 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 TypeNone

SyntaxSub DrawRoundRect(Left As Long, Top As Long, Width As Long, Height As Long, w As Long, h As Long)

Parameters

Example

Private Sub PageHeader_Format()' Draw a round rectangle with Top Secret centeredWith Canvas

.PenStyle = ddLSSolid

.PenWidth = 2

.DrawRoundRect 100, 100, 1500, 300, 10, 10

.Alignment = ddTXCenter

.DrawText "Top Secret", 100, 100, 1500, 300End With

End Sub

Name Type Description

Left Long Left coordinate of the rectangle shape (Twips).

Top Long Top coordinate of the rectangle shape (Twips)

Width Long Width of the rectangle (Twips)

Height Long Height of the rectangle (Twips)

DrawRoundRect

Name Type Description

Left Long Left coordinate of the rectangle shape (Twips).

Top Long Top coordinate of the rectangle shape (Twips)

Width Long Width of the rectangle (Twips)

Height Long Height of the rectangle (Twips)

W Long Width of the rounded angle (Twips)

H Long Height of the rounded angle (Twips)

ActiveReports 2.0 Standard User's Guide | 237

Page 238: 83791925 Active Report 2 0 Standard Edition

DrawTextDescriptionDrawText 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 TypeNone

SyntaxSub DrawText(Text As String, x As Long, y As Long, Width As Long, Height As Long)

Parameters

Example

' Draw Confidential Message at 45 degree angleCanvas.TextAngle = 450Canvas.Font.Name = "Arial"Canvas.Font.Size = 48Canvas.DrawText("Confidential", _

3*1440, 2*1440, 3*1440, 4*1440)

DrawTextLinkDescriptionDrawTextLink 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 TypeNone

SyntaxSub DrawTextLink(Text As String, x As Long, y As Long, Width As Long, Height As Long, Hyperlink As String)

Parameters

DrawText

Name Type Description

Text String String to be printed to the Canvas

X Long Left coordinate of the text area (Pixels).

Y Long Top coordinate of the text area (Pixels)

Width Long Width of the text area (Pixels)

Height Long Height of the text area (Pixels)

DrawTextLink

Name Type Description

Text String String to be printed to the Canvas

ActiveReports 2.0 Standard User's Guide | 238

Page 239: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_PageStart()Dim pic As StdPictureDim str As String

'Set the picture to load for DrawPictureLinkSet pic = LoadPicture(App.Path & "\ARLogo.jpg")

'Set the text to use with DrawTextLinkstr = "Link To DataDynamics Web Page"'Draw image to canvas and attach a hyperlinkCanvas.DrawPictureLink pic, 1 * 1440, 1 * 1440, _

2 * 1440, 2 * 1440, "www.datadynamics.com"

'Set a font name and size to use on the canvasCanvas.Font.Name = "Arial"Canvas.Font.Size = 18'Draw text to canvas and attach a hyperlinkCanvas.DrawTextLink str, 1 * 1440, 4 * 1440, _

3 * 1440, 4 * 1440, "www.datadynamics.com"End Sub

FillRectDescriptionFillRect fills the rectangle at the specified coordinates with solid ForeColor. Note: FillRect does not draw a border around the rectangle.

Return TypeNone

SyntaxSub FillRect(left As Long, top As Long, width As Long, height As Long)

Parameters

Example

rptSales.Pages(0).ForeColor = vbBluerptSales.Pages(0).FillRect 1440, 1440, 2880, 720

X Long Left coordinate of the text area (Pixels).

Y Long Top coordinate of the text area (Pixels)

Width Long Width of the text area (Pixels)

Height Long Height of the text area (Pixels)

Hyperlink String String indicating the URL for the hyperlink

FillRect

Name Type Description

Left Long Left coordinate of the rectangle (Pixels).

Top Long Top coordinate of the rectangle (Pixels)

Width Long Width of the rectangle (Pixels)

Height Long Height of the rectangle (Pixels)

ActiveReports 2.0 Standard User's Guide | 239

Page 240: 83791925 Active Report 2 0 Standard Edition

IntersectClipRectDescriptionSets 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 TypeNone

SyntaxSub IntersectClipRect(x As Long, y As Long, w As Long, h As Long)

Parameters

Example

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 1000, 1000, 5000, 5000cnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800<cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.HeightmPages.Insert mPages.Count, cnv

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 500, 500, 3000, 3000cnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.HeightmPages.Insert mPages.Count, cnv

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 1000, 1000, 5000, 5000cnv.PushClipRectcnv.IntersectClipRect 500, 500, 3000, 3000cnv.PopClipRectcnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.HeightmPages.Insert mPages.Count, cnv

Set cnv = Nothing

Load (Canvas)Description

IntersectClipRect

Name Type Description

x Long Left coordinate of the clipping rectangle area (Pixels).

y Long Top coordinate of the clipping rectangle area (Pixels)

w Long Width of the clipping rectangle area (Pixels)

h Long Height of the clipping rectangle area (Pixels)

Load

ActiveReports 2.0 Standard User's Guide | 240

Page 241: 83791925 Active Report 2 0 Standard Edition

Loads the contents of a canvas object from the specified file.

Return TypeNone

SyntaxSub Load(FileName As String)

Parameters

Example

Private Sub OverlayForm()Dim cv As New CanvasDim pg As Canvas' Load a saved canvas filecv.Load App.Path "\InvoiceForm.cnv"' overlay it on all report pagesFor Each pg In rpt.Pages

Pg.Overlay cvNext

End Sub

MeasureParagraphHeightDescriptionReturns 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 TypeLong

SyntaxFunction MeasureParagraph(Text As String, Width As Long) As Long

Parameters

RemarksWhen 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 fieldstr = "This is a string that will be used to measure the paragraph height"

Name Type Description

filename String A valid filename that contains a previously saved canvas object

MeasureParagraphHeight

Name Type Description

Text String The text string to be measured

Width Long Specified the width of the paragraph text string (in twips)

ActiveReports 2.0 Standard User's Guide | 241

Page 242: 83791925 Active Report 2 0 Standard Edition

'Set the canavs font the same as the field being'used to make sure the measurements are correctCanvas.Font = Field1.Font

'Set field1's height based off of the measurementWith Field1

.Height = Canvas.MeasureParagraphHeight(str, _

.Width - 40) + 30End With

Field1.Text = str

End Sub

MeasureTextDescriptionReturns 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 TypeNone

SyntaxSub MeasureText(Text As String, Width As Variant, Height As Variant)

Parameters

Example

Dim w, h rpt.Pages(0).MeasureText "Confidential", w, hrpt.Pages(0).DrawText "Confidential", 1440, 1440, w, h

OverlayDescriptionOverlays (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 TypeNone – The two canvas objects will be merged.

SyntaxSub Overlay(Canvas As Canvas)

Parameters

MeasureText

Name Type Description

Text String The text string to be measured

Width Variant Returns the width of the text string (in twips)

Height Variant Returns the minimum height of the text string (in twips)

Overlay

Name Type Description

ActiveReports 2.0 Standard User's Guide | 242

Page 243: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub OverlayForm()Dim cv As New CanvasDim pg As Canvas

' Run the report to create the pages collectionrptInvoice.Run

' Load a saved canvas filecv.Load App.Path & "\InvoiceForm.cnv"

' overlay it on all report pagesFor Each pg In rptInvoice.Pages

Pg.Overlay cvNext

End Sub

PopClipRectDescriptionRestores 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 TypeNone

SyntaxSub PopClipRect()

ParametersNoneSample

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 1000, 1000, 5000, 5000cnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.HeightmPages.Insert mPages.Count, cnv

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 500, 500, 3000, 3000cnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.HeightmPages.Insert mPages.Count, cnv

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 1000, 1000, 5000, 5000cnv.PushClipRectcnv.IntersectClipRect 500, 500, 3000, 3000cnv.PopClipRectcnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.Height

Canvas Canvas A valid pointer to the overlay canvas object

PopClipRect

ActiveReports 2.0 Standard User's Guide | 243

Page 244: 83791925 Active Report 2 0 Standard Edition

mPages.Insert mPages.Count, cnvSet cnv = Nothing

PushClipRectDescriptionSaves 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 TypeNone

SyntaxSub PushClipRect()

ParametersNone

Example

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 1000, 1000, 5000, 5000cnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.HeightmPages.Insert mPages.Count, cnv

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 500, 500, 3000, 3000cnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.HeightmPages.Insert mPages.Count, cnv

Set cnv = New DDActiveReportsViewer2Ctl.Canvascnv.IntersectClipRect 1000, 1000, 5000, 5000cnv.PushClipRectcnv.IntersectClipRect 500, 500, 3000, 3000cnv.PopClipRectcnv.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, 4500cnv.DrawLine 0, 1800, cnv.Width, 1800cnv.DrawLine 1800, 1000, 1800, cnv.Heightcnv.DrawLine 1800, 0, 1800, cnv.HeightmPages.Insert mPages.Count, cnv

Set cnv = Nothing

Save (Canvas)DescriptionSaves the canvas object to the specified file.

Return TypeNone – The canvas object will be persisted to the specified file.

PushClipRect

Save

ActiveReports 2.0 Standard User's Guide | 244

Page 245: 83791925 Active Report 2 0 Standard Edition

SyntaxSub Save(FileName As String)

Parameters

Example

Private Sub CreateFormTemplate()Dim cv As New Canvas' Draw the form on the canvas using drawing methods' Save the canvas object for later usecv.Save App.Path & "\InvoiceForm.cnv"

End Sub

TextOutDescriptionTextOut 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 TypeNone

SyntaxSub TextOut(Text As String, x As Long, y As Long)

Parameters

Example

Dim cv As New Canvas cv.TextOut "Sales Report", 1440, 1000'Add this page to the pages collectionrpt.Pages.Insert rpt.Pages.Count, cvcv.Clear'Create the second page'Commit the changesrpt.Pages.Commit

ControlsControls Methods

BarCode Control Properties

Name Type Description

filename String A valid filename where the canvas object will be saved

TextOut

Name Type Description

Text String The text string to be printed

x, y Long The left and top coordinates where the text should be printed (in pixels).

Controls

ActiveReports 2.0 Standard User's Guide | 245

Page 246: 83791925 Active Report 2 0 Standard Edition

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

Add (Controls)DescriptionAdd method adds a new control of the specified ProgID to the collection.

Return TypeControl object

SyntaxFunction Add(ProgID As String) As Object

Parameters

SettingsInternal controls have the following ProgID names:

Controls Methods

Method Description

Add 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

Name Type Description

ProgID String The ProgID of the control to be added.

ActiveReports 2.0 Standard User's Guide | 246

Page 247: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub CreateNewReport()Dim rpt As New rptTemplateDim ctl As Object' Create report data source controlWith 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 * 1440ctl.Top = 0

End With' Create the rest of the controls' Run the report

End Sub

Count (Controls)DescriptionCount method returns the number of controls in the collection.

Return Type Integer

SyntaxFunction Count() As Integer

ParametersNone

ExamplePrivate Sub Detail_BeforePrint()

Control ProgID

Label DDActiveReports2.Label

Field DDActiveReports2.Field

Image DDActiveReports2.Image

RichEdit DDActiveReports2.RichEdit

Frame DDActiveReports2.Frame

Checkbox DDActiveReports2.Checkbox

PageBreak DDActiveReports2.PageBreak

Line DDActiveReports2.Line

Shape DDActiveReports2.Shape

OLE Object DDActiveReports2.OLE

BarCode DDActiveReports2.BarCode

Subreport DDActiveReports2.Subreport

ADO Data Control DDActiveReports2.DataControl

DAO Data Control DDActiveReports2.DAODataControl

RDO Data Control DDActiveReports2.RDODataControl

XML Data Control DDActiveReports2.XMLDataControl

Count

ActiveReports 2.0 Standard User's Guide | 247

Page 248: 83791925 Active Report 2 0 Standard Edition

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 (Controls)DescriptionThe Item method returns a reference to the control object at the specified index.

Return TypeSection object

SyntaxFunction Item(Index As Variant) As Object

Parameters

Remove (Controls)DescriptionThe Remove method removes the control at the specified index from the controls collection.

Return TypeNone

SyntaxSub Remove(index As Variant)

Parameters

RemoveAll (Controls)DescriptionThe RemoveAll method removes all control objects within the section specified.

Item

Name Type Description

Index Variant The index of the control in the collection or unique name of the control.

Remove

Name Type Description

Index Variant The index of the control in the collection or unique name of the control.

RemoveAll

ActiveReports 2.0 Standard User's Guide | 248

Page 249: 83791925 Active Report 2 0 Standard Edition

Return TypeInteger

SyntaxSub RemoveAll()

ParametersNone

Example

Private Sub ActiveReport_ReportStart()Me.Detail.Controls.RemoveAll

End Sub

BarCode Control Properties

Alignment (BarCode)DescriptionSets or returns the position the barcode's readable caption will have relative to the barcode's left, center and right edges.

BarCode Control Properties

Property Data Type Description

Alignment TextAlignment Sets or returns the position the barcode's readable caption will have relative to the barcode's left, center and right edges.

BackColor OLE_COLOR Sets or returns the barcode's background color or fill color.

BarWidth Integer Sets or returns the width, in pixels, for the barcode's narrow bars.

Caption String Sets or returns the barcode's caption.

CaptionPosition BarCodeCaptionPosition Sets or returns the type of vertical alignment the barcode's caption will have.

DataField String Sets or returns the field the control will be bound to.

Direction BarCodeDirection Sets or returns the barcode's direction horizontally or vertically.

EnableCheckSum Bool Sets or returns if checksum value is used when rendering barcode.

Font StdFont Sets or returns the font properties used to print the caption.

ForeColor OLE_COLOR Sets the font color used to print the barcode.

Style BarCodeStyle Sets or returns the type of code, or symbology, the barcode control will use to generate the barcodes.

Alignment

ActiveReports 2.0 Standard User's Guide | 249

Page 250: 83791925 Active Report 2 0 Standard Edition

Data TypeTextAlignment

Settings

Availability

Example

Private Sub ActiveReport_ReportStart()ActiveReport1.Barcode1.Alignment = ddTXCenter

End Sub

BackColor (BarCode)DescriptionSets or returns the barcode's background color or fill color.

Data TypeOLE_COLOR

Availability

Example

' Mark the outstanding sales in red backgroundPrivate Sub Detail_Format()

If fieldID = "1400" thenBarcode1.BackColor = vbRed

ElseBarcode1.BackColor = vbBlue

End IfEnd Sub

Value Mnemonic Description

0 ddTXLeft Aligns the text to the left edge of the object area.

1 ddTXRight Aligns the text to the right edge of the object area.

2 ddTXCenter Center the text horizontally within the object area.

Design time Read / Write

Run time Read / Write

BackColor

Design time Read / Write

Run time Read / Write

BarWidth

ActiveReports 2.0 Standard User's Guide | 250

Page 251: 83791925 Active Report 2 0 Standard Edition

BarWidthDescriptionSets 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 TypeInteger

Availability

Example

Private Sub ActiveReport_ReportStart()Barcode1.BarWidth = 10

End Sub

Caption (BarCode)DescriptionSets 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 TypeString

Availability

Example

Private Sub Detail_Format()Barcode1.caption = fldItemName

End Sub

CaptionPositionDescriptionSets or returns the type of vertical alignment the barcode's caption will have.

Data Type

Design time Read / Write

Run time Read / Write

Caption

Design time Read / Write

Run time Read / Write

CaptionPosition

ActiveReports 2.0 Standard User's Guide | 251

Page 252: 83791925 Active Report 2 0 Standard Edition

BarCodeCaptionPosition

Settings

Availability

Example

Private Sub Detail_Format()Barcode1.Caption = fldItemNameBarcode1.CaptionPosition = ddbcCaptionBelow

End Sub

DataField (BarCode)DescriptionSets 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 TypeString

Availability

Example

Private Sub ActiveReport_DataInitialize()Fields.Add "ItemCode"Barcode1.DataField = "ItemCode"

End Sub

Direction

Value Mnemonic Description

0 ddbcCaptionNone Does not display the barcode's caption.

1 ddbcCaptionAbove The caption is positioned above the barcode.

2 ddbcCaptionBelow The caption is positioned below the barcode.

Design time Read / Write

Run time Read / Write

DataField

Design time Read / Write

Run time Read / Write

Direction

ActiveReports 2.0 Standard User's Guide | 252

Page 253: 83791925 Active Report 2 0 Standard Edition

DescriptionSets or returns the barcode's direction, horizontally or vertically.

Data TypeBarCodeDirection

Settings

Availability

Example

Private Sub Detail_Format()Barcode1.Direction = ddbcTopToBottom

End Sub

EnableCheckSumDescriptionSets or returns if checksum value is used when rendering barcode. Setting EnableCheckSum to false will only affect codes with checksum values.

Data TypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()Barcode1.EnableCheckSum = TrueBarcode2.EnableCheckSum = False

End Sub

Font (BarCode)

Value Mnemonic Description

0 ddbcLeftToRight Sets the barcode's direction left to right horizontally.

1 ddbcRightToLeft Sets the barcode's direction right to left horizontally.

2 ddbcTopToBottom Sets the barcode's direction down the page vertically.

3 ddbcBottomToTop Sets the barcode's direction up the page vertically

Design time Read/Write

Run time Read / Write

EnableCheckSum

Design time Read / Write

Run time Read / Write

Font (BarCode)

ActiveReports 2.0 Standard User's Guide | 253

Page 254: 83791925 Active Report 2 0 Standard Edition

DescriptionSets 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 TypestdFont

Availability

Example

Private Sub Detail_Format()' Set sales figures > $10000 to bold underlineIf txtSales.DataValue > 10000 Then

txtSales.Font.Bold = TruetxtSales.Font.Underline = True

ElsetxtSales.Font.Bold = FalsetxtSales.Font.Underline = False

End IfEnd Sub

ForeColor (BarCode)DescriptionSets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data TypeOLE_COLOR

Availability

Example

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

End Sub

Style (BarCode)

Design time Read / Write

Run time Read / Write

ForeColor (BarCode)

Design time Read / Write

Run time Read / Write

Style

ActiveReports 2.0 Standard User's Guide | 254

Page 255: 83791925 Active Report 2 0 Standard Edition

DescriptionSets or returns the type of code, or symbology, the barcode control will use to generate the barcodes.

Data TypeBarCodeStyle

Settings

Availability

Value Mnemonic Description

0 ddbcNone None

1 ddbcAnsi39 ANSI 3 of 9 (Code 39) uses upper case, numbers, - , * $ / + %

2 ddbcAnsi39X ANSI Extended 3 of 9 (Extended Code 39) uses the complete ASCII character set

3 ddbcCode_2_of_5 2 of 5 uses only numbers

4 ddbcCode25intlv Interleaved 2 of 5 uses only numbers

5 ddbcCode25mat 25 Matrix

6 ddbcCode39 Code 39 uses numbers, % * $ /. , - +, and upper case.

7 ddbcCode39x Extended Code 39 uses the complete ASCII character set

8 ddbcCode_128_A 128 A uses control characters, numbers, punctuation, and upper case

9 ddbcCode_128_B 128 B uses punctuation, numbers, upper case, and lower case

10 ddbcCode_128_C 128 C uses only numbers

11 ddbcCode_128auto 128 Auto uses complete ASCII character set. Automatically selects between Code 128 A, B, and C to give the smallest barcode.

12 ddbcCode93 Code 93 uses uppercase, % $ * / , + -, and numbers

13 ddbcCode93x Extended Code 93 uses the complete ASCII character set

14 ddbcMSI MSI Code uses only numbers

15 ddbcPostNet PostNet uses only numbers with a check digit

16 ddbcCodabar Codabar uses A B C D + - : , / and numbers

17 ddbcEAN_8 EAN-8 uses only numbers (7 numbers and a check digit)

18 ddbcEAN_13 EAN-13 uses only numbers (12 numbers and a check digit)

19 ddbcUPC_A UPC-A uses only numbers (11 numbers and a check digit)

20 ddbcUPC_E0 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

21 ddbcUPC_E1 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.

22 ddbcRM4SCC 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.

23 ddbcUCCEAN128 UCC/EAN –128 uses the complete ASCII character set. A special version of Code 128 used in HIBC applications.

Design time Read/Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 255

Page 256: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()Barcode1.Style = ddbcUPC_A

End Sub

Checkbox Properties

Alignment (Checkbox)DescriptionAlignment property determines where the checkbox caption should be printed relative to the left, center and right edges of the text field area.

Data TypeTextAlignment

Settings

Availability

Checkbox Properties

Property Data Type Description

Alignment TextAlignment Sets or returns the alignment of text within the object area.

BackColor OLE_COLOR Sets or returns the background color of the object. This property is ignored if the BackStyle is set to transparent.

BackStyle Integer Sets or returns the object transparency setting.

Caption String Sets or returns the printed caption of the checkbox.

Font StdFont Sets or returns the font properties of the object.

ForeColor OLE_COLOR Sets or returns the foreground color of the print font.

Style String 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.

Value Boolean Sets or returns the value of the checkbox, checked or not checked.

Alignment

Value Mnemonic Description

0 ddTXLeft Aligns the text to the left edge of the object area.

1 ddTXRight Aligns the text to the right edge of the object area.

2 ddTXCenter Center the text horizontally within the object area.

ActiveReports 2.0 Standard User's Guide | 256

Page 257: 83791925 Active Report 2 0 Standard Edition

ExamplerptMain.chkPassed.Align = ddTXRight

BackColor (Checkbox)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

BackStyle (Checkbox) DescriptionSets 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 TypeBackStyle

Availability

Design time Read / Write

Run time Read / Write

BackColor (Checkbox)

Design time Read / Write

Run time Read / Write

BackStyle (Checkbox)

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 257

Page 258: 83791925 Active Report 2 0 Standard Edition

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

Caption (Checkbox)DescriptionCaption property sets or returns the text string to be printed with the checkbox.

Data TypeString

Availability

ExamplerptMain.chkPassed.Caption = "Passed"

Font (Checkbox)DescriptionSets 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 TypestdFont

Availability

Example

Private Sub Detail_Format()' Set sales figures > $10000 to bold underlineIf txtSales.DataValue > 10000 Then

txtSales.Font.Bold = TruetxtSales.Font.Underline = True

ElsetxtSales.Font.Bold = FalsetxtSales.Font.Underline = False

End IfEnd Sub

Caption

Design time Read / Write

Run time Read / Write

Font (Checkbox)

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 258

Page 259: 83791925 Active Report 2 0 Standard Edition

ForeColor (Checkbox)DescriptionSets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data TypeOLE_COLOR

Availability

Example

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

End Sub

Style (Checkbox)DescriptionSets 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.

DataTypeString

Availability

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 normalIf isPositive = False Then

txtBalance.Style = "font-family: SimSun; font-weight:bold; text-align: center; color: rgb(255,0,0)"

ElseIf isPositive = True ThentxtBalance.Style = "font-family: SimSun; font-

weight: normal; text-align: center;

ForeColor (Checkbox)

Design time Read / Write

Run time Read / Write

Style

Design time Read/Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 259

Page 260: 83791925 Active Report 2 0 Standard Edition

color: rgb(0,0,0)"End If

End Sub

Value (Checkbox)DescriptionValue property sets or returns whether the checkbox is checked or not checked.

Data TypeBoolean

Availability

Example

Private Sub Detail_Format()If txtGrade.DataValue > 60 Then

chkPassed.Value = 1End If

End Sub

Field Control Properties

Value

Design time Read / Write

Run time Read / Write

Field Control Properties

Property Data Type Description

Alignment TextAlignment Determines how the value should be printed relative the left, center and right edges of the field.

BackColor OLE_COLOR Sets or returns the background fill color of the field.

BackStyle Integer Sets or returns the transparency of the field.

CanGrow Boolean 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.

CanShrink Boolean When set to True, the field will shrink to fit the text.

ClassName String Sets or returns the controls global style. The global styles are specified in the styles drop-down window.

CountNullValues ('CountNullValues (Field)' in the on-line documentation)

Boolean Sets or returns a value indicating whether null values are counted in averages and count totals for the field.

DataField String Sets or returns the name of the bound field.

DataValue Variant Sets or returns the value of a field before formatting is applied.

ActiveReports 2.0 Standard User's Guide | 260

Page 261: 83791925 Active Report 2 0 Standard Edition

Alignment (Field)DescriptionAlignment property determines where the Text value should be printed relative to the left, center and right edges of the text field area.

Data Type

Font StdFont Sets or returns the font properties used to print the value of the field.

ForeColor OLE_COLOR Sets the font color used to print the value of the field.

hyperLink String 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.

Multiline Boolean Determines whether the contents of the field are printed on a single line or multiple lines.

OutputFormat String Sets or returns the formatting string used to translate the data value of the field to its printed text value.

Style String Sets or returns a style string for the field. The style string can be used to specify a particular appearance for each field.

SummaryDistinctField String Sets the field name that should be used in calculating distinct summary functions.

SummaryDistinctValue String Sets a value that is used to calculate unbound distinct summary functions.

SummaryFunc SummaryFunctions Sets the type of summarization to be calculated for the specified field.

SummaryGroup String Specifies the summarization group level. This property is ignored if the SummaryType is not a group level summary.

SummaryRunning SummaryRunningType Specifies the type of running summarization to be used.

SummaryType SummaryType Specifies the level of summarized to be used.

Text String Sets or returns the formatted value of the field to be printed.

VerticalAlignment VerticalTextAlignment Determines how the value should be printed relative to the top, middle, and bottom of the field.

WordWrap Boolean Sets or returns whether or not a field's text will wrap.

ZOrder Integer 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.

Alignment

ActiveReports 2.0 Standard User's Guide | 261

Page 262: 83791925 Active Report 2 0 Standard Edition

TextAlignment

Settings

Availability

ExamplerptInvestments.fldName.Alignment = ddTXRight

BackColor (Field)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

BackStyle (Field)DescriptionSets 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.

Value Mnemonic Description

0 ddTXLeft Aligns the text to the left edge of the object area.

1 ddTXRight Aligns the text to the right edge of the object area.

2 ddTXCenter Center the text horizontally within the object area.

Design time Read / Write

Run time Read / Write

BackColor (Field)

Design time Read / Write

Run time Read / Write

BackStyle (Field)

ActiveReports 2.0 Standard User's Guide | 262

Page 263: 83791925 Active Report 2 0 Standard Edition

Data TypeBackStyle

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

CanGrow (Field)DescriptionCanGrow 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 TypeBoolean

Availability

ExamplerptInvestments.fldName.CanGrow = TruerptInvestments.fldName.CanShrink = False

CanShrink (Field)DescriptionCanShrink 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

Design time Read / Write

Run time Read / Write

CanGrow

Design time Read / Write

Run time Read / Write

CanShrink

ActiveReports 2.0 Standard User's Guide | 263

Page 264: 83791925 Active Report 2 0 Standard Edition

the contents and shift the control below it upward to account for the decrease in height.

Data TypeBoolean

Availability

ExamplerptInvestments.fldName.CanGrow = TruerptInvestments.fldName.CanShrink = False

ClassName (Field)Sets or returns the controls global style. The global styles are specified in the styles drop-down window.

Data TypeString

Availability

Example

Private Sub Detail_Format()fldID.ClassName = "Heading2"

End Sub

DataField (Field)DescriptionSets 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

Design time Read / Write

Run time Read / Write

ClassName

Design time Read / Write

Run time Read / Write

DataField (Field)

ActiveReports 2.0 Standard User's Guide | 264

Page 265: 83791925 Active Report 2 0 Standard Edition

String

Availability

Example

Private Sub CreateReport()Dim ar As rptTemplate ' rptTemplate is a predefined report

' Template already has a data control named dcRptData' in the Detail SectionSet ar = New rptTemplateWith ar.Sections("Detail").Controls

' Add a field to reportSet ctl = .Add("DDActiveReports2.Field")' Set the new field's propertiesctl.Name = "CompanyName"ctl.Top = 0ctl.Left = 0ctl.Width = 1500ctl.Height = 285' Assign as DataSource and DataField to the fieldctl.DataSource = "dcRptdata"ctl.DataField = "CompanyName"' .. Set up the rest of the fields

End With' Preview the reportar.Show

End Sub

DataValueDescriptionDataValue 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 TypeVariant

Availability

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 .texttxtPctTotal.DataValue = txtSales.DataValue / _

txtGrandTotal.DataValueEnd Sub

Design time Read / Write

Run time Read / Write

DataValue

Run time Read/Write

Font (Field)

ActiveReports 2.0 Standard User's Guide | 265

Page 266: 83791925 Active Report 2 0 Standard Edition

Font (Field)DescriptionSets 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 TypestdFont

Availability

Example

Private Sub Detail_Format()' Set sales figures > $10000 to bold underlineIf txtSales.DataValue > 10000 Then

txtSales.Font.Bold = TruetxtSales.Font.Underline = True

ElsetxtSales.Font.Bold = FalsetxtSales.Font.Underline = False

End IfEnd Sub

ForeColor (Field)DescriptionSets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data TypeOLE_COLOR

Availability

Example

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

End Sub

Design time Read / Write

Run time Read / Write

ForeColor (Field)

Design time Read / Write

Run time Read / Write

hyperLink

ActiveReports 2.0 Standard User's Guide | 266

Page 267: 83791925 Active Report 2 0 Standard Edition

hyperLink (Field)DescriptionSets 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.

DataTypeString

Availability

Example

Private Sub Detail_Format()fldLink.hyperLink = "www.datadynamics.com"fldLink.Text = "fldLink's Hyperlink is: " & _fldLink.hyperLink

End Sub

Multiline (Field)DescriptionDetermines 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 TypeBoolean

Availability

Example

RptInvestments.fldName.MultiLine = TruerptInvestments.fldName.CanGrow = TruerptInvestments.fldName.CanShrink = False

OutputFormatDescriptionOutputFormat sets or returns the mask string used to format the DataValue into the Text property. It uses the Visual Basic Format function settings.

Design time Read / Write

Run time Read / Write

Multiline

Design time Read / Write

Run time Read / Write

OutputFormat

ActiveReports 2.0 Standard User's Guide | 267

Page 268: 83791925 Active Report 2 0 Standard Edition

Data TypeString

Availability

ExamplerptInvestments.fldName.OutputFormat = "$###0.00"

Style (Field)DescriptionSets 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.

DataTypeString

Availability

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 normalIf isPositive = False Then

txtBalance.Style = "font-family: SimSun; font-weight:bold; text-align: center; color: rgb(255,0,0)"

ElseIf isPositive = True ThentxtBalance.Style = "font-family: SimSun; font-

weight: normal; text-align: center; color: rgb(0,0,0)"

End IfEnd Sub

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

Design time Read / Write

Run time Read / Write

Style

Design time Read/Write

Run time Read / Write

SummaryDistinctField

ActiveReports 2.0 Standard User's Guide | 268

Page 269: 83791925 Active Report 2 0 Standard Edition

Data TypeString

Availability

SummaryDistinctValueDescriptionSummaryDistinctValue 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 TypeString

Availability

SummaryFuncDescriptionSets 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 TypeSummaryFunctions

Settings

Design time Read / Write

Run time Read / Write

SummaryDistinctValue

Design time Read / Write

Run time Read / Write

SummaryFunc

Value Mnemonic Description

0 ddSFSum Calculates the total of all values within the specified summary region (group, page report).

1 ddSFAvg Calculates the average of all values within the specified summary region (group, page or report).

2 ddSFCount Calculates the count of all values within the specified summary region (group, page or report).

3 ddSFMin Calculates the minimum of all values within the specified summary region (group, page or report).

4 ddSFMax Calculates the maximum of all values within the specified summary region (group, page or report).

5 ddSFVar Calculates the variance of all values within the specified

ActiveReports 2.0 Standard User's Guide | 269

Page 270: 83791925 Active Report 2 0 Standard Edition

Availability

SummaryGroupDescriptionSummaryGroup 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 TypeString

Availability

SummaryRunning

summary region (group, page or report).

6 ddSFVarP Calculates the population variance of all values within the specified summary region (group, page or report).

7 ddSFStdDev Calculates the standard deviation of all values within the specified summary region (group, page or report).

8 ddSFStdDevP Calculates the population standard deviation of all values within the specified summary region (group, page or report).

9 ddSFDSum Calculates the total based on the distinct values of another field within the specified summary region (group, page or report).

10 ddSFDAvg Calculates the average based on the distinct values of another field within the specified summary region (group, page or report).

11 ddSFDCount Calculates the distinct count based on the distinct values of another field within the specified summary region (group, page or report).

12 ddSFDVar Calculates the variance based on the distinct values of another field within the specified summary region (group, page or report).

13 ddSFDVarP Calculates the population distinct variance based on the distinct values of another field within the specified summary region (group, page or report).

14 ddSFDStdDev Calculates the standard deviation based on the distinct values of another field within the specified summary region (group, page or report).

15 ddSFDStdDevP Calculates the population standard deviation based on the distinct values of another field within the specified summary region (group, page or report).

Design time Read / Write

Run time Read / Write

SummaryGroup

Design time Read / Write

Run time Read / Write

SummaryRunning

ActiveReports 2.0 Standard User's Guide | 270

Page 271: 83791925 Active Report 2 0 Standard Edition

DescriptionSummaryRunning 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 TypeSummaryRunningType

Settings

Availability

SummaryTypeDescriptionSummaryType 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 TypeSummaryType

Settings

Value Mnemonic Description

0 ddSRNone Do not calculate a running summary.

1 ddSRGroup Calculates a running summary (each value is the sum of the current value and all preceding values) within the same group level.

2 ddSRAll Calculates a running summary for all values.

Design time Read / Write

Run time Read / Write

SummaryType

Value Mnemonic Description

0 ddSMNone No summarization.

1 ddSMGrandTotal Specifies a report level summary, evaluates the summary function for all records in the report.

2 ddSMPageTotal Specifies a page level summary, evaluates the summary function for all records on each page.

3 ddSMSubTotal Specifies a group level summary, evaluates the summary function for all records in each group level.

ActiveReports 2.0 Standard User's Guide | 271

Page 272: 83791925 Active Report 2 0 Standard Edition

Availability

Text (Field)DescriptionSets or returns the text string to be displayed in the field.

Data TypeString

Availability

Example

Private Sub Detail_Format()If fldItem.Text = "" then

fldItem.Text = "None"End If

End Sub

VerticalAlignment (Field)DescriptionVerticalAlignment property determines where the Text value should be printed relative to the top, middle and bottom edges of the text field area.

Data TypeVerticalTextAlignment

Settings

Availability

4 ddSMPageCount Specifies a Page Count field.

Design time Read / Write

Run time Read / Write

Text

Design time Read / Write

Run time Read / Write

VerticalAlignment

Value Mnemonic Description

0 ddTXTop Aligns the text to the top of the object area.

1 ddTXMiddle Centers the text vertically within the object area.

2 ddTXBottom Aligns the text to the bottom of the object area.

Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 272

Page 273: 83791925 Active Report 2 0 Standard Edition

ExamplerptRPW.fldArable.VerticalAlignment = ddTXMiddle

WordWrap (Field)DescriptionSets 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 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.

DataTypeBoolean

Availability

Example

Private Sub Detail_Format()Field1.WordWrap = False

End Sub

ZOrder (Field)DescriptionThis 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 TypeNone

SyntaxSub Zorder(Position As Integer)

Parameters

Settings

Run time Read / Write

WordWrap

Design time Read/Write

Run time Read / Write

ZOrder (Field)

Name Type Description

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

ActiveReports 2.0 Standard User's Guide | 273

Page 274: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0txtEndNote.ZOrder 0txtDescription.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 descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.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 PanesFrame Control Properties

Panes

Frame Control Properties

1 Setting the ZOrder to 1 sends the control to the back.

Frames and Panes

Frame Control Properties

Property Data Type Description

BackColor OLE_COLOR Sets or returns the background fill color of the frame.

CanGrow Boolean 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.

CanShrink Boolean When set to True, the frame will shrink to fit the text.

CloseBorder Boolean Sets or returns if the border is closed

Panes Pane A collection of the pane objects appearing in the frame

ZOrder Integer 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.

BackColor

ActiveReports 2.0 Standard User's Guide | 274

Page 275: 83791925 Active Report 2 0 Standard Edition

BackColor (Frame)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

' Mark the outstanding sales in red backgroundPrivate Sub Detail_Format()

If frameMain.panes.count > 3 thenframeMain.BackColor = vbRed

ElseframeMain.BackStyle = ddBKTransparent

End IfEnd Sub

CanGrow (Frame)DescriptionCanGrow 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 TypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()frameMain.CanGrow = FalseframeMain.CanShrink = False

End Sub

Design time Read/Write

Run time Read / Write

CanGrow

Design time Read / Write

Run time Read / Write

CanShrink

ActiveReports 2.0 Standard User's Guide | 275

Page 276: 83791925 Active Report 2 0 Standard Edition

CanShrink (Frame)DescriptionCanShrink 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 TypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()frameMain.CanGrow = FalseframeMain.CanShrink = False

End Sub

CloseBorder (Frame)DescriptionSet or returns whether or not the bottom border line will be displayed if the frame spans across multiple pages.

Data TypeBoolean

Availability

ExampleFrameMain.CloseBorder = False

Panes (Frame)DescriptionReturns a collection of the panes displayed on the frame.

Data TypePanes

Availability

Design time Read / Write

Run time Read / Write

CloseBorder

Design time Read / Write

Run time Read / Write

Panes

ActiveReports 2.0 Standard User's Guide | 276

Page 277: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub Detail_Format()FrameMain.Panes(0).BackColor = vbRedFrameMain.Panes(0).BackStyle = 1

End Sub

ZOrder (Frame)DescriptionThis 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 TypeNone

SyntaxSub Zorder(Position As Integer)

Parameters

Settings

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0txtEndNote.ZOrder 0txtDescription.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 descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.Width = txtDescription.Width' Sets the vertical alignment to middle and' Positions the description behind the' Head and End note text fields.txtDescription.VerticalAlignment = ddTXMiddle

Run time Read / Write

ZOrder (Frame)

Name Type Description

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

1 Setting the ZOrder to 1 sends the control to the back.

ActiveReports 2.0 Standard User's Guide | 277

Page 278: 83791925 Active Report 2 0 Standard Edition

End Sub

Panes CollectionPane Properties

Pane Methods

Pane Properties

BackColor (Pane)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

Private Sub Detail_Format()fAuto.Panes(0).BackColor = vbYellowfAuto.Panes(0).BackStyle = ddBKNormal

End Sub

BackStyle

Panes

Pane Properties

Property Data Type Description

BackColor OLE_COLOR Sets or returns the pane's background color or fill color.

BackStyle Integer Sets or returns whether the pane is rendered in transparent (opaque) or normal mode.

Border Border Set or returns the pane's border settings.

CloseBorder Boolean Set or returns whether or not the bottom border line will be displayed if the pane spans across multiple pages.

Controls PaneControls Returns a collection of controls displayed on the frame

BackColor

Design time N/A

Run time Read / Write

BackStyle

ActiveReports 2.0 Standard User's Guide | 278

Page 279: 83791925 Active Report 2 0 Standard Edition

DescriptionSets 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 TypeBackStyle

Availability

Example

Private Sub Detail_Format()fAuto.Panes(0).BackColor = vbYellowfAuto.Panes(0).BackStyle = ddBKNormal

End Sub

BorderDescriptionSet or returns the pane's border settings.

Data TypeBorder

Availability

Example

Private Sub Detail_Format()fAuto.Panes(0).Border.BottomColor = vbRedfAuto.Panes(0).Border.BottomStyle = ddBLExtraThickSolidfAuto.Panes(0).Border.RightColor = vbRedfAuto.Panes(0).Border.RightStyle = ddBLThickSolidfAuto.Panes(0).Border.TopColor = vbBluefAuto.Panes(0).Border.TopStyle = ddBLExtraThickSolidfAuto.Panes(0).Border.LeftColor = vbBluefAuto.Panes(0).Border.LeftStyle = ddBLSolidfAuto.Panes(0).Border.Shadow = True

End Sub

Design time N/A

Run time Read / Write

Border

Design time N/A

Run time Read-Only

CloseBorder

ActiveReports 2.0 Standard User's Guide | 279

Page 280: 83791925 Active Report 2 0 Standard Edition

CloseBorder (Pane)DescriptionSet or returns whether or not the bottom border line will be displayed if the pane spans across multiple pages.

Data TypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()FrameMain.CloseBorder = FalseFrameMain.Panes(0).CloseBorder = False

End Sub

Controls (Pane)DescriptionReturns a collection of controls on the pane

Data TypePaneControls

Availability

Pane Methods

Design time N/A

Run time Read / Write

Controls

Design time N/A

Run time Read / Write

Pane Methods

Method Description

Add 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 | 280

Page 281: 83791925 Active Report 2 0 Standard Edition

Add (Pane)DescriptionAdds a new pane to the panes collection.

Return TypeNone

SyntaxSub Add(ParentName As String, Split As SplitTypes, [NewPaneName])

Parameters

SplitType

Example

Private Sub ActiveReport_ReportStart()FrameMain.Panes.Add "Pane0", ddLeftSplit, "Pane1"FrameMain.Panes.Add "Pane0", ddBottomSplit, "Pane2"

End Sub

Count (Pane)DescriptionReturns the number of panes in the collection.

Return TypeInteger

SyntaxFunction Count() As Integer

ParametersNone

Example

If FrameM.Panes.Count < 3 ThenFrameM.Panes.Add "Pane0", ddRightSplit, "Pane" & _

Name Type Description

ParentName String The parent pane's name.

Split SplitTypes Indicates the type of split to use

NewPaneName String Name for the new pane

Value Mnemonic Description

0 ddTopSplit Places the splitter on top

1 ddBottomSplit Places the splitter on the bottom

2 ddLeftSplit Places the splitter on the left

3 ddRightSplit Places the splitter on the right

Count

ActiveReports 2.0 Standard User's Guide | 281

Page 282: 83791925 Active Report 2 0 Standard Edition

FrameM.Panes.CountEnd If

Item (Pane)DescriptionReturns a reference to the pane object at the specified index.

Return TypePane

SyntaxFunction Item(Index As Integer) As Pane

Parameters

Example

Private Sub Detail_Format()FrameMain.Panes.Item(0).BackColor = vbRedFrameMain.Panes.Item(0).BackStyle = ddBKNormal

End Sub

Remove (Pane)DescriptionRemoves a pane's object with the specified index.Return Type

None

SyntaxSub Remove(Index)

Parameters

Example

If Ingredients = "" ThenFrameMain.Panes.Remove 0

End If

Item

Name Type Description

Index Integer Index of the pane to return

Remove

Name Type Description

Index Integer Index of the pane to remove

Image Properties

ActiveReports 2.0 Standard User's Guide | 282

Page 283: 83791925 Active Report 2 0 Standard Edition

Image Properties

BackColor (Image)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

Property Data Type Description

BackColor OLE_COLOR Sets or returns the background color of the object. This property is ignored if the BackStyle is set to transparent.

BackStyle Integer Sets or returns the object transparency setting.

ForeColor OLE_COLOR Sets or returns the foreground color of the object.

Hyperlink String 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.

LineColor OLE_COLOR Sets or returns the line color of the border around the object.

LineStyle LineStyle Sets or returns the line style of the border around the object.

LineWeight Single Sets or returns the line thickness of the border around the object.

Picture StdPicture Sets or returns the image object to be printed.

PictureAlignment Integer Sets or returns the alignment of the picture within the object area.

SizeMode Integer Sets or returns the sizing and clipping setting of the picture when the object dimensions change.

ZOrder Integer 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.

BackColor (Image)

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 283

Page 284: 83791925 Active Report 2 0 Standard Edition

BackStyle (Image)DescriptionSets 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 TypeBackStyle

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

ForeColor (Image)DescriptionSets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data TypeOLE_COLOR

Availability

Example

Private Sub PageHeader_Format()' Paint a Red Confidential in the top-left corner' of each page and change the totals to a red fontCanvas.ForeColor = vbBluetxtTotal.ForeColor = vbRedCanvas.Font.Name = "Arial"

BackStyle (Image)

Design time Read / Write

Run time Read / Write

ForeColor (Image)

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 284

Page 285: 83791925 Active Report 2 0 Standard Edition

Canvas.Font.Size = 16Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440

End Sub

hyperLink (Image)DescriptionSets 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.

DataTypeString

Availability

Example

Private Sub Detail_Format()Image1.Picture = _

LoadPicture(app.path & "\Logo.jpg")Image1.Hyperlink = _

"www.datadynamics.com"End Sub

LineColor (Image)DescriptionLineColor property sets or returns the pen color used to draw the shape's border.

Data TypeOLE_COLOR

Availability

Example

rptShows.imgPoster.LineWeight = 2rptShows.imgPoster.LineStyle = ddLSSolidrptShows.imgPoster.LineColor = vbRed

hyperLink

Design time Read / Write

Run time Read / Write

LineColor

Design time Read / Write

Run time Read / Write

LineStyle

ActiveReports 2.0 Standard User's Guide | 285

Page 286: 83791925 Active Report 2 0 Standard Edition

LineStyle (Image)DescriptionLineStyle property sets or returns the pen style used to draw the shape's border.

Data TypeLineStyle

Settings

Availability

Example

rptShows.imgPoster.LineWeight = 2rptShows.imgPoster.LineStyle = ddLSSolidrptShows.imgPoster.LineColor = vbRed

LineWeight (Image)DescriptionLineWeight property sets or returns the width of the image's border in line weight units (1lw=10 twips).

Data TypeInteger

Availability

Example

rptShows.imgPoster.LineWeight = 2rptShows.imgPoster.LineStyle = ddLSSolidrptShows.imgPoster.LineColor = vbRed

Value Mnemonic Description

0 ddLSTransparent No line.

1 ddLSSolid

2 ddLSDash

3 ddLSDot

4 ddLSDashDot

5 ddLDDashDotDot

Design time Read / Write

Run time Read / Write

LineWeight

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 286

Page 287: 83791925 Active Report 2 0 Standard Edition

PictureDescriptionPicture property sets or return a picture handle displayed in the image control.

Data TypeStdPicture

Availability

Example

rptShows.imgPoster.Picture = LoadPicture(app.path &"\Posters\LesMis.jpg")

PictureAlignment (Image)DescriptionPictureAlignment property determines how the picture is displayed within the image drawing area.

Data TypePictureAlignment

Settings

Availability

ExamplerptShows.imgPoster.PictureAlignment = ddPACenter

Picture

Design time Read / Write

Run time Read / Write

PictureAlignment

Value Mnemonic Description

0 ddPATopLeft Align the picture to the top left corner of the image control area.

1 ddPATopRight Align the picture to the top right corner of the image control area.

2 ddPACenter Align the picture in the center of the image control area.

3 ddPABottomLeft Align the picture to the bottom left corner of the image control area.

4 ddPABottomRight Align the picture to the bottom right corner of the image control area.

Design time Read / Write

Run time Read / Write

SizeMode

ActiveReports 2.0 Standard User's Guide | 287

Page 288: 83791925 Active Report 2 0 Standard Edition

SizeMode (Image)DescriptionSizeMode property determines how the picture is sized to fit within the image area.

Data TypeSizeMode

Settings

Availability

ExampleRptShows.imgPoster.SizeMode = ddSMZoom

ZOrder (Image)DescriptionThis 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 TypeNone

SyntaxSub Zorder(Position As Integer)

Parameters

Settings

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0txtEndNote.ZOrder 0txtDescription.ZOrder 1

End Sub

Value Mnemonic Description

0 ddSMClip Displays the picture at its actual size. The picture is clipped (cut off) if it is larger than the controls defined area.

1 ddSMStretch Sizes the picture to fit the area of the control.

2 ddSMZoom Scales the image to either the height or width of the control to fit it within the specified area without distorting it.

Design time Read / Write

Run time Read / Write

ZOrder (Image)

Name Type Description

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

1 Setting the ZOrder to 1 sends the control to the back.

ActiveReports 2.0 Standard User's Guide | 288

Page 289: 83791925 Active Report 2 0 Standard Edition

Private Sub Detail_BeforePrint()

' Positions the head note at the top' of the description and brings it in' front of the descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.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 Data Type Description

Alignment TextAlignment Determines where the caption should be printed relative the left, center and right edges of the label.

Angle Integer Sets or returns the angle (slope) of the printed value. 1 = 1/10 degree.

BackColor OLE_COLOR Sets or returns the background fill color of the label.

BackStyle Integer Sets or returns the transparency of the label.

Caption String Sets the value to be printed.

ClassName String Sets or returns the controls global style. The global styles are specified in the styles drop-down window.

Font StdFont Sets or returns the font properties used to print the value of the label.

ForeColor OLE_COLOR Sets the font color used to print the value of the label.

Hyperlink String 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.

Multiline Boolean Determines whether the label prints as a single line or expands to multiple lines.

Style String Sets or returns a style string for a label. The style string can be used to specify a particular appearance for each label.

VerticalAlignment VerticalTextAlignment Determines how the value should be printed relative to the top, middle, and bottom of the label.

WordWrap Boolean 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.

ZOrder Integer Sets or returns the order, front or back, for the

ActiveReports 2.0 Standard User's Guide | 289

Page 290: 83791925 Active Report 2 0 Standard Edition

Alignment (Label)DescriptionAlignment property determines where the caption should be printed relative to the left, center and right edges of the label area.

Data TypeTextAlignment

Settings

Availability

ExamplerptInvestments.lblName.Alignment = ddTXRight

AngleDescriptionAngle property sets or returns the angle (slope) of the printed value (1 = 1/10 degree).

Data TypeInteger

Availability

controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

Alignment

Value Mnemonic Description

0 ddTXLeft Aligns the text to the left edge of the object area.

1 ddTXRight Aligns the text to the right edge of the object area.

2 ddTXCenter Center the text horizontally within the object area.

Design time Read / Write

Run time Read / Write

Angle

Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 290

Page 291: 83791925 Active Report 2 0 Standard Edition

ExamplerptInvestments.lblIndex.Angle = 900

BackColor (Label)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

BackStyle (Label)DescriptionSets 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 TypeBackStyle

Availability

Example

Run time Read / Write

BackColor (Label)

Design time Read / Write

Run time Read / Write

BackStyle (Label)

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 291

Page 292: 83791925 Active Report 2 0 Standard Edition

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

Caption (Label)DescriptionSets or returns the text string to be printed.

Data TypeString

Availability

Example

Private Sub PageFooter_Format()If Not dcRptData.Recordset.EOF Then

lblContinued.Caption = "Continued"Else

lblContinued.Caption = ""End If

End Sub

ClassName (Label)Sets or returns the controls global style. The global styles are specified in the styles dropdown window.

Data TypeString

Availability

Example

Private Sub Detail_Format()lblID.ClassName = "Heading2"

End Sub

Caption

Design time Read / Write

Run time Read / Write

ClassName

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 292

Page 293: 83791925 Active Report 2 0 Standard Edition

Font (Label)DescriptionSets 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 TypestdFont

Availability

Example

Private Sub Detail_Format()' Set sales figures > $10000 to bold underlineIf txtSales.DataValue > 10000 Then

txtSales.Font.Bold = TruetxtSales.Font.Underline = True

ElsetxtSales.Font.Bold = FalsetxtSales.Font.Underline = False

End IfEnd Sub

ForeColor (Label)DescriptionSets or returns the foreground color for a control or canvas object. Changing the foreground color changes the font color.

Data TypeOLE_COLOR

Availability

Example

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

End Sub

Font (Label)

Design time Read / Write

Run time Read / Write

ForeColor (Label)

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 293

Page 294: 83791925 Active Report 2 0 Standard Edition

hyperLink (Label)DescriptionSets 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.

DataTypeString

Availability

Example

Private Sub Detail_Format()lblLink.hyperLink = _

"ftp.datadynamics.com/activereports/samples"lblLink.Caption = "lblLink's Hyperlink is: " & _lblLink.hyperLink

End Sub

Multiline (Label)DescriptionDetermines 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 TypeBoolean

Availability

ExamplerptInvestments.lblDescription.MultiLine = True

Style (Label)DescriptionSets 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.

hyperLink

Design time Read / Write

Run time Read / Write

Multiline

Design time Read / Write

Run time Read / Write

Style

ActiveReports 2.0 Standard User's Guide | 294

Page 295: 83791925 Active Report 2 0 Standard Edition

Note: If an invalid CSS style strings is used, the style string will be ignored.

DataTypeString

Availability

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 normalIf isPositive = False Then

lblBalance.Style = "font-family: SimSun; font-weight:bold; text-align: center; color: rgb(255,0,0)"

ElseIf isPositive = True ThenlblBalance.Style = "font-family: SimSun; font-

weight: normal; text-align: center; color: rgb(0,0,0)"

End IfEnd Sub

VerticalAlignment (Label)DescriptionVerticalAlignment property determines where the caption should be printed relative to the top, middle and bottom edges of the label area.

Data TypeVerticalTextAlignment

Settings

Availability

ExamplerptPets.lblType.VerticalAlignment = ddTXBottom

Design time Read / Write

Run time Read / Write

VerticalAlignment

Value Mnemonic Description

0 ddTXTop Aligns the text to the top of the object area.

1 ddTXMiddle Centers the text vertically within the object area.

2 ddTXBottom Align the text to the bottom of the object area.

Design time Read / Write

Run time Read / Write

WordWrap

ActiveReports 2.0 Standard User's Guide | 295

Page 296: 83791925 Active Report 2 0 Standard Edition

WordWrap (Label)DescriptionSets 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 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.

DataTypeBoolean

Availability

Example

Private Sub Detail_Format()Label1.WordWrap = False

End Sub

ZOrder (Label)DescriptionThis 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 TypeNone

SyntaxSub Zorder(Position As Integer)

Parameters

Settings

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0

Design time Read/Write

Run time Read / Write

ZOrder (Label)

Name Type Description

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

1 Setting the ZOrder to 1 sends the control to the back.

ActiveReports 2.0 Standard User's Guide | 296

Page 297: 83791925 Active Report 2 0 Standard Edition

txtEndNote.ZOrder 0txtDescription.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 descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.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

LineColor (Line)DescriptionLineColor property sets or returns the pen color used to draw the line.

Data TypeOLE_COLOR

Availability

Line Properties

Property Data Type Description

LineColor OLE_COLOR Sets or returns the drawing color.

LineStyle LineStyle Sets or returns the style color.

LineWeight Single Sets or returns the thickness of the line.

X1 Single Sets the horizontal coordinate of the line's starting point.

X2 Single Sets or returns the horizontal coordinate of the line's ending point.

Y1 Single Sets or returns the vertical coordinate of the line's starting point.

Y2 Single Sets or returns the vertical coordinate of the line's ending point.

ZOrder Integer 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

Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 297

Page 298: 83791925 Active Report 2 0 Standard Edition

Example

rptBooks.lnLeft.LineColor = vbYellowrptBooks.lnLeft.LineStyle = ddLSDot

LineStyle (Line)DescriptionLineStyle property sets or returns the pen style used to draw the line.

Data TypeLineStyle

Settings

Availability

Example

rptBooks.lnLeft.LineColor = vbYellowrptBooks.lnLeft.LineStyle = ddLSDotrptBooks.lnLeft.LineWeight = 3

LineWeight (Line)DescriptionLineWeight property sets or returns the width of the line in line weight units (1lw=10 twips).

Data TypeInteger

Availability

Run time Read / Write

LineStyle

Value Mnemonic Description

0 ddLSTransparent No line.

1 ddLSSolid

2 ddLSDash

3 ddLSDot

4 ddLSDashDot

5 ddLDDashDotDot

Design time Read / Write

Run time Read / Write

LineWeight

Design time Read / Write

ActiveReports 2.0 Standard User's Guide | 298

Page 299: 83791925 Active Report 2 0 Standard Edition

Example

rptBooks.lnLeft.LineColor = vbYellowrptBooks.lnLeft.LineStyle = ddLSDotrptBooks.lnLeft.LineWeight = 3

X1DescriptionSets or returns the horizontal coordinate of the line's starting point. The coordinates are relative to the section's top-left corner.

Data TypeSingle

Availability

Example

Private Sub Detail_Format()rptBooks.lnHz.X1 = 0rptBooks.lnHz.X2 = Me.PrintWidthrptBooks.lnHz.Y1 = 500rptBooks.lnHz.Y2 = 500

End Sub

X2DescriptionSets or returns the horizontal coordinate of the line's ending point. The coordinates are relative to the section's top-left corner.

Data TypeSingle

Availability

Example

Private Sub Detail_Format()rptBooks.lnHz.X1 = 0rptBooks.lnHz.X2 = Me.PrintWidth

Run time Read / Write

X1

Design time Read / Write

Run time Read / Write

X2

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 299

Page 300: 83791925 Active Report 2 0 Standard Edition

rptBooks.lnHz.Y1 = 500rptBooks.lnHz.Y2 = 500

End Sub

Y1DescriptionSets or returns the vertical coordinate of the line's starting point. The coordinates are relative to the section's top-left corner.

Data TypeSingle

Availability

Example

Private Sub Detail_Format()rptBooks.lnHz.X1 = 0rptBooks.lnHz.X2 = Me.PrintWidthrptBooks.lnHz.Y1 = 500rptBooks.lnHz.Y2 = 500

End Sub

Y2DescriptionSets or returns the vertical coordinate of the line's ending point. The coordinates are relative to the section's top-left corner.

Data TypeSingle

Availability

Example

Private Sub Detail_Format()rptBooks.lnHz.X1 = 0rptBooks.lnHz.X2 = Me.PrintWidthrptBooks.lnHz.Y1 = 500rptBooks.lnHz.Y2 = 500

End Sub

Y1

Design time Read / Write

Run time Read / Write

Y2

Design time Read / Write

Run time Read / Write

ZOrder (Line)

ActiveReports 2.0 Standard User's Guide | 300

Page 301: 83791925 Active Report 2 0 Standard Edition

ZOrder (Line)DescriptionThis 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 TypeNone

SyntaxSub Zorder(Position As Integer)

Parameters

Settings

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0txtEndNote.ZOrder 0txtDescription.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 descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.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

OLEOLE Object Properties

OLE Object Methods

Name Type Description

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

1 Setting the ZOrder to 1 sends the control to the back.

OLE Control

ActiveReports 2.0 Standard User's Guide | 301

Page 302: 83791925 Active Report 2 0 Standard Edition

OLE Object Properties

BackColor (OLE)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

BackStyle (OLE)Description

OLE Object Properties

Property Data Type Description

BackColor OLE_COLOR Sets or returns the background color of the object. This property is ignored if the BackStyle is set to transparent.

BackStyle Integer Sets or returns the transparency of the object.

Class String Sets or returns the ProgID of the OLE object.

Object Object Sets or returns an OLE object that is bound to the control.

PictureAlignment PictureAlignment Sets or returns the alignment for the OLE object.

SizeMode SizeMode Sets or Returns the size mode for the OLE object.

VerbCount Long Returns the number of verbs available for the ole object.

ZOrder Integer 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.

BackColor (OLE)

Design time Read / Write

Run time Read / Write

BackStyle (OLE)

ActiveReports 2.0 Standard User's Guide | 302

Page 303: 83791925 Active Report 2 0 Standard Edition

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 TypeBackStyle

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

ClassDescriptionClass property sets or returns the ProgID of the OLE object.

Data TypeString

Availability

ExampleOLE1.Class = "Word.Document.8"

Object (OLE)DescriptionObject 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 TypeObject

Design time Read / Write

Run time Read / Write

Class

Design time Read / Write

Run time Read / Write

Object

ActiveReports 2.0 Standard User's Guide | 303

Page 304: 83791925 Active Report 2 0 Standard Edition

Availability

Example

Private Sub ActiveReport_ReportStart()lblCaption.Caption = OLE1.object.Name

End Sub

PictureAlignment (OLE)DescriptionSets 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 TypePictureAlignment

Settings

Availability

Example

Private Sub ActiveReport_ReportStart()'Centers the OLE objectOLE1.PictureAlignment = ddPACenter' Stretch the OLE object to fill the entire containerOLE1.SizeMode = ddSMStretch

End Sub

SizeMode (OLE)DescriptionDetermines how the OLE object will be sized inside the OLE container.

Data TypeSizeMode

Run time Read

PictureAlignment

Value Mnemonic Description

0 ddPATopLeft Aligns the image to the top and left.

1 ddPATopRight Aligns the image to the top and right.

2 ddPACenter Aligns the image to the center.

3 ddPABottomLeft Aligns the image to the bottom and left.

4 ddPABottomRight Aligns the image to the bottom and right.

Design time Read / Write

Run time Read / Write

SizeMode

ActiveReports 2.0 Standard User's Guide | 304

Page 305: 83791925 Active Report 2 0 Standard Edition

Settings

Availability

Example

Private Sub ActiveReport_ReportStart()'Centers the OLE objectOLE1.PictureAlignment = ddPACenter'Stretch the OLE object to fill the entire containerOLE1.SizeMode = ddSMStretch

End Sub

VerbCountDescriptionPopulates the verbs array and returns a verb count available for the OLE object. VerbCount must be called before accessing the other GetVerb methods.

Data TypeLong

Availability

Example

Private Sub CheckVerbs()Dim sVName As StringDim vCnt, iOLE1.CreateEmbedded "c:\test.rtf"vCnt = OLE1.VerbCountFor i = 0 To vCnt - 1

OLE1.GetVerbName i, sVNameDebug.Print "VerbName = " & sVNameDebug.Print "VerbID = " & OLE1.GetVerbID(i)

NextOLE1.DoVerb 0

End Sub

ZOrder (OLE)

Value Mnemonic Description

0 DdSMClip (Default) Clips the image.

1 ddSMStretch Stretches the image to fill OLE Container.

2 ddSMZoom Zooms in on the image.

Design time Read / Write

Run time Read / Write

VerbCount

Design time Read / Write

Run time Read / Write

ZOrder (OLE)

ActiveReports 2.0 Standard User's Guide | 305

Page 306: 83791925 Active Report 2 0 Standard Edition

DescriptionThis 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 TypeNone

SyntaxSub Zorder(Position As Integer)

Parameters

Settings

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0txtEndNote.ZOrder 0txtDescription.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 descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.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

Name Type Description

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

1 Setting the ZOrder to 1 sends the control to the back.

OLE Object Methods

Method Description

CreateEmbedded Created an embedded OLE object from a source document. Sub CreateEmbedded(FileName As String)

DoVerb Performs a specified action for the OLE object.Sub DoVerb(ID As Long)

GetUserType Returns the name of the specified OLE object's user type. Function

ActiveReports 2.0 Standard User's Guide | 306

Page 307: 83791925 Active Report 2 0 Standard Edition

CreateEmbeddedDescriptionCreated an embedded OLE object from a source document.

SyntaxSub CreateEmbedded(FileName As String)

Parameters

RemarksTo 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 reportOLE1.Class = "Word.Document.8"OLE1.CreateEmbedded App.Path & "\TestDocument.Doc"

End Sub

DoVerbDescriptionOpens an OLE object so an operation, such as edit or replace, can be performed.

SyntaxSub DoVerb(ID As Long)

Parameters

Example

GetUserType(Type As Integer) As String

GetVerbID Returns the ID for the specified verb.Function GetVerbID(Index As Long) As Long

GetVerbName Returns the name of the specified verb. Sub GetVerbName(Index As Long, Name As String)

InsertObject Inserts an object into the OLE control.Sub InsertObject()

CreateEmbedded

Name Type Description

FileName String The name of the source document used as a template to create the embedded object.

DoVerb

Name Type Description

ID Long The ID number for the verb to activate

ActiveReports 2.0 Standard User's Guide | 307

Page 308: 83791925 Active Report 2 0 Standard Edition

Private Sub CheckVerbs()Dim sVName As StringDim vCnt, i>OLE1.CreateEmbedded "c:\test.rtf"vCnt = OLE1.VerbCountFor i = 0 To vCnt - 1

OLE1.GetVerbName i, sVNameDebug.Print "VerbName = " & sVNameDebug.Print "VerbID = " & OLE1.GetVerbID(i)

NextOLE1.DoVerb 0

End Sub

GetUserTypeDescriptionReturns the name of the specified OLE object's user type.

SyntaxSub GetUserType(Type As Integer)As String

Parameters

GetVerbIDDescriptionReturns the ID for the specified verb. Note: VerbCount must be called before using GetVerbID.

SyntaxFunction GetVerbID(Index As Long) As Long

Parameters

Example

Private Sub CheckVerbs()Dim sVName As StringDim vCnt, iOLE1.CreateEmbedded "c:\test.rtf"vCnt = OLE1.VerbCountFor i = 0 To vCnt - 1

OLE1.GetVerbName i, sVNameDebug.Print "VerbName = " & sVNameDebug.Print "VerbID = " & OLE1.GetVerbID(i)

NextOLE1.DoVerb 0

End Sub

GetUserType

Name Type Description

Type Integer Integer value specifying the type to return the name for.

GetVerbID

Name Type Description

Index Long Integer value indicating the index number of the verb.

ActiveReports 2.0 Standard User's Guide | 308

Page 309: 83791925 Active Report 2 0 Standard Edition

GetVerbNameDescriptionReturns the name of the specified verb. Note: VerbCount must be called before using GetVerbName.

SyntaxSub GetVerbName(Index As Long, Name As String)

Parameters

Example

Private Sub CheckVerbs()Dim sVName As StringDim vCnt, iOLE1.CreateEmbedded "c:\test.rtf"vCnt = OLE1.VerbCountFor i = 0 To vCnt - 1

OLE1.GetVerbName i, sVNameDebug.Print "VerbName = " & sVNameDebug.Print "VerbID = " & OLE1.GetVerbID(i)

NextOLE1.DoVerb 0

End Sub

InsertObjectDescriptionCauses the InsertObject dialog box to pop up so that the end user can insert an object into the OLE control.

SyntaxSub InsertOjbect()

Example

Private Sub Detail_Format()Call OLE1.InsertObject

End Sub

PageBreak Control Properties

GetVerbName

Name Type Description

Index Long Integer value indicating the index number of the verb.

Name String String value indicating the name of the verb.

InsertObject

PageBreak Control Properties

ActiveReports 2.0 Standard User's Guide | 309

Page 310: 83791925 Active Report 2 0 Standard Edition

Enabled (PageBreak)DescriptionSets or returns whether or not the PageBreak control will be activated on the current page.

DataTypeBoolean

Availability

Example

Private Sub PageHeader_Format()Static x As Longx = x + 1'Disables the page break for all but the first pageIf x > 1 Then

Me.PageBreak1.Enabled = FalseEnd If

End Sub

RTFRTF Text Control Properties

RTF Text Control Methods

RTF Text Control Properties

Property Data Type Description

Enabled Boolean Sets or returns whether or not the page break is activated

Enabled

Design time Read / Write

Run time Read / Write

RTF Text Control

RTF Text Control Properties

Property Data Type Description

BackStyle BackStyle Sets or returns the transparency for the RichEdit control.

BulletIndent Integer Returns or sets the amount of indent used in a RichEdit control when SelBullet is set to True

CanGrow Boolean Determines whether the rich edit print area grows as needed to contain the text.

CanShrink Boolean Determines whether the rich edit print area shrinks to fit the contents of the RichEdit control.

GetTab Long Returns the tab position at the specified index.

MaxLength Long Sets the maximum number of characters

ActiveReports 2.0 Standard User's Guide | 310

Page 311: 83791925 Active Report 2 0 Standard Edition

BackStyle (RTF)

allowed in the control.

Multiline Boolean Determines whether the rich edit prints Multiline text or single line.

SelAlignment SelAlignmentConstants Sets or returns the alignment of the current selection.

SelBold Variant Sets or returns the bold style setting of the current selection.

SelBullet Variant Sets or returns the bulleted list style of the current selection.

SelCharOffset Variant Sets or returns the character offset from the base line.

SelColor OLE_COLOR Sets or returns the text color of the current selection.

SelFontName String Sets or returns the font of the current selection.

SelFontSize Long Sets or returns the point size of the current selection.

SelHangingIndent Long Sets or returns the first line left margin within the current selection.

SelIndent Long Sets or returns the left margin of the current selection.

SelItalic Variant Sets or returns the Italic style of the current selection.

SelLength Long Sets or returns the number of characters in the current selection.

SelProtected Variant Determines whether the current selection can be modified.

SelRightIndent Long Sets or returns the right margin of the current selection.

SelStart Long Sets or returns the beginning position of the current selection.

SelStrikeThru Variant Sets or returns the strikethru style setting of the current selection.

SelTabCount Long Sets or returns the number of tab stop position within the current selection.

SelTabs Variant Sets or returns the tab positions within the current selection.

SelText String Sets or returns the string of selected text.

SelTextBackColor OLE_COLOR Sets or returns the background color of the selected text.

SelUnderline Variant Sets or returns the underline style of the current selection.

Tag String Sets or returns a user defined value associated with the control.

Text String Returns the contents of the RichEdit control as a text string

TextRTF String Sets or returns the RTF text of the RichEdit control.

ZOrder Integer 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

ActiveReports 2.0 Standard User's Guide | 311

Page 312: 83791925 Active Report 2 0 Standard Edition

DescriptionDetermines 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 TypeBackStyle

Availability

Example

' Sets the Richedit background to redPrivate Sub Detail_Format()

If setColor = true then RichEdit1.BackStyle = ddBKNormalRichEdit1.BackColor = vbRed

ElseRichEdit1.BackStyle = ddBKTransparent

End IfEnd Sub

BulletIndentDescriptionReturns or sets the amount of indent used in a RichEdit control when SelBullet is set to True.

Data TypeInteger

Availability

CanGrow (RTF)DescriptionDetermines 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 TypeBoolean

Design time Read/Write

Run time Read / Write

BulletIndent

Design time Read / Write

Run time Read / Write

CanGrow

ActiveReports 2.0 Standard User's Guide | 312

Page 313: 83791925 Active Report 2 0 Standard Edition

Availability

Example

Me.rtfRecalls.CanGrow = FalseMe.rtfEcalls.CanShrink = False

CanShrink (RTF)DescriptionDetermines whether the rich edit print area shrinks to fit the contents of the RichEdit control.

Data TypeBoolean

Availability

Example

Me.rtfRecalls.CanGrow = FalseMe.rtfEcalls.CanShrink = False

GetTabDescriptionGetTab property returns the tab position setting at the specified index.

Data TypeLong

Availability

MaxLengthDescriptionSpecifies the maximum number of characters a user can enter in the control. The default for

Design time Read / Write

Run time Read / Write

CanShrink

Design time Read / Write

Run time Read / Write

GetTab

Design time N/A

Run time Read-Only

MaxLength

ActiveReports 2.0 Standard User's Guide | 313

Page 314: 83791925 Active Report 2 0 Standard Edition

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 TypeLong

Availability

Example

' Set the RTF MaxLength and Load the lettertxtLetter.MaxLength = 2000txtLetter.Text = _ dcRptData.RecordSet.Fields("LetterText").Value

Multiline (RTF)DescriptionDetermines whether the RichEdit prints multiple lines or single line. When set to False the control is limited to single lines.

Data TypeBoolean

Availability

ExamplertfLetter.Multiline = True

SelAlignmentDescriptionReturns or sets the selected text alignment. A value of 3 (rtfAlignmentNone) indicates that the selection spans paragraphs with different alignment settings.

Data TypeSelAlignmentConstantsselAlignmentConstants

Availability

Design time Read / Write

Run time Read / Write

Multiline

Design time Read / Write

Run time Read / Write

SelAlignment

Value Mnemonic Description

0 rtfLeft Align left

1 rtfRight Align right

2 rtfCenter Align center

3 rtfAlignmentNone None

ActiveReports 2.0 Standard User's Guide | 314

Page 315: 83791925 Active Report 2 0 Standard Edition

ExamplertfLetter.SelAlignment = rtfLeft

SelBoldDescriptionSets or returns the font bold style of the currently selected text. A null value indicates that the current selection has mixed bold styles.

Data TypeVariant

Availability

ExamplertfLetter.SelBold = True

SelBulletDescriptionSets 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 TypeVariant

Availability

Example

rtfLetter.SelText = "Unit Price" & vbCRLF & "Cost"rtfLetter.SelBullet = True

SelCharOffsetDescriptionSets 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;

Design time N/A

Run time Read / Write

SelBold

Design time N/A

Run time Read / Write

SelBullet

Design time N/A

Run time Read / Write

SelCharOffset

ActiveReports 2.0 Standard User's Guide | 315

Page 316: 83791925 Active Report 2 0 Standard Edition

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 TypeVariant

Availability

Example

rtfLetter.SelText = "TM"rtfLetter.SelCharOffset = 10

SelColorDescriptionSets 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 TypeVariant

Availability

Example

rtfLetter.SelColor = vbRedrtfLetter.SelText = "$2000.00"rtfLetter.SelColor = vbBlack

SelFontNameDescriptionSets or returns the font used to print the current text selection. Returns Null if the selection font is mixed.

Data TypeVariant

Availability

Example

Design time N/A

Run time Read / Write

SelColor

Run time Read / Write

SelFontName

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 316

Page 317: 83791925 Active Report 2 0 Standard Edition

rtfLetter.SelFontName = "Arial"rtfLetter.SelFontSize = 10rtfLetter.SelBold = True

SelFontSizeDescriptionSets 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 TypeVariant

Availability

Example

rtfLetter.SelFontName = "Arial"rtfLetter.SelFontSize = 10 * 20 ' 10 ptsrtfLetter.SelBold = True

SelHangingIndentDescriptionSets 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 TypeLong

Availability

Example

rtfLetter.SelIndent = 720 ' ½ inch in twipsrtfLetter.SelHangingIndent = 1440 ' 1 inch in twipsrtfLetter.SelRightIndent = 720

SelIndentDescriptionSets or returns the left margin of the selected paragraph.

SelFontSize

Run time Read / Write

SelHangingIndent

Run time Read / Write

SelIndent

ActiveReports 2.0 Standard User's Guide | 317

Page 318: 83791925 Active Report 2 0 Standard Edition

Data TypeLong

Availability

Example

rtfLetter.SelIndent = 720 ' ½ inch in twipsrtfLetter.SelHangingIndent = 1440 ' 1 inch in twipsrtfLetter.SelRightIndent = 720

SelItalicDescriptionSets or returns the font Italic style of the currently selected text. A null value indicates that the current selection has mixed italic styles.

Data TypeVariant

Availability

ExamplertfLetter.SelItalic = True

SelLengthDescriptionSets or returns the length (number of characters) of the current selection.

Data TypePositive Long or 0

Availability

Example

rtfLetter.SelStart = 10rtfLetter.SelLength = Len(sMsg)rtfLetter.SelBold = True

Run time Read / Write

SelItalic

Run time Read / Write

SelLength

Run time Read / Write

SelProtected

ActiveReports 2.0 Standard User's Guide | 318

Page 319: 83791925 Active Report 2 0 Standard Edition

SelProtectedDescriptionDetermines 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 TypeVariant

Availability

Example

rtfLetter.SelLength = Len(sComapnyname)rtfLetter.SelProtected = True

SelRightIndentDescriptionSets or returns the distance from the right edge of the rich edit control and the right edge of the selected text.

Data TypeLong

Availability

Example

rtfLetter.SelIndent = 720 ' ½ inch in twipsrtfLetter.SelHangingIndent = 1440 ' 1 inch in twipsrtfLetter.SelRightIndent = 720

SelStartDescriptionSets 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 TypeLong

Availability

Run time Read / Write

SelRightIndent

Design time N/A

Run time Read / Write

SelStart

ActiveReports 2.0 Standard User's Guide | 319

Page 320: 83791925 Active Report 2 0 Standard Edition

Example

rtfLetter.SelStart = 10rtfLetter.SelLength = Len(sMsg)rtfLetter.SelBold = True

SelStrikeThruDescriptionSets or returns the font strikethru style of the currently selected text. A Null value indicates that the current selection has mixed strikethru styles.

Data TypeVariant

Availability

ExamplertfLetter.SelStrikeThru = True

SelTabCountDescriptionReturns the number of tab stops within the current selection.

Data TypeLong

Availability

SelTabsDescriptionReturns the absolute tab position at the specified index.

Data TypeInteger

Availability

Design time N/A

Run time Read / Write

SelStrikeThru

Design time N/A

Run time Read / Write

SelTabCount

Run time Read / Write

SelTabs

ActiveReports 2.0 Standard User's Guide | 320

Page 321: 83791925 Active Report 2 0 Standard Edition

Example

Dim arrTabs(5) As IntegerarrTabs(0) = 5arrTabs(1) = 10arrTabs(2) = 15arrTabs(3) = 20arrTabs(4) = 25arrTabs(5) = 30rtfLetter.SelTabs = arrTabs

SelTextDescriptionSets or returns the string of the current selected text. Returns an empty string if no text is selected.

Data TypeString

Availability

Example

rtfLetter.SelColor = vbRedrtfLetter.SelText = "$2000.00"rtfLetter.SelColor = vbBlack

SelTextBackColorDescriptionSets or returns the background color of the selected text. Returns Null when the selection background color is mixed.

Data TypeVariant

Availability

Example

rtf.SetTextBackcolor = vbRedrtf.SelText = "ActiveReports"

Run time Read / Write

SelText

Run time Read / Write

SelTextBackColor

Run time Read / Write

SelUnderline

ActiveReports 2.0 Standard User's Guide | 321

Page 322: 83791925 Active Report 2 0 Standard Edition

SelUnderlineDescriptionSets or returns the font underline style of the currently selected text. A Null value indicates that the current selection has mixed underline styles.

Data TypeVariant

Availability

ExamplertfLetter.SelUnderline = False

Tag (RTF)DescriptionSets or returns a user defined value associated with the specified RTF control.

Data TypeString

Availability

Text (RTF)DescriptionSets or returns the RichEdit control's contents as a text string.

Data TypeString

Availability

ExampleMe.RichEdit1.Text = "RichEdit Text"

TextRTF

Run time Read / Write

Tag

Design time Read / Write

Run time Read / Write

Text

Design time Read / Write

Run time Read / Write

TextRTF

ActiveReports 2.0 Standard User's Guide | 322

Page 323: 83791925 Active Report 2 0 Standard Edition

DescriptionSets or returns the RTF contents of the RichEdit control as a text string.

Data TypeString

Availability

ExampleRichEdit1.TextRTF = "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}\viewkind4\uc1\pard\lang1033\f0\fs17 Rich Text\par }"

ZOrder (RTF)DescriptionThis 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 TypeNone

SyntaxSub Zorder(Position As Integer)

Parameters

Settings

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0txtEndNote.ZOrder 0txtDescription.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 descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

Design time N/A

Run time Read / Write

ZOrder (RTF)

Name Type Description

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

1 Setting the ZOrder to 1 sends the control to the back.

ActiveReports 2.0 Standard User's Guide | 323

Page 324: 83791925 Active Report 2 0 Standard Edition

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.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

Clear (RTF)DescriptionClear method deletes the current selection.

Return TypeNone

SyntaxSub Clear()

ParametersNone

Copy

RTF Text Control Methods

Method Description

Clear Clears the current selection. Sub Clear()

Copy Copies the current selection to the clipboard.Sub Copy()

Cut Cuts the current selection to the clipboard. Sub Cut()

DeleteField Deletes the field at the specified index.Sub DeleteField(szFieldName As String, nPos As Long, bDeleteAll As Boolean) As Boolean

Find 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

InsertField Inserts a merge field at the specified position.Sub InsertField(szFieldName As String, nPos As Long) As Boolean

LoadFile Loads the contents of a file into the control. Sub LoadFile(szPathName As String, isFileType As LoadSaveConstants)

Paste Pastes the contents of the clipboard into the control at the current position.Sub Paste()

ReplaceField Replaces a merge field with a value. Sub ReplaceField(bstrField As String, bstrValue As String)

SaveFile Stores the contents of the control to the specified file.Sub SaveFile(szPathName As String, isFileType As LoadSaveConstants)

SelectField Selects a specified field in the RTF Content.Function SelectField(FieldName As String, Index As Long) As Boolean

Clear

Copy

ActiveReports 2.0 Standard User's Guide | 324

Page 325: 83791925 Active Report 2 0 Standard Edition

DescriptionCopy method copies the current selection to the clipboard. The clipboard contents are set to RTF.

Return TypeNone

SyntaxSub Copy()

ParametersNone

CutDescriptionCut method cuts (copies then deletes) the current selection to the clipboard. The clipboard contents are set to RTF.

Return TypeNone

SyntaxSub Cut()

ParametersNone

DeleteFieldDescriptionDeleteField 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 TypeBoolean

SyntaxSub DeleteField(szFieldName As String, nPos As Long, bDeleteAll As Boolean) As Boolean

Parameters

Cut

DeleteField

Name Type Description

szFieldName String Specifies the field name to be deleted.

NPos Long Specifies the position within the RTF stream where the field is located. A –1 value deletes all occurrences of the field within the stream.

bDeleteAll Boolean When set to True it deletes all occurrences of the field within the stream.

Find

ActiveReports 2.0 Standard User's Guide | 325

Page 326: 83791925 Active Report 2 0 Standard Edition

Find (RTF)DescriptionFind 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.

SyntaxFunction Find(szText As String, nStart As Long, nEnd As Long, fcType As FindConstants, pnEndAs Long) As Long

Parameters

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

SyntaxFunction InsertField(szFieldName As String, nPos As Long)As Boolean

Parameters

Example

Private Sub ActiveReport_ReportStart()' Set up the letter merge fieldsrtfLetter.InsertField("CustomerName", 0)rtfLetter.SetText = vbCRLFrtLetter.InsertField("Address", rtfLetter.SelStart)

End Sub

LoadFile

Name Type Description

szText String Text string to search for.

nStart Long Starting position of the search range, -1 to start at the beginning of the RTF text stream.

nEnd Long End position of the search range, -1 to stop at the end of the RTF text stream.

fcType FindConstants Type of search, whole word, case sensitive, forward or backward search.

pnEnd Long Return value, position of the text string end within the stream.

InsertField

Name Type Description

szFieldName String Name of the field

nPos Long Field position within the text stream

LoadFile

ActiveReports 2.0 Standard User's Guide | 326

Page 327: 83791925 Active Report 2 0 Standard Edition

DescriptionLoadFile method loads an ASCII or RTF formatted text file into the control.

Return TypeNone

SyntaxSub LoadFile(szFileName As String, isFileType As LoadSaveConstants)

Parameters

Example

Private Sub ActiveReport_ReportStart()' Load formatted letter from filertfLetter.Load App.Path & "\LetterTemplate.RTF", rtfRTF

End Sub

PasteDescriptionPaste method pastes contents of the clipboard into the RTF stream at the current position.

Return TypeNone

SyntaxSub Paste()

ParametersNone

ReplaceFieldDescriptionReplaceField 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 TypeNone

SyntaxSub ReplaceField(bstrFiel As String, bstrValue As String)

Parameters

Name Type Description

FileName String Name of the input file.

FileType LoadSaveConstants File format (RTF or ASCII)

Paste

ReplaceField

Name Type Description

ActiveReports 2.0 Standard User's Guide | 327

Page 328: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub Detail_Format()' Merge the letter fields in the RTF controlrtfLetter.ReplaceField("CustomerName", txtCustomer.Text)

End Sub

SaveFileDescriptionSaveFile method saves the RTF text stream to the specified file name in ASCII or RTF format.

Return TypeNone

SyntaxSub SaveFile(szPathName As String, isFileType As LoadSaveConstants)

Parameters

Example

Private Sub Detail_Format()rtfLetter.ReplaceField "CustomerName", _

dcRptData.Recordset.Fields("CustomerName").Value' Replace merge fields' Save the result to a filertfLetter.Save App.Path & "\" & _

txtCustomerName.Text & ".RTF", 0

End Sub

SelectFieldDescriptionSelects a specified field in the RTF control.

Return TypeBoolean

SyntaxFunction SelectField(FieldName As String, Index As Long) As Boolean

Parameters

bstrField String The name of the field to be replaced.

bstrFieldValue String The value used to replace the field name.

SaveFile

Name Type Description

szPathName String Name of the output file.

IsFileType LoadSaveConstants File format ASCII or RTF

SelectField

ActiveReports 2.0 Standard User's Guide | 328

Page 329: 83791925 Active Report 2 0 Standard Edition

Shape Properties

BackColor (Shape)DescriptionSets 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 TypeOLE_COLOR

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

BackStyle (Shape)

Name Type Description

FieldName String Name of the field to select

Index Long Index for the specified field.

Shape Control Properties

Property Data Type Description

BackColor OLE_COLOR Sets or returns the background color of the object. This property is ignored if the BackStyle is set to transparent.

BackStyle BackStyle Sets or returns the transparency of the object.

LineColor OLE_COLOR Sets or returns the line color of the border around the object.

LineStyle LineStyle Sets or returns the line style of the border around the object.

LineWeight Single Sets or returns the line thickness of the border around the object.

Shape ShapeType Sets or returns the shape type, ellipse, rectangle or rounded rectangle.

BackColor (Shape)

Design time Read / Write

Run time Read / Write

BackStyle (Shape)

ActiveReports 2.0 Standard User's Guide | 329

Page 330: 83791925 Active Report 2 0 Standard Edition

DescriptionSets 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 TypeBackStyle

Availability

Example

' Highlight the outstanding sales with a red backgroundPrivate Sub Detail_Format()

If txtSales.DataValue > 10000 ThentxtSales.BackStyle = ddBKNormaltxtSales.BackColor = vbRed

ElsetxtSales.BackStyle = ddBKTransparent

End IfEnd Sub

LineColor (Shape)DescriptionLineColor property sets or returns the pen color used to draw the shape's border.

Data TypeOLE_COLOR

Availability

Example

Private Sub Detail_Format()Shape1.Shape = ddSHRoundRectShape1.LineColor = vbGreenShape1.LineStyle = ddLSDashDotDotShape1.LineWeight = 4

End Sub

Design time Read / Write

Run time Read / Write

LineColor

Design time Read / Write

Run time Read / Write

LineStyle

ActiveReports 2.0 Standard User's Guide | 330

Page 331: 83791925 Active Report 2 0 Standard Edition

LineStyle (Shape)DescriptionLineStyle property sets or returns the pen style used to draw the shape's border.

Data TypeLineStyle

Settings

Availability

Example

Private Sub Detail_Format()Shape1.Shape = ddSHRoundRectShape1.LineColor = vbGreenShape1.LineStyle = ddLSDashDotDotShape1.LineWeight = 4

End Sub

LineWeight (Shape)DescriptionLineWeight property sets or returns the width of the shape's border in line weight units 1lw = 10 twips.

Data TypeInteger

Availability

Example

Private Sub Detail_Format()Shape1.Shape = ddSHRoundRectShape1.LineColor = vbGreenShape1.LineStyle = ddLSDashDotDot

Value Mnemonic Description

0 ddLSTransparent No line

1 ddLSSolid

2 ddLSDash

3 ddLSDot

4 ddLSDashDot

5 ddLDDashDotDot

Design time Read / Write

Run time Read / Write

LineWeight

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 331

Page 332: 83791925 Active Report 2 0 Standard Edition

Shape1.LineWeight = 4End Sub

ShapeDescriptionShape property determines the type of the shape to draw using the control.

Data TypeShapeType

Settings

Availability

Example

Private Sub Detail_Format()Shape1.Shape = ddSHRoundRectShape1.LineColor = vbGreenShape1.LineStyle = ddLSDashDotDotShape1.LineWeight = 4

End Sub

Subreport Properties

Shape

Value Mnemonic Description

0 ddSHRectangle Rectangular shape

1 ddSHEllipse Elliptical or circular shape

2 ddSHRoundRectangle Rectangular shape with rounded corners

Design time Read / Write

Run time Read / Write

SubReport Control Properties

Property Data Type Description

CanGrow Boolean Determines whether the subreport print area grows as needed.

CanShrink Boolean Determines whether the subreport's print area shrinks to fit its contents.

DataField String Sets or returns the name of the bound appended child recordset.

Object Object Sets or returns a reference to the ActiveReport object to be used as a subreport.

ReportName String Sets or returns the name of the report object which is the source of the subreport.

ZOrder Integer 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 | 332

Page 333: 83791925 Active Report 2 0 Standard Edition

CanGrow (SubReport)DescriptionDetermines whether the subreport print area grows as needed. When the subreport grows, the controls directly below it will be pushed downwards.

Data TypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()'Set the subreport control's object to the sub reportSet SubRpt.object = New rptOrdersSubRpt.CanGrow = FalseSubRpt.CanShrink = False

End Sub

CanShrink (SubReport)DescriptionDetermines whether the subreport's print area shrinks to fit its contents.

Data TypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()'Set the subreport control's object to the sub reportSet SubRpt.object = New rptOrdersSubRpt.CanGrow = FalseSubRpt.CanShrink = False

End Sub

DataField (SubReport)Description

CanGrow

Design time Read / Write

Run time Read / Write

CanShrink

Design time Read / Write

Run time Read / Write

DataField

ActiveReports 2.0 Standard User's Guide | 333

Page 334: 83791925 Active Report 2 0 Standard Edition

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 TypeString

Availability

Example

Private Sub ActiveReport_DataInitialize()'Connects the report's datacontrol to the databasede.cnnNWind.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data

Source=" & GetVBPath() & "\NWIND.MDB;Persist Security Info=False"de.rsCustomers.OpenSet dc.Recordset = de.rsCustomersSet 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 recordsetsrpt.DataField = "Orders"

End Sub

Object (SubReport)DescriptionSets 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 TypeObject

Availability

Example

Dim i_CID As StringPrivate Sub ActiveReport_FetchData(EOF As Boolean)

'Gets the current records customer IDi_CID = me.DataControl1.Recordset!customerID

End Sub Private Sub ActiveReport_ReportEnd()

Design time Read / Write

Run time Read / Write

Object

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 334

Page 335: 83791925 Active Report 2 0 Standard Edition

'Set the subreport control's object to nothingUnload SubRpt.objectSet SubRpt.object = Nothing

End Sub Private Sub ActiveReport_ReportStart()

'Set the subreport control's object to the sub reportSet SubRpt.object = New rptOrders

End Sub Private Sub Detail_Format()

'Sets the subreport's recordset for the new customer IDSubRpt.object.DataControl1.Source = "Select * from orders where customerid

= '" & i_CID & "'"End Sub

ReportNameDescriptionSets or returns the name of the linked report object.

Data TypeString

Availability

Example

Private Sub ActiveReport_ReportStart()'Set the subreport control's object to the sub reportSet SubRpt.object = New rptOrdersSubRpt.CanGrow = FalseSubRpt.CanShrink = FalseSubRpt.ReportName = "Customer Orders"

End Sub

ZOrder (SubReport)DescriptionThis 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 TypeNone

SyntaxSub Zorder(Position As Integer)

Parameters

ReportName

Design time Read / Write

Run time Read / Write

ZOrder (SubReport)

Name Type Description

ActiveReports 2.0 Standard User's Guide | 335

Page 336: 83791925 Active Report 2 0 Standard Edition

Settings

Example

Private Sub ActiveReport_ReportStart()txtHeadNote.ZOrder 0txtEndNote.ZOrder 0txtDescription.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 descriptontxtHeadNote.Top = txtDescription.ToptxtHeadNote.Left = txtDescription.LefttxtHeadNote.Width = txtDescription.Width

' Positions the end note at the bottom' of the description and brings it in' front of the descriptontxtEndNote.Top = (txtDescription.Top _

+ txtDescription.Height) - txtEndNote.HeighttxtEndNote.Left = txtDescription.LefttxtEndNote.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 ControlsADO

DAO

RDO

XML

ADOADO Data Control Properties

ADO Data Control Methods

ADO Data Control Properties

Position Integer Sets the position, front or back, for the control.

Value Description

0 Setting the ZOrder to 0 brings the control to the front.

1 Setting the ZOrder to 1 sends the control to the back.

Data Controls

ADO

ADO Data Control Properties

Property Data Type Description

ActiveReports 2.0 Standard User's Guide | 336

Page 337: 83791925 Active Report 2 0 Standard Edition

CommandTimeOutDescriptionSets or returns the period of time (in seconds) to wait for a command to execute before returning a timeout error.

Data TypeLong

Availability

Example

CommandTimeOut Long Sets or returns the period of time (in seconds) to wait for a command to execute before returning a timeout error.

Connection Object Sets or returns the ADO connection object associated with the data control.

ConnectionString String Sets or returns the string of parameters used to open the connection.

ConnectionTimeOut Long Sets or returns the period of time (in seconds) to wait for a connection before terminating and returning an error.

CursorLocation ADOCursorLocation Sets or returns the location of the cursor that ActiveReports should created when creating the recordset

CursorType ADOCursorType Specifies the type of cursor that should be used when opening the recordset.

DataSourceName String Sets or returns the data source name for the connection.

DefaultDatabase String Sets or returns the name of the default database to use from the provider.

LockType Long Sets or returns the type of record locking to be used while reading from or writing to the data source.

MaxRows Long Sets or returns the number of records to return from the record set for processing in the detail section.

NRecords Long Returns the number of records in the current recordset.

Password String Sets or returns the data source password.

Provider String 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.

RecordSet Object Sets or returns a reference to the recordset object.

Source String Sets or returns the SQL source or table name for the recordset object.

UserID String Sets the user id used to open the data source.

CommandTimeOut

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 337

Page 338: 83791925 Active Report 2 0 Standard Edition

Private Sub CreateReport()Dim rpt As New rptTemplateDim ctl As Object' Create an ADO Data data source controlWith rpt.Sections("Detail").Controls

Set ctl = .Add("DDActiveReports2.DataControl")End Withctl.Provider = "MSDASQL"ctl.ConnectionString = "driver={SQL Server};" & _ctl.Source = "SELECT * FROM RoySched"ctl.ConnectionTimeOut = 20ctl.CommandTimeout = 20ctl.MaxRows = 20ctl.LockType = 0 ' ReadOnly' Create Additional Controls' Run and Preview the report outputrpt.Show

End Sub

Connection (ADO)DescriptionSets 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 TypeObject

Availability

Example

Dim rpt As New rptSalesSet rpt.dc.Connection = cnnAppConnectionRptSales.Show

ConnectionStringDescriptionSets or returns the string of parameters used to open the connection. ADO uses the following connection parameters:

Connection

Run time Read / Write

ConnectionString

Argument Description

Provider= Specifies the name of a provider to use for the connection.

Data Source= Specifies the name of a data source for the connection For example, a SQL Server database registered as an ODBC data source.

User ID= Specifies the user name to use when opening the connection.

Password= Specifies the password to use when opening the connection.

File Name= Specifies the name of a provider-specific file, such as a persisted data source object, containing preset connection information.

Remote Provider= 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 | 338

Page 339: 83791925 Active Report 2 0 Standard Edition

Data TypeString

Availability

Example

Private Sub CreateReport()Dim rpt As New rptTemplateDim ctl As Object' Create an ADO data source controlWith rpt.Sections("Detail")

Set ctl = .CreateControl("DDActiveReports2.DataControl")End Withctl.Provider = "MSDASQL"ctl.ConnectionString = "driver={SQL Server};" & _

"Server=local;uid=sa;pwd=;database=pubs"ctl.Source = "SELECT * FROM RoySched"ctl.ConnectionTimeOut = 20ctl.CommandTimeout = 20ctl.MaxRows = 20ctl.LockType = 0 ' ReadOnly' Create Additional Controls' Run and Preview the report outputrpt.Show

End Sub

ConnectionTimeOutDescriptionSets or returns the period of time (in seconds) to wait for a connection before terminating and returning an error.

Data TypeLong

Availability

Example

Private Sub CreateReport()Dim rpt As New rptTemplateDim ctl As Object' Create an ADO data source controlWith rpt.Sections("Detail").Controls

Set ctl = .Add("DDActiveReports2.DataControl")End Withctl.Provider = "MSDASQL"ctl.ConnectionString = "driver={SQL Server};" & _

"Server=local;uid=sa;pwd=;database=pubs"

Remote Server= Specifies the pathname of the sever to use when opening a client-side connection. (Remote Data Service only.)

Design time Read / Write

Run time Read / Write

ConnectionTimeOut

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 339

Page 340: 83791925 Active Report 2 0 Standard Edition

ctl.Source = "SELECT * FROM RoySched"ctl.CommandTimeout = 20ctl.MaxRows = 20ctl.LockType = 0 ' ReadOnly' Create Additional Controls' Run and Preview the report outputrpt.Show

End Sub

CursorLocationDescriptionSets 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 TypeADOCursorLocation

Settings

Availability

RemarksThe CursorLocation is read/write when the recordset is closed and read-only when the recordset is open.

CursorTypeDescriptionThe CursorType property specifies the type of cursor that should be used when opening the recordset.

Data TypeADOCursorType

Settings

CursorLocation

Value Mnemonic Description

2 ddADOUseServer Default - Creates a server-side cursor.

3 ddADOUseClient Creates a client-side cursor, when supported by the provider.

Design time Read / Write

Run time Read / Write**

CursorType

Value Mnemonic Description

0 ddADOOpenForwardOnly Default - Creates a forward-only cursor.

1 ddADOOpenKeyset Keyset cursor

2 ddADOOpenDynamic Dynamic Cursor

3 ddADOOpenStatic Static cursor

ActiveReports 2.0 Standard User's Guide | 340

Page 341: 83791925 Active Report 2 0 Standard Edition

Availability

RemarksThe CursorType property is read/write when the recordset is closed and read-only when the recordset is open.

DataSourceName (ADO)DescriptionSets or returns the data source name for the connection.

Data TypeString

Availability

Example

Private Sub RunReport()Dim sDSN As String' Modify the report DSN to a DSN name from the registrysDSN = LoadDSNFromReg()If sDSN <> "" Then

Load rptSalesrptSales.dcRptData.DataSourceName = sDSNrptSales.Show

End IfEnd Sub

DefaultDatabaseDescriptionSets or returns the name of the default database to use from the provider.

Data TypeString

Availability

Design time Read / Write

Run time Read / Write**

DataSourceName

Design time Read / Write

Run time Read / Write

DefaultDatabase

Design time Read / Write

Run time Read / Write

LockType

ActiveReports 2.0 Standard User's Guide | 341

Page 342: 83791925 Active Report 2 0 Standard Edition

LockType (ADO)DescriptionSets or returns the type of record locking to be used while reading from, or writing to, the data source.

Data TypeLong

Availability

MaxRowsDescriptionSets 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 TypeLong

Availability

Example

Private Sub ActiveReport_ReportStart()' Set the number of records returned by the query to 10' For Top 10 ReportdcRptData.MaxRows = 10

End Sub

NRecordsDescriptionReturns the number of records in the current recordset.

Data TypeLong

Availability

Design time Read / Write

Run time Read / Write

MaxRows

Design time Read / Write

Run time Read / Write

NRecords

Design time N/A

ActiveReports 2.0 Standard User's Guide | 342

Page 343: 83791925 Active Report 2 0 Standard Edition

Password (ADO)DescriptionSets or returns the data source password.

Data TypeString

Availability

Example

Private Sub ActiveReport_ReportStart()' Set the user login properties before the report' startsdcRptData.UserID = sUserIDdcRptData.Password = sPassword

End Sub

ProviderDescriptionSets 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 TypeString

Availability

Example

Private Sub ActiveReport_ReportStart()' Set the OLEDB provider namedcRptData.Provider = "MSDASQL"

End Sub

Recordset (ADO)

Run time Read-Only

Password

Design time Read / Write

Run time Read / Write

Provider

Design time Read / Write

Run time Read / Write

RecordSet

ActiveReports 2.0 Standard User's Guide | 343

Page 344: 83791925 Active Report 2 0 Standard Edition

DescriptionSets or returns a reference to the recordset object.

Data TypeObject

Availability

Example

Private Sub PrintOrder(lOrderID As Long)Dim rs As Recordset' Print a specific order based on a parametersSQL = "SELECT * FROM Invoice WHERE OrderID = " & _

Str(lOrderID)Set rs = dbOrderSystem.OpenRecordset(sSQL)Load rptOrders' Set the recordset property to our VB recordsetSet rptOrders.dcRptData.Recordset = rs' Print the reportrptOrders.PrintReport

End Sub

SourceDescriptionSets or returns the SQL source or table name for the recordset object.

Data TypeString

Availability

Example

srptProducts.dcRptData.Source = sSQLsrptProducts.dcRptData.Refresh

UserIDDescriptionSets the user id used to open the data source.

Data TypeString

Availability

Run time Read / Write

Source

Design time Read / Write

Run time Read / Write

UserID

ActiveReports 2.0 Standard User's Guide | 344

Page 345: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()' Set the user login properties before the report>' startsdcRptData.UserID = sUserIDdcRptData.Password = sPassword

End Sub

ADO Data Control Methods

Refresh (ADO)DescriptionRefresh 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 ValueNone – the recordset object property will be updated to contain the new results.

SyntaxSub Refresh()

ParametersNone

Example

srptProducts.dcRptData.Source = sSQLsrptProducts.dcRptData.Refresh

DAODAO Data Control Properties

DAO Data Control Methods

Design time Read / Write

Run time Read / Write

ADO DB Data Control Methods

Method Description

Refresh Refreshes the data control's recordset. Sub Refresh()

Refresh

DAO

DAO Data Control Properties

ActiveReports 2.0 Standard User's Guide | 345

Page 346: 83791925 Active Report 2 0 Standard Edition

DAO Data Control Properties

Connect (DAO)DescriptionConnect 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 TypeString

Availability

Property Data Type Description

Connect String Sets or returns the connection string or type to the data source.

DatabaseName String Sets or returns the database name or path based on the Connect property setting.

DefaultCursorType DAOCursorType Sets or returns the type of cursor driver used to open the data source. This property is used with ODBCDirect data sources only.

DefaultType DAODefaultType Determines the type of workspace used to open the data source.

Exclusive Boolean Determines whether the data source is opened in a single-user mode or a shared multi-user mode.

MaxRows Long Sets the number of rows to be returned from the recordset to be processed in the detail section.

Options Long Sets or returns a value that defines the recordset object characteristics. See Visual Basic DAO documentation for more information about this property's settings.

Password String Sets or returns the password associated with the user name to open secure MS Access mdb files.

Recordset Object Sets or returns a Recordset object from the data control.

RecordsetType DAORecordsetType Sets or returns the type of the recordset that the data control will create from your data source.

RecordSource String Sets or returns strings identifying the table name, querydef or SQL string that defines the record source of the data control.

SystemDB String Sets or returns the name of the security setting mdw file.

UserName String Sets or returns the user name to open secure MS Access mdb files.

Connect

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 346

Page 347: 83791925 Active Report 2 0 Standard Edition

Example

' Connect to SQL Server using ODBCdcRptData.Connect = "ODBC;DSN=LocalServer;UID=sa;PWD=;"

DatabaseNameDescriptionDatabaseName property sets or returns the database name or path based on the Connect property setting.

Data TypeString

Availability

Example

Private Sub ActiveReport1_ReportStart()' Verify the location of the databasedcRptData.DatabaseName = App.Path & "\appdb.mdb"

End Sub

DefaultCursorTypeDescriptionDefaultCursorType 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 TypeDAOCursorType

Settings

Availability

DatabaseName

Design time Read / Write

Run time Read / Write

DefaultCursorType

Value Mnemonic Description

0 ddDAODefaultCursor Let the ODBC driver select the cursor type.

1 ddDAOODBCCursor Use the ODBC driver client-side cursor.

2 ddDAOServerSideCursor Let the server manage the cursor

Design time Read / Write

Run time Read / Write

DefaultType

ActiveReports 2.0 Standard User's Guide | 347

Page 348: 83791925 Active Report 2 0 Standard Edition

DefaultTypeDescriptionDefaultType 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 TypeDAODefaultType

Settings

Availability

ExclusiveDescriptionExclusive 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 TypeBoolean

Availability

MaxRowsDescriptionSets 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 TypeLong

Availability

Value Mnemonic Description

1 ddDAOUseODBC Use ODBCDirect to bypass the JET engine and access RDO directly.

2 ddDAOUseJet Use the Microsoft JET to access your data source.

Design time Read / Write

Run time Read / Write

Exclusive

Design time Read / Write

Run time Read / Write

MaxRows

ActiveReports 2.0 Standard User's Guide | 348

Page 349: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()' Set the MaxRows to the top n recordsdcRptData.MaxRecords = nMaxRecords

End Sub

Options (DAO)DescriptionOptions property specifies one or more of the recordset object characteristics. You can combine settings using the "OR" operator.

Data TypeLong

Availability

Password (DAO)DescriptionPassword 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 TypeString

Availability

Example

Private Sub RunPayrollReport()frmGetPassword.Show vbModalIf sPwd <> "" Then

' Load the report Load rptPayrollrptPayroll.dcRptData.SystemDB = App.Path & _

"\Payroll.mdw"' Set the password for the secure databaserptPayroll.dcRptData.UserName = sUserrptPayroll.dcRptData.Password = sPwd' Preview the report,

Design time Read / Write

Run time Read / Write

Options

Design time Read / Write

Run time Read / Write

Password

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 349

Page 350: 83791925 Active Report 2 0 Standard Edition

' an error would occur if the password is invalidrptPayroll.Show

End IfEnd Sub

Recordset (DAO)DescriptionRecordset 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 TypeObject

Availability

Example

Private Sub PrintOrder(lOrderID As Long)Dim rs As Recordset' Print a specific order based on a parametersSQL = "SELECT * FROM Invoice WHERE OrderID = " & _

Str(lOrderID)Set rs = dbOrderSystem.OpenRecordset(sSQL)Load rptOrders' Set the recordset property to our VB recordsetSet rptOrders.dcRptData.Recordset = rs' Print the reportrptOrders.PrintReport

End Sub

RecordsetTypeDescriptionRecordsetType property determines the type of the open recordset.

Data TypeDAORecordsetType

Settings

Availability

Recordset

Run time Read / Write

RecordsetType

Value Mnemonic Description

0 ddDAOTable Table type recordset object

1 ddDAODynaset Dynaset type recordset object

2 ddDAOSnapshot Snapshot type recordset object

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 350

Page 351: 83791925 Active Report 2 0 Standard Edition

RecordSourceDescriptionRecordSource property sets or returns the SQL RecordSource, table name or querydef name for the data control.

Data TypeString

Availability

Example

' Modify the report record source based on user inputsSQL = "SELECT * FROM Customers "sSQL = sSQL & "WHERE Region = '" & sState & "'"rptOrders.dcRptData.Recordsource = sSQLrptOrders.dcRptData.Refresh

SystemDBDescriptionSystemDB 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 TypeString

Availability

Example

Private Sub RunPayrollReport()frmGetPassword.Show vbModalIf sPwd <> "" Then

' Load the reportLoad rptPayroll' Set the pathname to the security filerptPayroll.dcRptData.SystemDB = App.Path & _

"Payroll.mdw"' Set the password for the secure databaserptPayroll.dcRptData.UserName = sUserrptPayroll.dcRptData.Password = sPwd' Preview the report,' an error would occur if the password is invalidrptPayroll.Show

RecordSource

Design time Read / Write

Run time Read / Write

SystemDB

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 351

Page 352: 83791925 Active Report 2 0 Standard Edition

End IfEnd Sub

UserName (DAO)DescriptionUserName 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 TypeString

Availability

Example

Private Sub RunPayrollReport()frmGetPassword.Show vbModalIf sPwd <> "" Then

' Load the reportLoad rptPayroll' Set the pathname to the security filerptPayroll.dcRptData.SystemDB = App.Path & _

"Payroll.mdw"' Set the password for the secure databaserptPayroll.dcRptData.UserName = sUserrptPayroll.dcRptData.Password = sPwd' Preview the report,' an error would occur if the password is invalidrptPayroll.Show

End IfEnd Sub

DAO Data Control Methods

Refresh (DAO)DescriptionRefresh method refreshes the data control's recordset. Call this method after modifying any of the data control's connection and RecordSource properties.

Return Value

UserName

Design time Read / Write

Run time Read / Write

DAO Data Control Methods

Method Description

Refresh Refreshes the data control's recordset. Sub Refresh()

Refresh

ActiveReports 2.0 Standard User's Guide | 352

Page 353: 83791925 Active Report 2 0 Standard Edition

None – the recordset object property will be updated to contain the new results.

SyntaxSub Refresh()

ParametersNone

Example

srptProducts.dcRptData.RecordSource = sSQLsrptProducts.dcRptData.Refresh

RDORDO Data Control Properties

RDO Data Control Methods

RDO Data Control Properties

RDO

RDO Data Control Properties

Property Data Type Description

Connect String The RDOConnection parameters string.

Connection Object A reference to the data control's underlying RDOConnection object.

CursorDriver RDOCursorDriver Specifies the type of cursor driver to be created.

DataSourceName String The name of the ODBC data source used in the connection.

Environment Object A reference to the control's RDOEnvironment object.

ErrorThreshold Long The severity level value that constitutes a fatal error.

KeysetSize Long Number of rows in the keyset buffer.

LockType RDOLockType The type of concurrent locking.

LoginTimeout Long Number of seconds to wait for a connection before a timeout error.

LogMessages String Path of the ODBC trace log file.

MaxRows Long The maximum number of records to be returned from the query.

Options Integer Sets one or more of the resultset characteristics.

Password String The password used to create the RDOEnvironment object for the connection.

Prompt RDOPrompt Determines how the ODBC driver should prompt for missing connection parameters.

QueryTimeout Long Number of seconds to wait before a query timeout error occurs.

ActiveReports 2.0 Standard User's Guide | 353

Page 354: 83791925 Active Report 2 0 Standard Edition

Connect (RDO)DescriptionConnect string sets the parameters for the RDO connection. Parameters are specified in the <parameter>=<value>; format. Valid parameters are:

Data TypeString

Availability

Example

' DSN-Less ConnectiondcRptData.Connection = "driver={SQL Server};" & _

"SERVER=bigsmile;UID=sa;PWD=pwd;database=pubs"' DSN ConnectiondcRptData.LoginTimeout = 30dcRptData.Connect = "DSN=Pubs;UID=sa;PWD=pwd;"' Open a connection using a DSN and individual arguments' instead of a connection stringdcRptData.DataSourceName = "Pubs"dcRptData.UserName = "sa"dcRptData.Password = "pwd"

Resultset Object A reference to the RDOResultset object of the connection.

ResultsetType RDOResultSetType Indicates the type of the open resultset, static or keyset.

RowsetSize Long The number of rows in a resultset.

SQL String The SQL statement that defines the query executed by the control.

UserName String The user name used in the connection.

Version String The version of the data source associated with the connection.

Connect

Value Description

DSN ODBC registered data source name.

UID Recognized user of the database.

PWD Password associated with the user.

DRIVER Description of the ODBC driver. Used in DSN-less connections. Use brackets {} around descriptions containing spaces.

DATABASE Default database to use once connected.

SERVER Name of remote server.

WSID The systems Net Name.

APP Application's EXE name.

Design time Read / Write

Run time Read / Write

Connection

ActiveReports 2.0 Standard User's Guide | 354

Page 355: 83791925 Active Report 2 0 Standard Edition

Connection (RDO)DescriptionConnection 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 TypeObject

Availability

Example

Private Sub RunReport(rpt As Object)' Assign our already open connection to save on connectionrpt.Connection = cnnOrderEnterrpt.Show

End Sub

CursorDriverDescriptionSets or returns the type of cursor to be created for the resultset.

Data TypeRDOCursorDriver

Settings

Availability

DataSourceName (RDO)DescriptionSets 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.

Run time Read / Write

CursorDriver

Value Mnemonic Description

0 ddRDOUseIfNeeded The ODBC Driver will choose the appropriate driver to use.

1 ddRDOUseODBC Use the ODBC Driver cursor library.

2 ddRDOUseServer Use server side cursors.

3 ddRDOUseClientBatch Use optimistic client-side cursor

4 ddRDOUseNone Recordset is not returned as a cursor.

Design time Read / Write

Run time Read / Write

DataSourceName

ActiveReports 2.0 Standard User's Guide | 355

Page 356: 83791925 Active Report 2 0 Standard Edition

Data TypeString

Availability

Example

Private Sub ActiveReport_ReportStart()Dim sDSN As StringsDSN = GetDSNFromRegistry()dcRptData.DataSourceName = sDSN

End Sub

EnvironmentDescriptionReturns a reference to the RDOEnvironment object used by the RDO Data Control.

Data TypeObject

Availability

ErrorThresholdDescriptionSets or returns the severity level that constitutes a fatal error.

Data TypeLong

Availability

KeysetSizeDescriptionSets 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

Design time Read / Write

Run time Read / Write

Environment

Run time Read / Write

ErrorTheshold

Design time Read / Write

Run time Read / Write

KeysetSize

ActiveReports 2.0 Standard User's Guide | 356

Page 357: 83791925 Active Report 2 0 Standard Edition

Long

Availability

LockType (RDO)DescriptionSets 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 TypeRDOLockType

Settings

Availability

LoginTimeoutDescriptionSets or returns the number of seconds to wait for establishing a connection before a timeout error.

Data TypeLong

Availability

LogMessagesDescription

Design time Read / Write

Run time Read / Write

LockType

Value Mnemonic Description

1 ddRDOConcurReadOnly The recordset is read-only (not updateable)

2 ddRDOConcurLock Pessimistic concurrency

3 ddRDOConcurRowVer Optimistic concurrency (based on row id)

4 ddRDOConcurValues Optimistic concurrency (based on row values)

5 ddRDOConcurBatch Optimistic concurrency using batch mode. A status is returned for each successful update.

Design time Read / Write

Run time Read / Write

LoginTimeout

Design time Read / Write

Run time Read / Write

LogMessages

ActiveReports 2.0 Standard User's Guide | 357

Page 358: 83791925 Active Report 2 0 Standard Edition

Sets or returns the name of the ODBC-trace log file.

Data TypeString

Availability

MaxRowsDescriptionSets the maximum number of rows to return from the remote server.

Data TypeLong

Availability

Options (RDO)DescriptionSets or returns the resultset characteristics flags.

Data TypeInteger

Availability

Password (RDO)DescriptionSets or returns the password associated with the user id used to connect to the data source.

Data TypeString

Availability

Design time Read / Write

Run time Read / Write

MaxRows

Design time Read / Write

Run time Read / Write

Options

Design time Read / Write

Run time Read / Write

Password

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 358

Page 359: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()' Set the user name and password before ' openning the recordsetdcRptData.UserName = gsUserdcRptData.Password = gdPassword

End Sub

Prompt (RDO)DescriptionDetermines how the ODBC driver should prompt for missing connection parameters.

Data TypeRDOPrompt

Settings

Availability

QueryTimeoutDescriptionNumber of seconds to wait before a query timeout error occurs.

Data TypeLong

Prompt

Value Mnemonic Description

0 ddRDODriverPrompt 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.

1 ddRDODriverNoPrompt The driver manager uses the connection string provided in connect. If sufficient information is not provided, the OpenConnection method returns a trappable error.

2 ddRDODriverComplete 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.

3 ddRDODriverCompleteRequired Behaves like ddRDODriverComplete, except the driver disables the controls for any information not required to complete the connection.

Design time Read / Write

Run time Read / Write

QueryTimeout

ActiveReports 2.0 Standard User's Guide | 359

Page 360: 83791925 Active Report 2 0 Standard Edition

Availability

ResultsetDescriptionSets or returns a reference to the RDOResultset object of the connection.

Data TypeObject

Availability

Example

Private Sub RunReport()Load rptProducts' Set the report resultset to our VB RDO ResultsetSet rptProducts.dcRptData.Resultset = rs' Preview the reportrptProducts.Show

End Sub

ResultsetTypeDescriptionSets or returns the type of the open resultset: static or keyset.

Data TypeRDOResultSetType

Settings

Availability

RowsetSize

Design time Read / Write

Run time Read / Write

Resultset

Run time Read / Write

ResultsetType

Value Mnemonic Description

1 DdRDOOpenKeySet Creates a keyset resultset

3 DdRDOOpenStatic Creates a static resultset

Design time Read / Write

Run time Read / Write

RowsetSize

ActiveReports 2.0 Standard User's Guide | 360

Page 361: 83791925 Active Report 2 0 Standard Edition

DescriptionRowsetSize returns the number of rows in a resultset.

Data TypeLong

Availability

SQLDescriptionThe SQL statement that defines the query executed by the control.

Data TypeString

Availability

Example

Private Sub PrintOrder(lOrderID As Long)Dim sSQL As StringLoad rptOrdersSQL = "SELECT * FROM orders "sSQL = sSQL & "WHERE OrderID = " & Str(lOrderID)' Modify the SQLrptOrder.dcRptData.SQL = sSQLrptOrder.Show

End Sub

UserName (RDO)DescriptionThe user name used in the connection.

Data TypeString

Availability

Example

Design time Read / Write

Run time Read / Write

SQL

Design time Read / Write

Run time Read / Write

UserName

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 361

Page 362: 83791925 Active Report 2 0 Standard Edition

Private Sub ActiveReport_ReportStart()' Set the user name and password before' openning the recordsetdcRptData.UserName = gsUserdcRptData.Password = gdPassword

End Sub

Version (RDO)DescriptionThe version of the data source associated with the connection.

Data TypeString

Availability

RDO Data Control Methods

Refresh (RDO)DescriptionRefreshes the data control's resultset.

Return ValueNone – the resultset object property will be updated to contain the new results.

SyntaxSub Refresh()

ParametersNone

Example

Private Sub Detail_Format()srptProducts.dcRptData.SQL = "SELECT * FROM Products" & _

" WHERE CategoryID = " & txtCategoryID.TextsrptProducts.dcRptData.Refresh

End Sub

Version

Design time N/A

Run time Read / Write

RDO Data Control Methods

Method Description

Refresh Refreshes the data control's recordset. Sub Refresh()

Refresh

ActiveReports 2.0 Standard User's Guide | 362

Page 363: 83791925 Active Report 2 0 Standard Edition

XMLXML Data Control Properties

XML Data Control Methods

XML Data Control Properties

BOFDescriptionReturns whether or not the node is at the beginning of the nodelist.

Data TypeString

Availability

Example

If me.XMLDataControl.BOF and me.XMLDataControl.EOF thenExit sub

End if

XML

XML Data Control Properties

Property Data Type Description

BOF Boolean Returns whether or not the node is at the beginning of the nodelist.

Count Long Sets or returns the XML RecordCount.

CurrentPosition Long Sets or returns the current position for the XML database.

EOF Boolean Returns whether or not the node is at the end of the nodelist.

FileURL String Sets or returns the file URL for the XLM database.

NodeList Variant Sets or returns the node list for the XML database.

RecordSetPattern String Sets or returns an XSL pattern to indicate which nodes the XML database will return.

ValidateOnParse Boolean 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

Design time N/A

Run time Read Only

Count

ActiveReports 2.0 Standard User's Guide | 363

Page 364: 83791925 Active Report 2 0 Standard Edition

Count (XML)DescriptionReturns the number of nodes selected by the XSLPattern specified in the RecordsetPattern property.

Data TypeString

Availability

Example

Private Sub ActiveReport_ReportStart()Dim recCount As LongrecCount = XMLDataControl1.Count

End Sub

CurrentPositionDescriptionReturns the record number the XML database is currently using. Note: The first record in the database is at position 0.

Data TypeString

Availability

ExamplelblDetailItem.Caption = xmlDC.CurrentPosition

EOFDescriptionReturns whether or not the node is at the end of the nodelist.

Data TypeString

Availability

Design time N/A

Run time Read Only

CurrentPosition

Design time N/A

Run time Read Only

EOF

Design time N/A

ActiveReports 2.0 Standard User's Guide | 364

Page 365: 83791925 Active Report 2 0 Standard Edition

Example

If me.XMLDataControl.BOF and me.XMLDataControl.EOF thenExit sub

End if

FileURLDescriptionSets or returns the XML DataControl's URL or file name of the XML document to which the report is connected.

Data TypeString

Availability

Example

Private Sub ActiveReport_DataInitialize()If connectLocal = False Then

XMLDataControl1.FileURL = _"http://www.datadynamics.com/samples/ratings.xml"

ElseXMLDataControl1.FileURL = App.Path & _

"\purchaseorder.xml"End If

End Sub

NodeListDescriptionSets 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 TypeVariant

Availability

Example

Run time Read Only

FileURL

Design time Read / Write

Run time Read / Write

NodeList

Design time N/A

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 365

Page 366: 83791925 Active Report 2 0 Standard Edition

Private Sub Detail_Format()Dim itemReport As rptOrderItemsSet itemReport = New rptOrderItems'Set the node list for the subreport based off the main'reports XML DataControlitemReport.XMLDataControl1.NodeList = _Me.XMLDataControl1.Field("Manifest/Item", True)SubReport1.object = itemReport

End Sub

RecordSetPatternDescriptionSets 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/en-us/xmlsdk30/htm/xmrefxpathsyntax.asp

Typical XSL patterns

Data TypeString

Availability

Example

Private Sub ActiveReport_DataInitialize()XMLDataControl1.ValidateOnParse = TrueXMLDataControl1.FileURL = App.Path & _

"\purchaseorder.RPX"

RecordSetPattern

Pattern Description

//* All nodes

//ITEM All ITEM nodes

/ Root item

//LAYOUT/ITEM/* All child nodes of //LAYOUT/ITEM

//ITEM[@type] All item nodes that contain the type attribute

//ITEM[@id="1"] All item nodes that have id attribute value of "1"

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 366

Page 367: 83791925 Active Report 2 0 Standard Edition

XMLDataControl1.RecordsetPattern = "Manifest/Item"End Sub

ValidateOnParseDescriptionSets 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 TypeString

Availability

Example

Private Sub ActiveReport_DataInitialize()XMLDataControl1.ValidateOnParse = TrueXMLDataControl1.FileURL = App.Path & _

"\purchaseorder.XML"XMLDataControl1.RecordsetPattern = "Manifest/Item"

End Sub

XML Data Control Methods

FieldDescriptionReturns the field specified from the XML database. When working with subreports, setting the

ValidateOnParse

Design time N/A

Run time Read / Write

XML Data Control Methods

Method Description

Field 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

ActiveReports 2.0 Standard User's Guide | 367

Page 368: 83791925 Active Report 2 0 Standard Edition

asNodeList to true will allow for manual binding to the subreports XML DataControl.

Return TypeNone

SyntaxFunction Field(Name As String,[AsNodeList])

Parameters

Example

Private Sub Detail_Format()Dim itemReport As rptOrderItemsSet itemReport = New rptOrderItemsitemReport.XMLDataControl1.NodeList = _

Me.XMLDataControl1.Field("Manifest/Item", True)SubReport1.object = itemReport

End Sub

LoadXMLDescriptionLoads XML data by using the indicated XML string. The XMLString can be an entire XML document or a correctly formed XML document section.

Return TypeNone

SyntaxSub LoadXML(XMLString As Integer)

Parameters

Example

Private Sub ActiveReport_DataInitialize()XMLDataControl1.ValidateOnParse = TrueXMLDataControl1.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>" & _

Name Type Description

Name String Name of XML field

AsNodeList Boolean Determines if the field will be used as a NodeList.

LoadXML

Name Type Description

XMLString String String indicating the XML file to load

ActiveReports 2.0 Standard User's Guide | 368

Page 369: 83791925 Active Report 2 0 Standard Edition

"<Subtotal>$23.75</Subtotal>" & _"<Tax>$2.43</Tax>" & _"</Receipt>" & _"</Customer>" & _"</Order>")

End Sub

MoveNextDescriptionMoves to the next node in the nodelist.

Return TypeNone

SyntaxSub MoveNext()

ParametersNone

ResetDescriptionRenews 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 TypeNone

SyntaxSub Reset()

ParametersNone

History ObjectHistory Properties

History Methods

History Properties

MoveNext

Reset

History

History Properties

Property Data Type Description

Count Integer Returns the number of entries in the history stack.

Position Integer Returns the position of the current page in the history stack.

ActiveReports 2.0 Standard User's Guide | 369

Page 370: 83791925 Active Report 2 0 Standard Edition

Count (History)DescriptionReturns the number of entries in the navigation history stack.

Data TypeInteger

Availability

Example

' Command button implementations of a custom toolbarPrivate Sub btnBack()

With arv.TOC.History.BackbtnBack.Enabled = (.Position >= 0)btnForward.Enabled = (.Position < .Count)

End WithEnd SubPrivate Sub btnForward()

With arv.TOC.History.ForwardbtnBack.Enabled = (.Position >= 0)btnForward.Enabled = (.Position < .Count)

End WithEnd Sub

PositionDescriptionReturns the position of the current page in the navigation history stack.

Data TypeInteger

Availability

Example

' Command button implementations of a custom toolbarPrivate Sub btnBack()

With arv.TOC.History.BackbtnBack.Enabled = (.Position >= 0)btnForward.Enabled = (.Position < .Count)

End WithEnd SubPrivate Sub btnForward()

With arv.TOC.History.ForwardbtnBack.Enabled = (.Position >= 0)btnForward.Enabled = (.Position < .Count)

Count

Run time Read

Position

Run time Read

ActiveReports 2.0 Standard User's Guide | 370

Page 371: 83791925 Active Report 2 0 Standard Edition

End WithEnd Sub

History Methods

BackDescriptionDisplays the previous page in the navigation history stack.

Return TypeNone

SyntaxSub Back()

ParametersNone

Example

' Command button implementations of a custom toolbarPrivate Sub btnBack()

With arv.TOC.History.BackbtnBack.Enabled = (.Position >= 0)btnForward.Enabled = (.Position < .Count)

End WithEnd SubPrivate Sub btnForward()

With arv.TOC.History.ForwardbtnBack.Enabled = (.Position >= 0)btnForward.Enabled = (.Position < .Count)

End WithEnd Sub

ForwardDescriptionDisplays the next page in the navigation history stack.

History Methods

Method Description

Back 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

Forward

ActiveReports 2.0 Standard User's Guide | 371

Page 372: 83791925 Active Report 2 0 Standard Edition

Return TypeNone

SyntaxSub Forward()

ParametersNone

Example

' Command button implementations of a custom toolbarPrivate Sub btnBack()

With arv.TOC.History.BackbtnBack.Enabled = (.Position >= 0)btnForward.Enabled = (.Position < .Count)

End WithEnd SubPrivate Sub btnForward()

With arv.TOC.History.ForwardbtnBack.Enabled = (.Position >= 0)btnForward.Enabled = (.Position < .Count)

End WithEnd Sub

Item (History)DescriptionReturns the page number at the selected index in the navigation history stack.

Return TypeNone

SyntaxSub Item(Index As Integer, PageNumber As Long)

Parameters

Example

Dim cIndex As IntegerDim pIndex As IntegerPrivate Sub arv_TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long)

pIndex = cIndexcIndex = cIndex + 1

End SubPrivate Sub cmdOpenReport_Click()

arv.ReportSource = New rptCustomersEnd SubPrivate Sub cmdPrevTOC_Click()

Dim pg As Longarv.TOC.History.Item pIndex, pgarv.TOC.GotoPage pg

Item

Name Type Description

Index Integer Index of the navigation history entry.

PageNumber Long The returned page number at the specified index.

ActiveReports 2.0 Standard User's Guide | 372

Page 373: 83791925 Active Report 2 0 Standard Edition

End Sub

Pages and PageSettingsPageSettings Properties

Pages

PageSettings Properties

Pages and PageSettings

PageSettings Properties

Property Data Type Description

BottomMargin Single Sets or returns the space between the bottom of the physical page and the bottom of the printing area.

Collate prtCollate When printing multiple copies of a report, complete pages of each copy will be printed before the next copy starts printing.

Duplex prtDuplex Sets or returns the type of duplex printing to be used. This property depends on the selected device. Not all printers support duplex printing.

Gutter Single Sets or returns the extra space between the edge of the page and the page's margins.

LeftMargin Single Sets or returns the space between the left edge of the physical page and the left edge of the printing area.

MirrorMargins Boolean Sets or returns whether the left page's margins will be mirrored on the right page.

Orientation prtOrientation Determines whether a report prints vertically or horizontally. It defaults to the current setting of the printer in Windows Control Panel.

PaperBin Integer PaperBin sets or returns the paper bin number from which the paper is fed.

PaperHeight Single 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 Integer PaperSize sets or returns the index in the PaperSizes collection of the currently selected standard paper size.

PaperWidth Single 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.

RightMargin Single Sets or returns the space between the right edge of the physical page and the right edge of the printing area.

TopMargin Single Sets or returns the space between the top of the physical page and the top of the printing area.

BottomMargin

ActiveReports 2.0 Standard User's Guide | 373

Page 374: 83791925 Active Report 2 0 Standard Edition

BottomMarginDescriptionSets or returns the space between the bottom of the physical page and the bottom of the printing area.

DataTypeSingleDefault Value

1440 twips = 1 inch.

Availability

Example

Private Sub ActiveReport_ReportStart()'Sets a 1 inch bottom marginMe.PageSettings.BottomMargin = 1440'Sets a 1 inch top marginMe.PageSettings.TopMargin = 1440' ½ inch left marginMe.PageSettings.LeftMargin = 720' ½ inch right marginMe.PageSettings.RightMargin = 720

End Sub

Collate (PageSettings)DescriptionWhen 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.

DataTypePrtCollate

Settings

Availability

Design time Read / Write

Run time Read / Write

Collate

Value Mnemonic Description

-1 COLLATE_PRINTERDEFAULT The report will use the setting selected on the default printer

0 COLLATE_FALSE Multiple copies of a page will be printed followed by multiple copies of the following page.

1 COLLATE_TRUE A complete copy of the report will be printed before another copy starts printing.

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 374

Page 375: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()'Prints all copies of a each page before moving to the next pageMe.PageSettings.Collate = COLLATE_FALSE

End Sub

Duplex (PageSettings)DescriptionSets 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 TypeprtDuplex

Settings

Availability

Example

Private Sub ActiveReport_ReportStart()'Sets a report up to be bound like a book'Turn on MirrorMarginsMe.PageSettings.MirrorMargins = True'Sets gutter to .5 in to allow for bindingMe.PageSettings.Gutter = 720'Set duplex to print vertically on both sidesMe.PageSettings.Duplex = ddDXVertical

End Sub

GutterDescriptionSets 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

Duplex

Value Mnemonic Description

-1 ddDXPrinterDefault The report will use the default setting on the selected printer.

1 ddDXSimplex Turns off duplex printing.

2 ddDXHorizontal Prints horizontally on both sides of the paper.

3 ddDXVertical Prints vertically on both sides of the paper.

Design time Read / Write

Run time Read / Write

Gutter

ActiveReports 2.0 Standard User's Guide | 375

Page 376: 83791925 Active Report 2 0 Standard Edition

of even pages.

DataTypeSingle

Availability

Example

Private Sub ActiveReport_ReportStart()'Sets a report up to be bound like a book'Turn on MirrorMarginsMe.PageSettings.MirrorMargins = True'Sets gutter to .5 in to allow for bindingMe.PageSettings.Gutter = 720'Set duplex to print vertically on both sidesMe.PageSettings.Duplex = ddDXVertical

End Sub

LeftMarginDescriptionSets or returns the space between the left edge of the physical page and the left edge of the printing area.

DataTypeSingleDefault Value

1440 twips = 1 inch.

Availability

Example

Private Sub ActiveReport_ReportStart()'Sets a 1 inch bottom margin Me.PageSettings.BottomMargin = 1440'Sets a 1 inch top marginMe.PageSettings.TopMargin = 1440' ½ inch left marginMe.PageSettings.LeftMargin = 720' ½ inch right marginMe.PageSettings.RightMargin = 720

End Sub

MirrorMarginsSets or returns whether the left page's margins will be mirrored on the right page. Setting

Design time Read / Write

Run time Read / Write

LeftMargin

Design time Read / Write

Run time Read / Write

MirrorMargins

ActiveReports 2.0 Standard User's Guide | 376

Page 377: 83791925 Active Report 2 0 Standard Edition

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.

DataTypeBoolean

Availability

Example

Private Sub ActiveReport_ReportStart()'Sets a report up to be bound like a book'Turn on MirrorMarginsMe.PageSettings.MirrorMargins = True'Sets gutter to .5 in to allow for bindingMe.PageSettings.Gutter = 720'Set duplex to print vertically on both sidesMe.PageSettings.Duplex = ddDXVertical

End Sub

Orientation (PageSettings)DescriptionDetermines 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 TypePrtOrientation

Settings

Availability

Example

' ActiveReports defaults to the current printer settings' to change the default you need to set the orientation' property in the ReportStart eventPrivate Sub ActiveReport_ReportStart()

me.PageSettings.Orientation = ddOLandscapeEnd Sub

Design time Read / Write

Run time Read / Write

Orientation

Value Mnemonic Description

-1 ddODefault Uses printer's default orientation setting

1 ddOPortrait Print along the width of the paper.

2 ddOLandscape Print along the length of the paper.

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 377

Page 378: 83791925 Active Report 2 0 Standard Edition

PaperBinDescriptionPaperBin sets or returns the paper bin number from which the paper is fed.

Data TypeInteger

Settings

Note: PaperBin values may very with individual printers. Check printer documentation for appropriate PaperBin.

Availability

PaperHeight (PageSettings)DescriptionPaperHeight 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 TypeSingle

Availability

PaperBin

Value Description

1 Use paper from the upper bin.

2 Use paper from the lower bin.

3 Use paper from the middle bin.

4 Wait for manual insertion of each sheet of paper.

5 Use envelopes from the envelope feeder.

6 Use envelopes from feeder, but wait for manual insertion.

7 (Default) Use paper from the current default bin.

8 Use paper fed from the tractor feeder.

9 Use paper from the small paper feeder.

10 Use paper from the large paper bin.

11 Use paper from the large capacity feeder.

14 Use paper from the attached cassette cartridge.

Design time Read / Write

Run time Read / Write

PaperHeight

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 378

Page 379: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()' Specify a custom paper sizeMe.PageSettings.PaperSize = 256' Sets the paper's width to 2 inchesMe.PageSettings.PaperWidth = 1440 * 2' Sets the paper's height to 4 inchesMe.PageSettings.PaperHeight = 1440 * 4

End Sub

PaperSizeDescriptionPaperSize 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

PaperSize

Value Description

1 Letter, 8 1/2 x 11 in

2 +A611Letter Small, 8 1/2 x 11 in

3 Tabloid, 11 x 17 in

4 Ledger, 17 x 11 in

5 Legal, 8 1/2 x 14 in

6 Statement, 5 1/2 x 8 1/2 in

7 Executive, 7 1/2 x 10 1/2 in

8 A3, 297 x 420 mm

9 A4, 210 x 297 mm

10 A4 Small, 210 x 297 mm

11 A5, 148 x 210 mm

12 B4, 250 x 354 mm

13 B5, 182 x 257 mm

14 Folio, 8 1/2 x 13 in

15 Quarto, 215 x 275 mm

16 10 x 14 in

17 11 x 17 in

18 Note, 8 1/2 x 11 in

19 Envelope #9, 3 7/8 x 8 7/8 in

20 Envelope #10, 4 1/8 x 9 1/2 in

21 Envelope #11, 4 1/2 x 10 3/8 in

22 Envelope #12, 4 1/2 x 11 in

23 Envelope #14, 5 x 11 1/2 in

24 C size sheet

25 D size sheet

ActiveReports 2.0 Standard User's Guide | 379

Page 380: 83791925 Active Report 2 0 Standard Edition

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 TypeInteger

Availability

Example

Private Sub InitPaperSizes()Dim I As IntegerFor I = 0 To rptSummary.Printer.PaperSizes.Count – 1

lstPaperSizes.AddItem rptSummary.Printer.PaperSizes(I)Next I

End SubPrivate Sub lstPaperSizes_DblClick()

' Set the paper size to the selected sizerptSumamry.PageSettings.PaperSize = lstPaperSizes.ListIndex

End Sub

PaperWidth (PageSettings)DescriptionPaperWidth 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

26 E size sheet

27 Envelope DL, 110 x 220 mm

29 Envelope C3, 324 x 458 mm

30 Envelope C4, 229 x 324 mm

28 Envelope C5, 162 x 229 mm

31 Envelope C6, 114 x 162 mm

32 Envelope C65, 114 x 229 mm

33 Envelope B4, 250 x 353 mm

34 Envelope B5, 176 x 250 mm

35 Envelope B6, 176 x 125 mm

36 Envelope, 110 x 230 mm

37 Envelope Monarch, 3 7/8 x 7 1/2 in

38 Envelope, 3 5/8 x 6 1/2 in

39 U.S. Standard Fanfold, 14 7/8 x 11 in

40 German Standard Fanfold, 8 1/2 x 12 in

41 German Legal Fanfold, 8 1/2 x 13 in

255 User Defined

Design time Read / Write

Run time Read / Write

PaperWidth

ActiveReports 2.0 Standard User's Guide | 380

Page 381: 83791925 Active Report 2 0 Standard Edition

common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data TypeSingle

Availability

Example

Private Sub ActiveReport_ReportStart()' Specify a custom paper sizeMe.PageSettings.PaperSize = 256' Sets the paper's width to 2 inchesMe.PageSettings.PaperWidth = 1440 * 2' Sets the paper's height to 4 inchesMe.PageSettings.PaperHeight = 1440 * 4

End Sub

RightMarginDescriptionSets or returns the space between the right edge of the physical page and the right edge of the printing area.

DataTypeSingleDefault Value

1440 twips = 1 inch.

Availability

Example

Private Sub ActiveReport_ReportStart()'Sets a 1 inch bottom marginMe.PageSettings.BottomMargin = 1440'Sets a 1 inch top marginMe.PageSettings.TopMargin = 1440' ½ inch left marginMe.PageSettings.LeftMargin = 720' ½ inch right marginMe.PageSettings.RightMargin = 720

End Sub

TopMarginDescription

Design time N/A

Run time Read / Write

RightMargin

Design time Read / Write

Run time Read / Write

TopMargin

ActiveReports 2.0 Standard User's Guide | 381

Page 382: 83791925 Active Report 2 0 Standard Edition

Sets or returns the space between the top of the physical page and the top of the printing area.

DataTypeSingleDefault Value

1440 twips = 1 inch.

Availability

Example

Private Sub ActiveReport_ReportStart()'Sets a 1 inch bottom marginMe.PageSettings.BottomMargin = 1440'Sets a 1 inch top marginMe.PageSettings.TopMargin = 1440' ½ inch left marginMe.PageSettings.LeftMargin = 720' ½ inch right marginMe.PageSettings.RightMargin = 720

End Sub

Pages ObjectPages Properties

Pages Methods

Pages Properties

Note: Users should set this property prior to saving or loading a password-protected file.

Password (Pages)DescriptionSets 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 TypeString

Availability

Design time Read / Write

Run time Read / Write

Pages

Pages Properties

Property Data Type Description

Password String Sets or returns a case-sensitive password for saving or loading protected reports.

Password

ActiveReports 2.0 Standard User's Guide | 382

Page 383: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub cmdLoadRDF_Click()ARViewer1.Pages.Password = "myPassword"ARViewer1.Pages.Load app.path & "\Password.RDF"

End SubPrivate Sub ActiveReport_ReportEnd()

Me.Pages.Password = "myPassword"<Me.Pages.Save app.path & "\Password.RDF"

End Sub

Pages Methods

Add (Pages)Description

Run time Read / Write

Pages Methods

Method Description

Add 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 Removes all object from the collection.Sub RemoveAll()

Save Save the report pages output to the specified file. Sub Save(FileName As String,[SaveOptions],[Vdata])

Add

ActiveReports 2.0 Standard User's Guide | 383

Page 384: 83791925 Active Report 2 0 Standard Edition

Adds a new blank canvas object to the collection. The new canvas object can be accessed at the index Count – 1.

Return ValueNone

SyntaxSub Add()

ParametersNone – The new canvas object is added to the end of the collection.

Example

' Run the report to create the pages collectionrptInvoice.Run' Add a new page to the reportrptInvoice.Pages.AddWith rptInvoice.Pages(rptInvoice.Pages.Count-1)

' Print additional information about the report' to the last page

End With' Display the report with the additional pagerptInvoice.Show

CommitDescriptionCommits 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 ValueNone

SyntaxSub Commit()

ParametersNone

Example

Private Sub ActiveReport_ReportEnd()Dim rpt As New arTOCDim iPg As IntegerDim pg As Canvas'Runs the arTOC report to generate the TOCSet rpt.PrintTOC = TOCrpt.Run' Insert all the arTOC pages into the end of' this reportiPg = Me.Pages.CountFor Each pg In rpt.Pages

Pages.Insert iPg, pgiPg = iPg + 1

Next

Commit

ActiveReports 2.0 Standard User's Guide | 384

Page 385: 83791925 Active Report 2 0 Standard Edition

' Commit all changes to the pages collectionPages.CommitUnload rptSet rpt = Nothing

End Sub

Count (Pages)DescriptionReturns the number of objects in the collection.

Return ValueLong

SyntaxFunction Count() As Long

ParametersNone

Example

For I = 0 to rpt.Pages.Count – 1Rpt.Pages(I).Overlay cv

Next I

GetPagesInRangeDescriptionReturns 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 TypePages

SyntaxFunction GetPagesInRange(rangeString As String) As Pages

Parameters

Example

Private Sub ActiveReport_ReportEnd()Dim myPDFExport As ActiveReportsPDFExport.ARExportPDFDim myPageRange As PagesSet myPDFExport = New _

ActiveReportsPDFExport.ARExportPDF

Count

GetPagesInRange

Name Type Description

rangeString String String value indicating the range of pages to be returned

ActiveReports 2.0 Standard User's Guide | 385

Page 386: 83791925 Active Report 2 0 Standard Edition

Set myPageRange = _Me.Pages.GetPagesInRange("1,3,5,7,9")

myPDFExport.FileName = "C:\PDFExportRanges.PDF"myPDFExport.Export myPageRange

End Sub

Insert (Pages)DescriptionAdds the specified canvas object before the specified index in the collection.

Return ValueNone

SyntaxSub Insert(Index As Long, Canvas As Canvas)

Parameters

Example

' Insert a FaxCover Page before the first page in the reportrptInvoice.Pages.Insert 0, cvFaxCover

InsertNewDescriptionAdds a new blank canvas object before the specified index in the collection.

Return ValueNone

SyntaxSub InsertNew(Index As Long)

Parameters

Example

' Insert a new page before the 5th page in the reportrptInvoice.Pages.InsertNew 4

Insert

Name Type Description

Index Long Index of the item to succeed the new object.

Canvas Canvas A canvas object to be inserted into the collection.

InsertNew

Name Type Description

Index Long Index of the item to succeed the new object.

Item

ActiveReports 2.0 Standard User's Guide | 386

Page 387: 83791925 Active Report 2 0 Standard Edition

Item (Pages)DescriptionReturns a reference to the canvas object at the specified index.

Return ValueCanvas

SyntaxFunction Item(Index As Long) As Canvas

Parameters

Load (Pages)DescriptionRetrieves previously saved Pages collection.

Return ValueNone

SyntaxSub Load(FileName As String)

Parameters

Example

rptInvoice.Pages.Load App.Path & "\SavedReport.rdf"rptInvoice.Show

Remove (Pages)DescriptionRemoves the canvas object at the specified index in the collection.

Return ValueNone – The specified item is removed from the collection.

SyntaxSub Remove(Index As Long)

Parameters

Name Type Description

Index Long Index of the requested canvas object.

Load

Name Type Description

FileName String Full path of the file to be loaded

Remove

ActiveReports 2.0 Standard User's Guide | 387

Page 388: 83791925 Active Report 2 0 Standard Edition

Example

' Remove the first page of the reportrptInvoice.Pages.Remove(0)rptInvoice.Pages.Commit

RemoveAll (Pages)DescriptionRemoves all objects from the collection. Count returns 0.

Return ValueNone – All objects are removed from the collection.

SyntaxSub RemoveAll()

ParametersNone

Example

' Clear the pages collectionrptInvoice.Pages.RemoveAllrptInvoice.Pages.Commit' Run the report againrptInvoice.Run

Save (Pages)DescriptionSaves the report pages output to the specified file. Saved files can be loaded and viewed or printed using the viewer control.

Return ValueNone

SyntaxSub Save(FileName As String, [SaveOptions],[Vdata])

Parameters

Name Type Description

Index Long Index of the canvas object to be removed from the collection.

RemoveAll

Save

Name Type Description

FileName String Full path of the file to be loaded.

SaveOptions SaveOptionTypes Indicates how the pages should be save.

Vdata Variant Returns the byte array when ByteArray is specified in

ActiveReports 2.0 Standard User's Guide | 388

Page 389: 83791925 Active Report 2 0 Standard Edition

Settings

Example

' Run the invoice report to create the pages collectionrptInvoice.Run' Save the output to filerptInvoice.Pages.Save App.Path & "\Invoice.rdf"

PaperSizes Methods

Count (PaperSizes)DescriptionThe count method returns the number of available standard paper sizes.

Return TypeInteger

SyntaxFunction Count() As Integer

ParametersNone

Example

'Returns a list of PaperSize Names and Values 'supported by the assigned printer and adds them to a'listbox controlPrivate Sub cmdGetPaperSizes_Click()

For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1lstPaperSizes.AddItem "PaperSize Value = " & _

ActiveReport1.Printer.PaperSizes.Item(P) & _

the SaveOptions

Value Description

1 Compresses all pages

2 Decompresses all pages and saves them

4 Save to byte array

PaperSizes Methods

Method Description

Count 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

ActiveReports 2.0 Standard User's Guide | 389

Page 390: 83791925 Active Report 2 0 Standard Edition

" PaperSize Name = " & _ActiveReport1.Printer.PaperSizes.Name(P)

Next PEnd Sub

Item (PaperSizes)DescriptionItem method returns a reference to the PaperSize string at the specified index.

Return TypeString

SyntaxFunction Item(Index As Variant) As String

Parameters

Example

'Returns a list of PaperSize Names and Values 'supported by the assigned printer and adds them to a'listbox controlPrivate Sub cmdGetPaperSizes_Click()

For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1lstPaperSizes.AddItem "PaperSize Value = " & _

ActiveReport1.Printer.PaperSizes.Item(P) & _" PaperSize Name = " & _ActiveReport1.Printer.PaperSizes.Name(P)

Next PEnd Sub

Name (PaperSizes)DescriptionSets or returns a description for the specified paper size.

Return TypeString

SyntaxFunction Name(Index As Variant) As String

Parameters

Example

Item

Name Type Description

Index Variant Index of the requested paper size.

Name

Name Type Description

Index Variant Index for the requested paper size name.

ActiveReports 2.0 Standard User's Guide | 390

Page 391: 83791925 Active Report 2 0 Standard Edition

'Returns a list of PaperSize Names and Values 'supported by the assigned printer and adds them to a'listbox controlPrivate Sub cmdGetPaperSizes_Click()

For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1lstPaperSizes.AddItem "PaperSize Value = " & _

ActiveReport1.Printer.PaperSizes.Item(P) & _" PaperSize Name = " & _ActiveReport1.Printer.PaperSizes.Name(P)

Next PEnd Sub

Parameters CollectionParameter Properties

Parameters Methods

Parameter Properties

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

SyntaxSELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data TypeString

Availability

ExampleText1.Text = "select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995%

Parameters

Parameter Properties

Property Data Type Description

Default Value String Sets or returns a string expression containing the query parameter's default value.

Key String Sets or returns the query parameter's key (name).

Prompt String Sets or returns the string expression to be used as a prompt for the query parameter.

Tag Variant Sets or returns custom data attached to the query parameter.

Value String Sets or Returns the string expression to be substituted in the query

DefaultValue

Design time N/A

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 391

Page 392: 83791925 Active Report 2 0 Standard Edition

># and OrderID><%OrderID|Order ID:|11000%>"

KeyDescriptionSets or returns the query parameter's key or name. The key is used to identify the parameter. Note: The Key is a required property.

SyntaxSELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data TypeString

Availability

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 PropNodeDim i As IntegerIf Cancelled = True Then

Me.CancelExit Sub

End IfForm1.EventListBox.ClearFor i = 0 To Me.Parameters.Count - 1

Set myprop = New PropNodemyprop.Name = Me.Parameters(i).Keymyprop.Value = Me.Parameters(i).ValueForm1.EventListBox.Properties.Add myprop

NextEnd Sub

Prompt (Parameters)DescriptionSets 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.

SyntaxSELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data TypeString

Availability

Key

Design time N/A

Run time Read / Write

Prompt

Design time N/A

ActiveReports 2.0 Standard User's Guide | 392

Page 393: 83791925 Active Report 2 0 Standard Edition

ExampleText1.Text = "select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995%># and OrderID><%OrderID|Order ID:|11000%>"

Tag (Parameters)DescriptionSets or returns custom data attached to the query parameter.

Data TypeVariant

Availability

Example

Me.Parameters(0).Tag = "date"Me.Parameters(1).Tag = "string"

Value (Parameters)DescriptionSets or Returns the string expression to be substituted in the query.

Data TypeString

Availability

Example

Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean)Dim myprop As PropNodeDim i As IntegerIf Cancelled = True Then

Me.CancelExit Sub

End IfForm1.EventListBox.ClearFor i = 0 To Me.Parameters.Count - 1

Set myprop = New PropNodemyprop.Name = Me.Parameters(i).Keymyprop.Value = Me.Parameters(i).ValueForm1.EventListBox.Properties.Add myprop

Next

Run time Read / Write

Tag

Design time N/a

Run time Read / Write

Value

Design time N/a

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 393

Page 394: 83791925 Active Report 2 0 Standard Edition

End Sub

Parameters Methods

Count (Parameters)DescriptionReturns the number of available parameters in the query string.

Return TypeInteger

SyntaxFunction Count() As Integer

ParametersNone

Example

Private Sub btnSetQuery_Click()myReport.DAODataControl1.RecordSource = Text1.TextPropList1.ClearFor cnt = 0 To myReport.Parameters.Count - 1

PropList1.AddObject myReport.Parameters(cnt)If cnt = 0 Then PropList1.SelectObjects

myReport.Parameters(0)End If

NextbtnRunReport.Enabled = True

End Sub

Item (Parameters)DescriptionReturns the query parameter for the specified index.

Return TypeARParameter

SyntaxFunction Item(Index As Variant) As ARParameter

Parameters Methods

Method Description

Count 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

Item

ActiveReports 2.0 Standard User's Guide | 394

Page 395: 83791925 Active Report 2 0 Standard Edition

Parameters

Example

Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean)Dim i As IntegerIf Cancelled = True Then

Me.CancelExit Sub

End If'If data parameter is empty set the default dateIf 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 zeroIf Me.Parameters.Item(1).Value = "" Then

Me.Parameters.Item(1).Value = "0"End If

End Sub

Printer ObjectPrinter Properties

Printer Methods

Printer Properties

Name Type Description

Index Variant Index for the requested parameter.

Printer

Printer Properties

Property Data Type Description

Collate prtCollate When printing multiple copies of a report, complete pages of each copy will be printed before the next copy starts printing.

ColorMode Integer Determines whether to force print in color or monochrome, this property dependent on the selected printer driver.

Copies Integer Number of copies to print.

DeviceCopies Integer Sets or returns the physical number of copies of the selected device.

DeviceName String Name of the printer device driver.

Devices String Array A string array of available device names.

DisplayProgressDialog Boolean Determines whether the print progress dialog should be displayed while the report is printed.

DPI Long The printer resolution (Dots Per Inch)

Duplex prtDuplex Sets or returns the type of duplex printing to be used. This property depends on the selected device. Not all printers support duplex printing.

FileName String Sets/returns file name used to print to a file. If empty, ActiveReports prints to the printer.

FromPage Long Specifies the first page to print.

hDC Long Returns a handle (from Microsoft Windows) to the printer's device context.

MaxPage Long Returns the total number of pages to be printed.

ActiveReports 2.0 Standard User's Guide | 395

Page 396: 83791925 Active Report 2 0 Standard Edition

Collate (Printer)DescriptionWhen 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.

DataTypePrtCollate

Settings

Availability

NDevices Long The number of available printers.

NPorts Long The number of available ports.

Orientation prtOrientation Determines whether a report prints vertically or horizontally. It defaults to the current setting of the printer in Windows Control Panel.

PaperBinNames Variant Returns a zero-based array of names of PaperBins supported by the current device.

PaperBins Variant Returns an zero-based array of PaperBin codes supported by the current device.

PaperHeight Long 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.

PaperSizes PaperSizes A collection of available paper sizes.

PaperWidth Long 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.

Port String Returns the current printer port name.

Ports String Array A string array of available port names

PrintQuality Long Determines the level of detail to use when printing.

Status JobStatus Returns the current job status.

ToPage Long Specifies the last page to print from the collection.

TrackDefault Boolean Specifies whether device changes will modify Windows default printer.

TwipsPerPixelX Single Number of twips for each printer pixel horizontally.

TwipsPerPixelY Single Number of twips for each printer pixel vertically.

Collate (Printer)

Value Mnemonic Description

-1 COLLATE_PRINTERDEFAULT The report will use the setting selected on the default printer

0 COLLATE_FALSE Multiple copies of a page will be printed followed by multiple copies of the following page.

1 COLLATE_TRUE A complete copy of the report will be printed before another copy starts printing.

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 396

Page 397: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub ActiveReport_ReportStart()'Prints all copies of a each page before moving to the next pageMe.PageSettings.Collate = COLLATE_FALSE

End Sub

ColorModeDescriptionColorMode 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 TypeInteger

Settings

Availability

ExamplerptInvoice.Printer.ColorMode=2

CopiesDescriptionSets 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 TypeInteger

Availability

ExamplerptInvoice.Printer.Copies = 2

ColorMode

Value Description

1 Print in Monochrome

2 Print in Color

Design time N/A

Run time Read / Write

Copies

Design time N/A

Run time Read / Write

DeviceCopies

ActiveReports 2.0 Standard User's Guide | 397

Page 398: 83791925 Active Report 2 0 Standard Edition

DeviceCopiesDescriptionSets 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 TypeInteger

Availability

ExamplerptInvoice.Printer.DeviceCopies = 2

DeviceNameDescriptionSets 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 TypeString

Availability

ExampleDebug.Print rptInvoice.Printer.DeviceName

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

Design time N/A

Run time Read / Write

DeviceName

Design time N/A

Run time Read / Write

Devices

ActiveReports 2.0 Standard User's Guide | 398

Page 399: 83791925 Active Report 2 0 Standard Edition

Data TypeArray of Strings

Availability

Example

' Fill a listbox with the available print devicesFor i = 0 to NDevices – 1

lstDevices.AddItem Devices(i)Next i

DisplayProgressDialogDescriptionDetermines whether the print progress dialog should be displayed while the report is printing.

Data TypeBoolean – Default is True

Availability

Example

rptInvoice.PrintReport FalserptInvoice.Printer.DisplayProgressDialog = False

DPIDescriptionDPI returns the resolution of the currently selected printer device. Note: DPI is the number of Dots Per Inch.

Data TypeLong

Availability

Design time N/A

Run time Read-Only

DisplayProgressDialog

Design time N/A

Run time Read / Write

DPI

Design time N/A

Run time Read

Duplex (Printer)

ActiveReports 2.0 Standard User's Guide | 399

Page 400: 83791925 Active Report 2 0 Standard Edition

Duplex (Printer)DescriptionSets 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 TypeprtDuplex

Settings

Availability

Example

Private Sub ActiveReport_ReportStart()'Sets a report up to be bound like a book'Turn on MirrorMarginsMe.PageSettings.MirrorMargins = True'Sets gutter to .5 in to allow for bindingMe.PageSettings.Gutter = 720'Set duplex to print vertically on both sidesMe.PageSettings.Duplex = ddDXVertical

End Sub

FileNameDescriptionSets or returns file name used to print to a file. If empty, ActiveReports prints to the printer.

Data TypeString

Availability

Example

rptSales.Printer.FileName = "C:\temp\sales.prn"

Value Mnemonic Description

-1 ddDXPrinterDefault The report will use the default setting on the selected printer.

1 ddDXSimplex Turns off duplex printing.

2 ddDXHorizontal Prints horizontally on both sides of the paper.

3 ddDXVertical Prints vertically on both sides of the paper.

Design time Read / Write

Run time Read / Write

FileName

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 400

Page 401: 83791925 Active Report 2 0 Standard Edition

rptSales.PrintReport False

FromPageDescriptionSets 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 TypeLong

Availability

Example

rptSales.Printer.FromPage = 1rptSales.Printer.ToPage = 1rptSales.PrintReport

hDCDescriptionReturns 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 TypeLong

Availability

MaxPageDescriptionMaxPage 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

FromPage

Design time N/A

Run time Read / Write

hDC

Run time Read

MaxPage

ActiveReports 2.0 Standard User's Guide | 401

Page 402: 83791925 Active Report 2 0 Standard Edition

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 TypeLong

Availability

Example

rptSummary.Printer.StartJob' Merge the two reports togetherrptSummary.Printer.MaxPage = rptSummary.Pages.Count + _

rptSales.Pages.Count' Print the summary reportFor Each pg In rptSummary.Pages

rptSummary.Printer.PrintPage pgNext' Print the sales detail reportFor Each pg In rptSales.Pages

rptSummary.Printer.PrintPage pgNext' Close the jobrptSummary.Printer.EndJob

NDevicesDescriptionNDevices returns the number of available printer devices. The printer device names are enumerated in the Devices property.

Data TypeLong

Availability

Example

' Fill a listbox with the available print devicesFor i = 0 to NDevices – 1

lstDevices.AddItem Devices(i)Next i

NPorts

Design time N/A

Run time Read / Write

NDevices

Design time N/A

Run time Read-Only

NPorts

ActiveReports 2.0 Standard User's Guide | 402

Page 403: 83791925 Active Report 2 0 Standard Edition

DescriptionNPorts 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 TypeLong

Availability

Example

' Fill a listbox with the available printer portsFor i = 0 to NPorts – 1

lstPorts.AddItem Ports(i)Next i

Orientation (Printer)DescriptionDetermines 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 TypePrtOrientation

Settings

Availability

Example

' ActiveReports defaults to the current printer settings' to change the default you need to set the orientation' property in the ReportStart eventPrivate Sub ActiveReport_ReportStart()

me.PageSettings.Orientation = ddOLandscapeEnd Sub

Design time N/A

Run time Read-Only

Orientation (Printer)

Value Mnemonic Description

-1 ddODefault Uses printer's default orientation setting

1 ddOPortrait Print along the width of the paper.

2 ddOLandscape Print along the length of the paper.

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 403

Page 404: 83791925 Active Report 2 0 Standard Edition

PaperBinNamesDescriptionReturns a zero-based array of names of PaperBins supported by the current device.

Data TypeVariant (Array of Strings)

Availability

Example

' Fill a listbox (lstPaperBins and lstPaperBinNames)' with paperbin codes and paperbin namesDim i As IntegerWith ActiveReport1.Printer

For i = 0 To Ubound(.PaperBins)lstPaperBins.AddItem .PaperBins(i)

NextFor I = 0 To Ubound(.PaperBinNames)

lstPaperBinNames.AddItem .PaperBinName(i)Next

End With

PaperBinsDescriptionReturns 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 TypeVariant (Array of Integers)

Availability

Example

' Fill a listbox (lstPaperBins and lstPaperBinNames)' with paperbin codes and paperbin namesDim i As IntegerWith ActiveReport1.PrinterFor i = 0 To Ubound(.PaperBins)

lstPaperBins.AddItem .PaperBins(i)NextFor I = 0 To Ubound(.PaperBinNames)

PaperBinNames

Design time N/A

Run time Read

PaperBins

Design time N/A

Run time Read

ActiveReports 2.0 Standard User's Guide | 404

Page 405: 83791925 Active Report 2 0 Standard Edition

lstPaperBinNames.AddItem .PaperBinName(i)NextEnd With

PaperHeight (Printer)DescriptionPaperHeight 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 TypeSingle

Availability

Example

Private Sub ActiveReport_ReportStart()' Specify a custom paper sizeMe.PageSettings.PaperSize = 256' Sets the paper's width to 2 inchesMe.PageSettings.PaperWidth = 1440 * 2' Sets the paper's height to 4 inchesMe.PageSettings.PaperHeight = 1440 * 4

End Sub

PaperSizesDescriptionReturns a reference to the collection of paper sizes the currently selected printer supports.

Data TypePaperSizes

Availability

Example

Private Sub InitPaperSizes()Dim I As IntegerFor I = 0 To rptSummary.Printer.PaperSizes.Count – 1

lstPaperSizes.AddItem rptSummary.Printer.PaperSizes(I)Next I

PaperHeight (Printer)

Design time Read / Write

Run time Read / Write

PaperSizes

Design time N/A

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 405

Page 406: 83791925 Active Report 2 0 Standard Edition

End Sub

PaperWidth (Printer)DescriptionPaperWidth 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 TypeSingle

Availability

Example

Private Sub ActiveReport_ReportStart()' Specify a custom paper sizeMe.PageSettings.PaperSize = 256' Sets the paper's width to 2 inchesMe.PageSettings.PaperWidth = 1440 * 2' Sets the paper's height to 4 inchesMe.PageSettings.PaperHeight = 1440 * 4

End Sub

PortDescriptionSets or returns the current printer port.

Data TypeString

Availability

ExamplerptSummary.Printer.Port = "LPT1"

Ports

PaperWidth (Printer)

Design time N/A

Run time Read / Write

Port

Design time N/A

Run time Read / Write

Ports

ActiveReports 2.0 Standard User's Guide | 406

Page 407: 83791925 Active Report 2 0 Standard Edition

DescriptionA 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 TypeArray - string

Availability

Example

Dim prt As New DDActiveReports2.Printer' Fill a listbox with the available printer portsFor i = 0 to prt.NPorts – 1

lstPorts.AddItem prt.Ports(i)Next i

PrintQualityDescriptionPrintQuality specifies the printer resolution used when printing the report.

Data TypePrtQuality

Settings

Availability

ExamplerptInvoice.PrintQuality = ddPQHigh

Status (Printer)DescriptionReturns the current print job status.

Data Type

Design time N/A

Run time Read / Write

PrintQuality

Value Mnemonic Description

-1 ddPQDraft Draft

-2 ddPQLow Low resolution

-3 ddPQMedium Medium resolution

-4 ddPQHigh High resolution

Design time N/A

Run time Read / Write

Status

ActiveReports 2.0 Standard User's Guide | 407

Page 408: 83791925 Active Report 2 0 Standard Edition

JobStatus

Settings

Availability

ExamplelblStatus.Caption = rptInvoice.Printer.Status

ToPageDescriptionSets 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 TypeLong

Availability

Example

rptSales.Printer.FromPage = 1rptSales.Printer.ToPage = 1rptSales.PrintReport

TrackDefaultDescriptionSpecifies whether changes to the printer options will be reflected in Windows default printer.

Value Mnemonic Description

0 ddJSIdle Idle

1 ddJSPrinting Printing

2 ddJSCompleted Completed

3 ddJSAborted Aborted

Design time N/A

Run time Read Only

ToPage

Design time N/A

Run time Read / Write

TrackDefault

ActiveReports 2.0 Standard User's Guide | 408

Page 409: 83791925 Active Report 2 0 Standard Edition

Data TypeBoolean – Default is False, changes will not be reflected in the printer settings.

Availability

Example

' If user changes printer options in our custome printer' form the changes will be reflected in Windows' default printerrptSummary.Printer.TrackDefault = True' This form displays custom printer settings and' modifies the printer objectfrmPrintSetup.Show vbModal

TwipsPerPixelX, TwipsPerPixelYDescriptionTwipsPerPixelX and TwipsPerPixelY return the number of twips per pixel horizontally (TwipsPerPixelX) or vertically (TwipsPerPixelY).

Data TypeSingle

Availability

Printer Methods

Design time N/A

Run time Read / Write

TwipsPerPixelX, TwipsPerPixelY

Design time N/A

Run time Read

Printer Methods

Method Description

AbortJob 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 | 409

Page 410: 83791925 Active Report 2 0 Standard Edition

AbortJobDescriptionAborts the current print job.

Return TypeNone

SyntaxSub AbortJob()

ParametersNone

EndJobDescriptionEndJob ends a previously started print job. You must call StartJob before calling this method. Otherwise, ActiveReports will fire an error event.

Return TypeNone

SyntaxSub EndJob()

ParametersNone

Example

rptSummary.Printer.StartJob "Sales Report"For Each pg In rptSales.Pages

rptSales.Printer.PrintPage pgNext>' Close the jobrptSummary.Printer.EndJob

EndPage

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

EndJob

EndPage

ActiveReports 2.0 Standard User's Guide | 410

Page 411: 83791925 Active Report 2 0 Standard Edition

DescriptionEndPage ends a previously started page. You must call StartPage before calling this method. Otherwise, ActiveReports will fire an error event.

Return TypeNone

SyntaxSub EndPage()

ParametersNone

Example

Dim rpt As New ActiveReport1Set PageEventHandler = rptrpt.ShowPrintTiled rpt, 3, 3

End Sub Sub PrintTiled(rpt As ActiveReport, rowCount As Integer, colCount As Integer)

Dim row, colDim pagex, pagey, pagew, pageh As IntegerDim margx, margyDim pageNum As Integerrpt.Printer.StartJob "One Page"rpt.Printer.StartPagepagew = (rpt.Printer.PaperWidthActiveReport1.PageSettings.LeftMargin – ActiveReport1.PageSettings.RightMargin) / colCountpageh = (rpt.Printer.PaperHeight – ActiveReport1.PageSettings.TopMargin – _

ActiveReport1.PageSettings.BottomMargin) / rowCountFor row = 0 To rowCount - 1

pagey = (pageh + SPACE_BETWEEN_PAGES) * rowFor col = 0 To colCount - 1

pagex = (pagew + SPACE_BETWEEN_PAGES) * colpageNum = row * colCount + colIf (pageNum < rpt.Pages.Count) Then

rpt.Printer.PrintPage rpt.Pages(pageNum), pagex, pagey, pagew, pageh

End IfNext

Nextrpt.Printer.EndPagerpt.Printer.EndJob

End Sub Private Sub PageEventHandler_PageEnd()

Dim pageObject As CanvasSet pageObject = PageEventHandler.CanvaspageObject.ForeColor = vbBlackpageObject.BackStyle = ddBKTransparentpageObject.PenStyle = 1pageObject.PenWidth = 1pageObject.DrawRect 0, 0, pageObject.Width, pageObject.Height

End Sub

EscapeDescriptionEscape method is used to send raw escape sequences to the printer. Escape sequences allow you to modify custom print setting while printing.

Escape

ActiveReports 2.0 Standard User's Guide | 411

Page 412: 83791925 Active Report 2 0 Standard Edition

Escape sequences start with ASCII character 27 – Chr$(27) followed by an escape sequence of characters.

Return TypeNone

SyntaxSub Escape(Code As String)

Parameters

PrintPageDescriptionPrint 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 TypeNone

SyntaxSub PrintPage(Canvas As Canvas, [left],[top],[width],[height])

Parameters

Example

rptSummary.Printer.StartJob "Sales Report"For Each pg In rptSales.Pages

rptSales.Printer.PrintPage pgNext' Close the jobrptSummary.Printer.EndJob

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

Name Type Description

Code String The escape sequence string to be sent to the printer

PrintPage

Name Type Description

Canvas Canvas A reference to a valid canvas object.

Left, Top, Width, Height (optional)

Long Specifying a left, top, width and height will scale the page's output.

PrintDialog

ActiveReports 2.0 Standard User's Guide | 412

Page 413: 83791925 Active Report 2 0 Standard Edition

Return TypeNone

SyntaxFunction PrintDialog(ParentWindow As Boolean)

Parameters

Example

Private Sub btnPrint()' Display the printer dialog centered within' the current formrpt.Printer.PrintDialog frmReports.hWnd

End Sub

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

Name Type Description

ParentWindow Long Parent window handle to center the dialog within the specified window.

SetupDialog

ActiveReports 2.0 Standard User's Guide | 413

Page 414: 83791925 Active Report 2 0 Standard Edition

Return TypeNone

SyntaxFunction SetupDialog(ParentWindow As Boolean)

Parameters

Example

Private Sub btnPrinterSetup()rpt.Printer.SetupDialog frmReports.hWnd

End Sub

StartJobDescriptionStarts a new printing job.

Return TypeNone

SyntaxSub StartJob(DocumentName As String)

Parameters

Name Type Description

ParentWindow Long Parent window handle to center the dialog within the specified window.

StartJob

Name Type Description

DocumentName String The name of the job as it would appear in the spooler's list of jobs.

ActiveReports 2.0 Standard User's Guide | 414

Page 415: 83791925 Active Report 2 0 Standard Edition

Example

rptSummary.Printer.StartJob "Sales Report"For Each pg In rptSales.Pages

rptSales.Printer.PrintPage pgNext' Close the jobrptSummary.Printer.EndJob

StartPageDescriptionStarts a new page inside a print job. This is used to output multiple scaled canvas objects on the same page.

Return TypeNone

Syntax

Dim rpt As New ActiveReport1Set PageEventHandler = rptrpt.ShowPrintTiled rpt, 3, 3

End Sub Sub PrintTiled(rpt As ActiveReport, rowCount As Integer, colCount As Integer)

Dim row, colDim pagex, pagey, pagew, pageh As IntegerDim margx, margyDim pageNum As Integerrpt.Printer.StartJob "One Page"rpt.Printer.StartPagepagew = (rpt.Printer.PaperWidthActiveReport1.PageSettings.LeftMargin – ActiveReport1.PageSettings.RightMargin) / colCountpageh = (rpt.Printer.PaperHeight – ActiveReport1.PageSettings.TopMargin – _

ActiveReport1.PageSettings.BottomMargin) / rowCountFor row = 0 To rowCount - 1

pagey = (pageh + SPACE_BETWEEN_PAGES) * rowFor col = 0 To colCount - 1

pagex = (pagew + SPACE_BETWEEN_PAGES) * colpageNum = row * colCount + colIf (pageNum < rpt.Pages.Count) Then

rpt.Printer.PrintPage rpt.Pages(pageNum), pagex, pagey, pagew, pageh

End IfNext

Nextrpt.Printer.EndPagerpt.Printer.EndJob

End Sub Private Sub PageEventHandler_PageEnd()

Dim pageObject As CanvasSet pageObject = PageEventHandler.CanvaspageObject.ForeColor = vbBlackpageObject.BackStyle = ddBKTransparentpageObject.PenStyle = 1pageObject.PenWidth = 1pageObject.DrawRect 0, 0, pageObject.Width, pageObject.Height

End Sub

StartPage

ActiveReports 2.0 Standard User's Guide | 415

Page 416: 83791925 Active Report 2 0 Standard Edition

RptFieldsRptFields Properties

RptFields Methods

RptField Properties

Name (RptField)DescriptionSets 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 TypeString

Availability

Example

Private Sub ActiveReport_DataInitialize()Fields.Add "OrderID"Debug.Print Fields("OrderID").Name

End Sub

Tag (RptField)DescriptionSets or returns a user defined value associated with the field object.

Data TypeVariant

Availability

RptFields

RptFields Properties

Property Data Type Description

Name String Sets or returns the name of the field.

Tag Variant Sets or returns a user defined value.

Value Variant Sets or returns the current value of the field object.

Name

Run time Read / Write

Tag

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 416

Page 417: 83791925 Active Report 2 0 Standard Edition

Value (RptField)DescriptionSets or returns the current value of the field object.

Data TypeVariant

Availability

Example

Private Sub ActiveReport_FetchData(eof As Boolean)If rs.EOF Then Exit Sub

Fields("Amount").Value = rs!QtyEof = False

End IfEnd Sub

RptFields Methods

Add (RptFields)DescriptionAdds a new custom field to the report's fields collection.

Return TypeRptField object

SyntaxFunction Add(Name As String) As Object

Value

Run time Read / Write

RptFields Methods

Method Description

Add 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

ActiveReports 2.0 Standard User's Guide | 417

Page 418: 83791925 Active Report 2 0 Standard Edition

Parameters

Example

Private Sub ActiveReport_DataInitialize()Fields.Add "Amount"

End Sub

Count (RptFields)DescriptionReturns the number of fields in the collection.

Return TypeInteger

SyntaxFunction Count() As Integer

ParametersNone

Example

For I = 0 To Fields.Count – 1Debug.Print Fields(I).Value

Next

ItemDescriptionReturns the field object at the specified index. Item is the default method of the RptFields collection.

Return TypeObject

SyntaxFunction Item(Index As Object)

Parameters

Name Type Description

Name String New field name, used as a key in the collection.

Count

Item

Name Type Description

Index Variant 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 | 418

Page 419: 83791925 Active Report 2 0 Standard Edition

Remove (RptFields)DescriptionRemoves the field at the specified index from the collection.

Return TypeNone

SyntaxSub Remove(Index)

Parameters

RemoveAll (RptFields)DescriptionRemoves all elements from the collection.

Return TypeNone

SyntaxSub RemoveAll()

ParametersNone

Sections CollectionSection Properties

Section Methods

Section Events

Section Properties

Name Type Description

Index Variant The index of the entry to be removed. Can be the ordinal index or the key of the field in the collection.

RemoveAll

Sections

Section Properties

Property Data Type Description

BackColor OLE_COLOR Sets or returns the background color of a section. The setting will be reflected when the BackStyle property is set to ddBKNormal.

BackStyle Integer Sets or returns whether the object has a transparent or normal background. Transparent background makes the objects behind the section visible.

CanGrow Boolean Determines if the section is allowed to

ActiveReports 2.0 Standard User's Guide | 419

Page 420: 83791925 Active Report 2 0 Standard Edition

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.

ColumnCount Integer Sets or returns the number of columns in the section.

ColumnDirection ColumnDirections Sets or returns the direction to use when printing multiple columns.

ColumnLayout Boolean Determines if a group header or footer section should reflect the column setting of it detail.

ColumnSpacing Single Sets or returns the space between columns in multicolumn report (in twips)

Controls Controls Returns a reference to the controls collection placed in the section.

DataField String 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.

GroupValue Variant 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.

GrpKeepTogether GrpKeepTogether Applies to group header sections. Determines if the group can be separated from its detail section.

Height Single Specifies the height of the section in twips.

IsRepeating Boolean Returns true if the section is repeating from last page.

KeepTogether Boolean Determines if the section can be split across pages if it does not fit in the available area on a page.

Name String Returns the unique name of a section.

NewColumn NewPageConstants 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.

NewPage NewPageConstants 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.

PrintAtBottom Boolean Sets or returns whether or not the GroupFooter or ReportFooter should be printed at the bottom of the page.

Repeat RepeatStyle Determines whether a group section should be repeated at the beginning of a new page if its detail was split across pages.

Script String Sets or returns the script being used for the section.

Type SectionType Returns the type of the section (ReportHeader, Detail, Etc.)

UnderlayNext Boolean Determines whether the section should print underneath the following section. The following section will start printing

ActiveReports 2.0 Standard User's Guide | 420

Page 421: 83791925 Active Report 2 0 Standard Edition

BackColor (Section)DescriptionSets or returns the background color of a section. The setting will be reflected when the BackStyle property is set to ddBKNormal.

Data TypeOLE_COLOR

Availability

Example

rptAuthors.Detail.BackColor = vbBluerptAuthors.Detail.BackStyle = ddBKNormal

BackStyle (Section)DescriptionSets or returns whether the section has a transparent or normal background.

Data TypeBackStyle

Settings

Availability

Example

rptAuthors.Detail.BackColor = vbBluerptAuthors.Detail.BackStyle = ddBKNormal

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

Design time Read / Write

Run time Read / Write

BackStyle

Value Mnemonic Description

0 ddBKTransparent Transparent opaque background, the objects behind the object show through the object.

1 ddBKNormal Normal, the object hides all controls behind it.

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 421

Page 422: 83791925 Active Report 2 0 Standard Edition

CanGrow (Section)DescriptionCanGrow 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 TypeBoolean

Availability

Example

rptAuthors.Detail.CanGrow = FalserptAuthors.Detail.CanShrink = False

CanShrink (Section)DescriptionCanShrink 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 TypeBoolean

Availability

Example

rptAuthors.Detail.CanGrow = FalserptAuthors.Detail.CanShrink = False

ColumnCountDescriptionColumnCount property sets or returns the number of newspaper columns in the report. This property

CanGrow

Design time Read / Write

Run time Read / Write

CanShrink

Design time Read / Write

Run time Read / Write

ColumnCount

ActiveReports 2.0 Standard User's Guide | 422

Page 423: 83791925 Active Report 2 0 Standard Edition

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 TypeInteger

Availability

Example

rptMenu.Detail.ColumnCount = 3rptMenu.Detail.ColumnDirection = ddCDAcrossDown

ColumnDirectionDescriptionColumnDirection property determines how ActiveReports should print the detail section in a multi -column report.

Data TypeColumnDirections

Settings

Availability

Example

rptMenu.Detail.ColumnCount = 3rptMenu.Detail.ColumnDirection = ddCDAcrossDown

Design time Read / Write

Run time Read / Write

ColumnDirection

Value Mnemonic Description

0 ddCDDownAcross Print each section down each column followed by the next column to its right.

1 ddCDAcrossDown Print sections right across the first row followed by the second row and so on.

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 423

Page 424: 83791925 Active Report 2 0 Standard Edition

ColumnLayoutDescriptionColumnLayout 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 TypeBoolean

Availability

ExamplerptShipments.GHLocation.ColumnLayout = False

ColumnSpacingDescriptionSets or returns the space between columns in multicolumn report (in twips).

Data TypeSingle

Availability

ExamplerptAuthors.Detail.ColumnSpacing = .5 * 1440

Controls (Section)DescriptionReturns a reference to the controls collection placed in the section

Data TypeControls

Availability

Example

ColumnLayout

Design time Read / Write

Run time Read / Write

ColumnSpacing

Design time Read / Write

Run time Read / Write

Controls

Run time Read-Only

ActiveReports 2.0 Standard User's Guide | 424

Page 425: 83791925 Active Report 2 0 Standard Edition

Private Sub Detail_BeforePrint()Dim ctrl As ControlDim sec As SectionSet 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 = FalseElse

sec.Controls(Y).Visible = TrueEnd If

End IfNext Y

End Sub

DataField (Section)DescriptionDataField 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 TypeString

Availability

ExampleRptLoans.ghClient.DataField = "CustomerID"

GroupValueDescriptionThis 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

DataField

Design time Read / Write

Run time Read / Write

GroupValue

ActiveReports 2.0 Standard User's Guide | 425

Page 426: 83791925 Active Report 2 0 Standard Edition

bind the group to that field by setting the DataField property to its name.

Data TypeVariant

Availability

Example

Private Sub Detail_Format()' Set the unbound group breaking valueghCountry.GroupValue = dcRptData.Recordset.Fields("Country").Value

End Sub

GrpKeepTogetherDescriptionGrpKeepTogether 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 TypeGrpKeepTogether

Settings

Availability

ExamplerptAuthors.GHCategory.GrpKeepTogether = True

Design time Read / Write

Run time Read / Write

GrpKeepTogether

Value Mnemonic Description

0 ddGrpNone A page can be broken immediately after a group header.

1 ddGrpFirstDetail The group header will print with the first detail section on the same page or column.

2 ddGrpAll The group header, detail and group footer will print together on the same page.

Design time Read / Write

Run time Read / Write

Height

ActiveReports 2.0 Standard User's Guide | 426

Page 427: 83791925 Active Report 2 0 Standard Edition

Height (Section)DescriptionSets 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 TypeSingle

Availability

ExampleRptMain.GHEmployee.Height = 2*1440

IsRepeatingDescriptionReturns true if the section is repeated from last page.

Data TypeBoolean

Availability

Example

Private Sub ghCustomer_Format()If ghCustomer.IsRepeating Then

lblContinued.Caption = "Continued"Else

lblContinued.Caption = ""End If

End Sub

KeepTogetherDescriptionKeepTogether 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 TypeBoolean

Design time Read / Write

Run time Read / Write

IsRepeating

Run time Read

KeepTogether

ActiveReports 2.0 Standard User's Guide | 427

Page 428: 83791925 Active Report 2 0 Standard Edition

Availability

ExamplerptInvoice.Detail.KeepTogether = False

Name (Section)DescriptionSets or returns the unique identifying name of the section.

Data TypeString

Availability

NewColumnDescriptionNewColumn 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 TypeNewPageConstants

Settings

Availability

Example

Private Sub Detail_Format()Static RNumber As LongRNumber = RNumber + 1

Design time Read / Write

Run time Read / Write

Name

Design time Read / Write

Run time Read

NewColumn

Value Mnemonic Description

0 ddNPNone No page-break before the section.

1 ddNPBefore Start printing the section on a new page.

2 ddNPAfter Start a new page after printing the section.

3 ddNPBeforeAfter Start printing the section on a new page and start a new page after printing it.

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 428

Page 429: 83791925 Active Report 2 0 Standard Edition

If RNumber = 6 Then 'If there are 6 records in the column'it will add a new column and reset the counterDetail.NewColumn = ddNPAfterRNumber = 0

ElseDetail.NewColumn = ddNPNone 'This turns off the Add New column

End IfEnd Sub

NewPageDescriptionNewPage 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 TypeNewPageConstants

Settings

Availability

Example

Private Sub Detail_Format()Static RNumber As LongRNumber = RNumber + 1If RNumber = 6 Then 'If there are 6 records on the page

'it will add a new page and reset the counterDetail.NewPage = ddNPAfterRNumber = 0

ElseDetail.NewPage = ddNPNone 'This turns off the Add New page

End IfEnd Sub

PrintAtBottomDescriptionSets 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

NewPage

Value Mnemonic Description

0 ddNPNone No page-break before the section.

1 ddNPBefore Start printing the section on a new page.

2 ddNPAfter Start a new page after printing the section.

3 ddNPBeforeAfter Start printing the section on a new page and start a new page after printing it.

Design time Read / Write

Run time Read / Write

PrintAtBottom

ActiveReports 2.0 Standard User's Guide | 429

Page 430: 83791925 Active Report 2 0 Standard Edition

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 TypeBoolean

Availability

Example

Private Sub GroupFooter1_Format()'Prints GroupFooter at the bottom of the pageGroupFooter1.PrintAtBottom = True

End Sub

RepeatDescriptionRepeat 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 TypeRepeatStyle

Settings

Availability

ExamplerptSales.GHDepartments.Repeat = ddRepeatAll

Script (Section)

Design time Read / Write

Run time Read / Write

Repeat

Value Mnemonic Description

0 ddRepeatNone Do not reprint the group header.

1 ddRepeatOnPage Print the group header at the top of each page within the group's detail sections.

2 ddRepeatOnColumn Print the group header at the top of each column within the group's detail sections.

3 ddRepeatAll Print the group header at the top of each column and page within the group's detail sections.

4 ddRepeatOnPageIncludeNoDetail 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.

Design time Read / Write

Run time Read / Write

Script

ActiveReports 2.0 Standard User's Guide | 430

Page 431: 83791925 Active Report 2 0 Standard Edition

DescriptionSets 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 OnFormat()end subSub OnBeforePrint()end subSub OnAfterPrint()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 TypeString

Availability

Example

Private Sub Command1_Click()Dim vbScript As StringvbScript = "sub OnFormat" & vbCrLfvbScript = 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 = vbScriptActiveReport1.Show

End Sub

Type (Section)DescriptionType property returns the type of the section.

Data TypeSectionType

Settings

Design time Read /Write

Run time Read / Write

Type

Value Mnemonic Description

0 ddSTReportHeader A section that prints once per report before any other report section is printed.

ActiveReports 2.0 Standard User's Guide | 431

Page 432: 83791925 Active Report 2 0 Standard Edition

Availability

Example

Private Sub ActiveReport_ReportStart()Dim ctl As ObjectFor x = 0 To Me.Sections.Count - 1

If Me.Sections(x).Type = 2 ThenSet ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label")ctl.Caption = "Page Header"ctl.Top = 0ctl.Left = 0ctl.Height = 500ctl.Width = 2000ctl.BackStyle = vbNormalctl.BackColor = vbBlue

ElseIf Me.Sections(x).Type = 6 ThenSet ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label")ctl.Caption = "Detail Section"ctl.Top = 0ctl.Left = 0ctl.Height = 500ctl.Width = 2000ctl.BackColor = vbRedctl.BackStyle = vbNormal

ElseIf Me.Sections(x).Type = 3 ThenSet ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label")ctl.Caption = "Page Footer"ctl.Top = 0ctl.Left = 0ctl.Height = 500ctl.Width = 2000ctl.BackColor = vbGreenctl.BackStyle = vbNormal

End IfNext

End Sub

UnderlayNextDescriptionUnderlayNext 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

1 ddSTReportFooter A section that prints once per report, after all detail and group sections are printed.

2 ddSTPageHeader A section that prints once at the top of each page in the report.

3 ddSTPageFooter A section that prints once at the bottom of each page in the report.

4 ddSTGroupHeader A section that prints once before detail sections whenever the group value or the group field value changes.

5 ddSTGroupFooter A section that prints once after detail sections whenever the group value or the group field value changes.

6 ddSTDetail A section that prints once for each record or detail line in the report.

Design time N / A

Run time Read Only

UnderlayNext

ActiveReports 2.0 Standard User's Guide | 432

Page 433: 83791925 Active Report 2 0 Standard Edition

Boolean

Availability

ExampleRptStyles.GHImported.UnderlayNext = True

Visible (Section)DescriptionVisible property determines whether the section is to be printed or not.

Data TypeBoolean

Availability

Example

If doSummary = True thenrptInvolice.Detail.Visible = False

End if

Section Methods

Add (Sections)

Design time Read / Write

Run time Read / Write

Visible

Design time Read / Write

Run time Read / Write

Section Methods

Method Description

Add 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 Updates the section when using a designer control (Professional Version only).

Remove Removes the specified section from the report. Sub Remove(index As Variant)

Add

ActiveReports 2.0 Standard User's Guide | 433

Page 434: 83791925 Active Report 2 0 Standard Edition

DescriptionCreates 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 TypeSection object

SyntaxSub Add(Name As String, insertionIndex As Long, Type As SectionType, height As Long)

Parameters

Example

Dim ar As rptTemplateSet ar = New rptTemplate' Add A Group Header Sectionar.Sections.Add "ghCustomer", 1, ddSTGroupHeader, 370' And always add a matching group footerar.sections.Add "gfCustomer", 3, ddSTGroupFooter, 370' Bind the sectionAr.Sections("ghCustomer").DataSource = "dcRptData"Ar.Sections("ghCustomer").DataField = "CustomerName"

Count (Sections)DescriptionCount method returns the number of section object in the Sections collection.

Return TypeInteger

SyntaxFunction Count() As Integer

ParametersNone

Item (Sections)Description

Name Type Description

Name String Unique name of the new section.

InsertionIndex Integer Position where the new section should be inserted within the current Sections collection.

SectionType SectionType Type of the section to be created (see Section Types in Constants).

Height Long Height of the new section in twips.

Count

Item

ActiveReports 2.0 Standard User's Guide | 434

Page 435: 83791925 Active Report 2 0 Standard Edition

Item method returns a reference to the section object at the specified index.

Return TypeSection object

SyntaxFunction Item(i ndex As Variant) As Object

Parameters

Refresh (Sections)DescriptionUpdates the section when using a designer control (Professional Version only).

Return Typenone

SyntaxSub Refresh()

ParametersNone

Remove (Sections)DescriptionRemove method removes the section at the specified index from the Sections collection.

Return TypeNone

SyntaxSub Remove(index As Variant)

Parameters

Section Events

Name Type Description

Index Variant The index of the section in the collection or unique name of the section.

Refresh

Remove

Name Type Description

Index Variant The index of the section in the collection or unique name of the section.

Section Events

Event Description

AfterPrint This event fires after the section is rendered to the canvas.

ActiveReports 2.0 Standard User's Guide | 435

Page 436: 83791925 Active Report 2 0 Standard Edition

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

SyntaxSub AfterPrint()

Example

Private Sub Detail_AfterPrint()ActiveReport1.Canvas.DrawText "Private", 4 * 1440, _

4 * 1440, 4 * 1440, 4 * 1440End Sub

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

SyntaxSub BeforePrint()

Example

Private Sub ghCountry_BeforePrint()txtPctTotal.DataValue = txtSales.DataValue / txtGrandTotal.DataValue

End Sub

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

BeforePrint

Format

ActiveReports 2.0 Standard User's Guide | 436

Page 437: 83791925 Active Report 2 0 Standard Edition

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

SyntaxSub Format()

Example

Private Sub Detail_Format()' If sales value is > 10000 Then color the field redIf txtSales.DataValue > 10000 Then

TxtSales.ForeColor = vbRedEnd If

End Sub

TOC ObjectTOC Properties

TOC Methods

TOCEntry Properties

TOC Properties

Count (TOC)DescriptionCount property returns the number of TOC entries.

Data TypeLong

TOC

TOC Properties

Property Data Type Description

Count Long Returns the number of entries in the table.

CurrentPage Long Sets or returns the current displayed page.

History History Returns a reference to the history object.

SelectedItem Long Returns the selected item in the TOC tree.

Count

ActiveReports 2.0 Standard User's Guide | 437

Page 438: 83791925 Active Report 2 0 Standard Edition

Availability

CurrentPageDescriptionSets 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 TypeLong

Availability

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 lblPagePrivate Sub btnMove_Click(Index As Integer)

Select Case IndexCase 0 ' First PageIf arv.Pages.Count > 0 Then

arv.TOC.CurrentPage = 0Case 1 ' Previous PageIf arv.TOC.CurrentPage > 0 Then

arv.TOC.CurrentPage = arv.TOC.CurrentPage-1End IfCase 2 ' Next PageIf arv.TOC.CurrentPage < arv.Pages.Count-1 Then

arv.TOC.CurrentPage = arv.TOC.CurrentPage + 1End IfCase 3 ' Last PageIf arv.Pages.Count > 0 Then

arv.TOC.CurentPage = arv.Pages.Count-1End If

End SelectEnd Sub

History (TOC)DescriptionHistory property returns a reference to the navigation history object.

Data TypeHistory

Availability

Run time Read

CurrentPage

Run time Read

History

ActiveReports 2.0 Standard User's Guide | 438

Page 439: 83791925 Active Report 2 0 Standard Edition

Example

' Command button implementations of a custom toolbarPrivate Sub btnBack()

arv.TOC.History.BackEnd SubPrivate Sub btnForward()

arv.TOC.History.ForwardEnd Sub

SelectedItemDescriptionReturns the selected item in a table of contents tree. This property is read-only and available at run time.

Data TypeLong

Availability

TOC Methods

Add (TOC)Description

Run time Read

SelectedItem

Run time Read

TOC Methods

Method Description

Add 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

ActiveReports 2.0 Standard User's Guide | 439

Page 440: 83791925 Active Report 2 0 Standard Edition

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 TypeNone

SyntaxSub Add(text As String)

Parameters

Example

Private Sub ghCategory_AfterPrint()TOC.Add txtCategory.Text

End SubPrivate Sub Detail_BeforePrint()

' Add a TOC entry for each printed product' within its categoryTOC.Add txtProduct.Text & "\" & txtCategory.Text

End Sub

GotoPageDescriptionDisplays the specified page in the report preview window.

Return TypeNone

SyntaxSub GotoPage(PageNumber As Long)

Parameters

Example

' Implementation of custom First Page, Last Page buttonsPrivate Sub btnFirstPage()

' Goto First Pagearv.TOC.GotoPage 0

End SubPrivate Sub btnLastPage()

Name Type Description

Text String Text string identifying the table of contents entry.

GotoPage

Name Type Description

PageNumber Long The page number to be displayed in the viewer

ActiveReports 2.0 Standard User's Guide | 440

Page 441: 83791925 Active Report 2 0 Standard Edition

' Goto Last Pagearv.TOC.GotoPage arv.Pages.Count - 1

End Sub

Item (TOC)DescriptionReturns the table of content entry at the specified index.

Return TypeString

SyntaxFunction Item(index As Long) As String

Parameters

Example

Private Sub arv_TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long)Me.Caption = arv.TOC(ItemIndex).NameMe.Caption = Me.Caption & " Page " & arv.TOC(ItemIndex).pageNumber + 1

End Sub

NavigateDescriptionNavigate method displays the page containing the requested entry.

Return TypeNone

SyntaxSub Navigate(tocEntry As String)

Parameters

Example

Private Sub GotoProduct()' Display a form to get category and product namesfrmGotoProduct.Show vbModalarv.TOC.Navigate sCategory & "\" & sProductName

End Sub

Item

Name Type Description

Index Long The index of the entry to be retrieved.

Navigate

Name Type Description

tocEntry String The table of contents entry string.

ActiveReports 2.0 Standard User's Guide | 441

Page 442: 83791925 Active Report 2 0 Standard Edition

PageNumber (TOC)DescriptionReturns 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 TypeString

SyntaxFunction PageNumber(index As Long)

Parameters

Remove (TOC)DescriptionRemoves the specified entry from the table of contents.

Return TypeNone

SyntaxSub Remove(tocEntry As String)

Parameters

RemoveAllDescriptionClears all entries from the table of contents.

Return TypeNone

SyntaxSub RemoveAll()

Parameters

PageNumber

Name Type Description

Index Variant The index of the entry to be retrieved.

Remove

Name Type Description

tocEntry String The table of contents entry string.

RemoveAll

ActiveReports 2.0 Standard User's Guide | 442

Page 443: 83791925 Active Report 2 0 Standard Edition

None

TOCEntry Properties

Name (TOCEntry)DescriptionSets or returns the name for the specified item in the TOC.

Data TypeString

Availability

Example

Private Sub ActiveReport_TOCSelChange(ByVal ItemIndex As Long)Me.Caption = TOC.Item(ItemIndex).Name

End Sub

PageNumber (TOCEntry)DescriptionSets or returns the page number for the specified item in the TOC. Note: The page numbers begin with 0.

Data TypeLong

Availability

Example

Private Sub ActiveReport_TOCSelChange(ByVal ItemIndex As Long)Me.Caption = "Page " & TOC.Item(ItemIndex).pageNumber

End Sub

TOCEntry Properties

Property Data Type Description

Name String Sets or returns the name for the item entered into the TOC.

PageNumber Long Sets or returns the page number for the item entered into the TOC.

PageOffSet Integer Sets or returns the page offset for the item entered into the TOC.

Name

Run time Read / Write

PageNumber

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 443

Page 444: 83791925 Active Report 2 0 Standard Edition

PageOffSetDescriptionSets 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 TypeInteger

Availability

Tools and ToolbarDDToolbar Properties

DDToolbar Methods

DDTools Methods

DDTool Properties

DDTool Methods

DDToolbar Properties

DisplayTooltipsDescriptionDetermines whether to display screen tooltips when the mouse hovers over a tool.

Data TypeBoolean

Availability

PageOffSet

Run time Read / Write

Tools and Toolbar

DDToolbar Properties

Property Data Type Description

DisplayTooltips Boolean Determines whether to display screen tooltips when the mouse hovers over a tool.

Font StdFont Specified the Font properties of the tool.

Tools DDTools A collection of the tool objects that displayed in the toolbar.

DisplayTooltips

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 444

Page 445: 83791925 Active Report 2 0 Standard Edition

Examplearv.Toolbar.DiaplayTooltips = True

Font (DDToolbar)DescriptionDefines the font properties used to display the tools.

Data TypeStdFont

Availability

Example

Private Sub ActiveReport_ReportStart()arv.Toolbar.Font.Name = "Tahoma"arv.Toolbar.Font.Size = "10"

End Sub

ToolsDescriptionReturns a collection of the tools that are displayed on the toolbar. The tools collection contains 14 standard built-in tools that cannot be removed.

Font

Design time Read / Write

Run time Read / Write

Tools

Value Description

0 Table of Contents

1 Separator

2 Print

3 Separator

4 Copy

5 Separator

6 Find

7 Separator

8 SinglePage

9 MultiPage

10 Separator

11 Zoom Out

12 Zoom In

13 Zoom Percent

14 Separator

15 Page Up

ActiveReports 2.0 Standard User's Guide | 445

Page 446: 83791925 Active Report 2 0 Standard Edition

Data TypeDDTools

Availability

Example

Private Sub btnViewReport_Click()Load frmRptViewerfrmRptViewer.arv.TOCVisible = TruefrmRptViewer.arv.ToolBar.Tools.Add "Printer Setup"frmRptViewer.Show

End SubPrivate Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool)

If tool.Caption = "Printer Setup" Thenarv.Printer.SetupDialog

End IfEnd Sub

DDToolbar Methods

Refresh (DDToolbar)DescriptionCauses the toolbar to repaint itself to reflect changes in the tools collection.

Return TypeNone

SyntaxSub Refresh()

ParametersNone – The toolbar will reflect the changes in its tools collection.

DDTools Methods

16 Page Down

17 Page n of m

18 Separator

19 History List Back

20 History List Forward

Run time Read / Write

DDToolbar Methods

Method Description

Refresh Causes the toolbar to repaint itself to reflect changes in the tools collection. Sub Refresh()

Refresh

DDTools Methods

ActiveReports 2.0 Standard User's Guide | 446

Page 447: 83791925 Active Report 2 0 Standard Edition

Add (DDTools)DescriptionAdds 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:

Return TypeNone

SyntaxSub Add(Caption As String)

Parameters

Method Description

Add 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

Tool Name Tool ID

Table Of Contents 40008

Print 32773

Find 32774

Single Page 40014

Multiple Page 40013

Zoom Out 40006

Zoom In 32775

Zoom 32771

Previous Page 40004

Next Page 40005

Page Edit 32772

History Backward 32776

History Forward 40010

ActiveReports 2.0 Standard User's Guide | 447

Page 448: 83791925 Active Report 2 0 Standard Edition

Example

Private Sub btnAddTools_Click()' arv is the name of an ActiveReports Viewer controlWith arv.Toolbar.Tools

.Addex("Printer Setup").AddIcon("Printer.ico")' Must set the ID property.Item(.Count – 1).ID = 999

End SubPrivate Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool)

If tool.Caption = "Printer Setup" Thenarv.Printer.SetupDialog

End IfEnd Sub

AddExDescriptionAdds 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 TypeNone

SyntaxSub Add(Caption As String)

Parameters

Example

Private Sub btnAddTools_Click()' arv is the name of an ActiveReports Viewer controlWith arv.Toolbar.Tools

.Add "Printer Setup"' Must set the ID property.Item(.Count – 1).ID = 999

End SubPrivate Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool)

If tool.Caption = "Printer Setup" Thenarv.Printer.SetupDialog

End IfEnd Sub

Count (DDTools)Description

Name Type Description

Caption String The tool caption string.

AddEx

Name Type Description

Caption String The tool caption string.

Count

ActiveReports 2.0 Standard User's Guide | 448

Page 449: 83791925 Active Report 2 0 Standard Edition

Returns the number of tools in the collection.

Return TypeLong

SyntaxFunction Count() As Long

ParametersNone

Example

Private Sub btnAddTools_Click()' arv is the name of an ActiveReports Viewer controlWith arv.Toolbar.Tools

.Add "Printer Setup"' Must set the ID property.Item(.Count – 1).ID = 999

End SubPrivate Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool)

If tool.Caption = "Printer Setup" Thenarv.Printer.SetupDialog

End IfEnd Sub

Insert (DDTools)DescriptionInserts a new tools into the tools collection at the specified index.

Return TypeNone

SyntaxSub Insert(Index As Integer, Caption As String)

Parameters

Example

Private Sub AddPrinterSetup()' Inserts a new Printer Setup tool' after the Print Toolarv.Toolbar.Tools.Insert 2, "Printer Setup"arv.Toolbar.Tools(3).ID = 999

End Sub

Item (DDTools)

Insert

Name Type Description

Index Integer Index of the tool where the tool is to be inserted. The new tools is inserted after the specified index.

Caption String Caption string of the new tool

Item

ActiveReports 2.0 Standard User's Guide | 449

Page 450: 83791925 Active Report 2 0 Standard Edition

DescriptionReturns a reference to the tool object at the specified index.

Return TypeDDTool

SyntaxFunction Item(Index As Integer) As DDTool

Parameters

Example

Private Sub btnAddTools_Click()' arv is the name of an ActiveReports Viewer controlWith arv.Toolbar.Tools

.Add "Printer Setup"' Must set the ID property.Item(.Count-1).ID = 999

End SubPrivate Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool)

If tool.Caption = "Printer Setup" Thenarv.Printer.SetupDialog

End IfEnd Sub

DDTool Properties

Caption (DDTool)DescriptionSets or returns caption string of the tool, command button or checkbox.

Data Type

Name Type Description

Index Integer Index of the tool to return

DDTool Properties

Property Data Type Description

Caption String Caption string of the tool.

Checked Boolean Determines the checked state of the tool.

Enabled Boolean Determines whether the tool is enabled or not.

ID Integer Returns the index of the tool.

Style Integer Sets or returns the type of button to use. A button with just an icon or a button with an icon and text.

Tooltip String Sets or returns the string to be displayed when the mouse hovers over the tool.

Type Integer Sets or returns the type of the tool (0-Button, 1-Checkbox, 2-Separator)

Visible Boolean Determines whether the tool is displayed on the toolbar.

Caption

ActiveReports 2.0 Standard User's Guide | 450

Page 451: 83791925 Active Report 2 0 Standard Edition

String

Availability

Example

Private Sub btnAddTools_Click()arv.ToolBar.Tools.Add "Printer Setup"

End SubPrivate Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool)

If tool.Caption = "Printer Setup" Thenarv.Printer.SetupDialog

End IfEnd Sub

CheckedDescriptionDetermines the checked state of a checked button tool. This property applies to custom checked button tool added using Add or Insert.

Data TypeBoolean

Availability

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 WithEnd Sub

Enabled (DDTool)DescriptionDetermines whether a tool is enabled (True) or disabled (False).

Data TypeBoolean

Availability

Design time Read / Write

Run time Read / Write

Checked

Design time Read / Write

Run time Read / Write

Enabled

ActiveReports 2.0 Standard User's Guide | 451

Page 452: 83791925 Active Report 2 0 Standard Edition

Example

' Disable the Print Buttonarv.Toolbar.Tools(2).Enabled = False

IDDescriptionReturns 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 TypeLong

Availability

Example

Private CancelJob As BooleanPrivate Const CONST_PRINTTOOLID As Long = 999Private Sub ActiveReport_ReportStart()

Dim bReturn As BooleanDim cnt As Integer' This overrides the print toolFor cnt = 0 To Me.Toolbar.Tools.Count-1

If "&Print..." = Me.Toolbar.Tools(cnt).Caption ThenMe.Toolbar.Tools(cnt).ID = CONST_PRINTTOOLID

End IfNext 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 BooleanIf CONST_PRINTTOOLID = tool.ID Then

' They clicked the "&Print..." buttonbReturn = Me.Printer.PrintDialog(Me.hWnd)If bReturn Then

Me.PrintReport FalseElseIf Not bReturn Then

CancelJob = TrueEnd If

End IfEnd Sub ' This enables the Print tool after the report finishes processing.Private Sub ActiveReport_ReportEnd()

Dim cnt As LongFor cnt = 0 To Me.Toolbar.Tools.Count-1

If "&Print..." = Me.Toolbar.Tools(cnt).Caption ThenMe.Toolbar.Tools(cnt).Enabled = True

End IfNext cnt

Design time Read / Write

Run time Read / Write

ID

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 452

Page 453: 83791925 Active Report 2 0 Standard Edition

End Sub

Style (DDTool)DescriptionSets 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 TypeInteger

Settings

Availability

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

TooltipDescriptionSets or returns the tooltip help text to be displayed when the mouse hovers over the tool.

Data TypeString

Availability

Example

' Add an Export to RTF buttonarv.Toolbar.Tools.Add "RTF"arv.Toolbar.Tools(arv.Toolbar.Tools.Count-1).Tooltip = _

"Export Report to RTF"

Style

Value Description

0 Show just the icon.

1 Show both the icon and the caption.

Design time Read / Write

Run time Read / Write

Tooltip

Design time Read / Write

Run time Read / Write

ActiveReports 2.0 Standard User's Guide | 453

Page 454: 83791925 Active Report 2 0 Standard Edition

Type (DDTool)DescriptionSets or returns the specified tool's type.

Data TypeInteger

Availability

Settings

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 WithEnd Sub

Visible (DDTool)DescriptionDetermines whether the tool is visible on the toolbar or not.

Data TypeBoolean

Availability

Examplearv.Toolbar.Tools(2).Visible = False

Type

Design time Read / Write

Run time Read / Write

Value Description

0 Specifies a command button

1 Specifies a checked button

2 Specifies a separator

8 Specifies the Page Textbox and Zoom Combobox (read-only)

16 Specifies the Multipage button (read-only)

Visible

Design time Read / Write

Run time Read / Write

DDTool Methods

ActiveReports 2.0 Standard User's Guide | 454

Page 455: 83791925 Active Report 2 0 Standard Edition

DDTool Methods

AddIconDescriptionAttaches an icon to the indicated or added tool.

Return TypeNone

SyntaxSub AddIcon(Picture As StdPicture)

Parameters

Example

Private Sub addButtonsToARV()'Insert the Save button in the sixth'position and assign it an icon and'disable itarv.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

Method Description

AddIcon Attaches an Icon to the indicated tool. Sub AddIcon(Picture As StdPicture)

AddIcon

Name Type Description

Picture StdPicture Path or reference to the icon file.

ActiveReports 2.0 Standard User's Guide | 455