ar2std - dynascape software · activereports 2.0 architectural overview 29 chapter 1 - installation...

471
AR2Std AR2Std | 1

Upload: others

Post on 04-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

AR2Std

AR2Std | 1

Page 2: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Table Of Contents

User's Guide 26

Introduction 26

Using ActiveReports' Documentation 26

Document Conventions 26

Documentation Overview 27

ActiveReports 2.x Features 27

ActiveReports 2.0 Architectural Overview 29

Chapter 1 - Installation 31

Installation Steps 31

Sample Reports 32

Client Distribution 32

Chapter 2 - Using ActiveReports for the First Time 33

Adding ActiveReports to Visual Basic 33

Adding a Report to the Visual Basic Environment 34

User Interface 35

Toolbars 35

Context Menus 38

Report Explorer 38

Fields List 38

Adding Controls to Your Report 39

Adding ActiveX controls and OLE objects 39

Selecting Multiple Controls 40

Moving and Sizing Controls 40

Sizing Sections 41

Control Alignment and Sizing 42

Formatting Controls 42

Quick Start -Creating Your First Report 44

Using ActiveReports' Print Preview 45

Using ActiveReports' Wizard 46

Converting Version 1.0 Reports to Version 2.0 47

Converting Access Reports 47

AR2Std | 2

Page 3: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Converting Crystal Reports 48

Chapter 3 - Printer and Page Settings 49

Using the Page Setup Dialogue 49

Using the Printer Settings Dialogue 49

Changing Page and Printer Setting in Code 50

Chapter 4 - Binding Reports to Data Controls 53

RDO (Remote Data Objects) 53

DAO (Data Access Objects) 54

ADO (ActiveX Data Objects) 54

XML 55

Setting Recordset and Connection Properties 56

Binding Controls to a Data Control 56

Chapter 5 - Bound Reporting and Grouping 57

Simple Table or List Report 57

Using Parameters With Bound Reports 58

Grouping Records 59

Grouping on Calculated Expression 60

Adding a Summary Field in Group Footer 60

Conditional Summary Fields 62

Using Formulas and Calculated Fields 65

Page N of M in the Page Footer 67

Page N of M in the Group Header 67

Chapter 6 - Unbound Reporting and Grouping 68

Unbound Reports 68

Simple Unbound Reports 69

Grouping With Unbound Reports 70

Adding Summary Fields to Unbound Reports 70

Unbound Reporting with Arrays 71

Unbound Reporting with Collections 74

Unbound Reporting with Text Files 76

Chapter 7 - Using Subreports 78

Subreports 78

AR2Std | 3

Page 4: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Bound Subreports 78

Using Parameters with Subreports 82

Embedded Subreports 82

Shaped/Hierarchical Subreports 87

Unbound Subreports 92

Chapter 8 - Dynamic (Run-Time) Reporting 97

Modifying and Formatting Controls at Run Time 98

Creating Dynamic Reports 98

Dynamic Reports 98

Chapter 9 - Creating Reports from an XML Document 101

Bound XML Data Reports 101

XML Data Reports and Subreports 103

XML Reports using LoadXML 107

Chapter 10 - Additional Report Types 107

Top n Reports 108

Master Detail Reports 108

Summary Reports 108

Mail-Merge Reports 108

Columnar Reports 109

Creating Labels 109

Conditional Printing 109

Green-Bar Printout Reports 110

Multi-Page Sections 110

Charts 110

Multiple Records Per Section 111

Modifying the Pages Collection of a Processed Report 111

Report Coding Tips 111

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

Setting Up a Table of Contents 112

Using the TOC with Subreports 112

Using the TOC with Groups 113

Working with the Frame Control 114

Using the Frame Control for a Table 114

AR2Std | 4

Page 5: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Chapter 12 - Hyperlinking, CSS and ActiveReports 115

Using Hyperlinks 116

Using HTML links 116

Using Hyperlinks for Drill-Down reports 117

Using Hyperlinks with the TOC 119

Using the MouseOver event with Hyperlinks 121

Using CSS 122

Creating Global Styles 122

Using Special CSS Styles 123

Chapter 13 - Saving and Loading 123

Saving And Loading RDF Files 124

Using ActiveReports' Export Filters 125

Saving and Loading Canvas Files 128

Saving and Loading Report Layouts 128

Saving and Loading to a Byte Array 129

Chapter 14 - Scripting 129

What are Scripts for? 129

How to Add Scripts 130

Working With Scripts 131

Using RPX Files 133

Chapter 15 - Using ActiveReports' ActiveX Viewer Control 134

ActiveReports' ActiveX Viewer Control 134

Adding the Viewer Control to VB 135

Creating a Custom Preview Screen 135

Using Split Windows on the Viewer Control 136

Adding Buttons to the Viewer Control 137

Controlling Printing and Printer Setup on the Viewer 140

Chapter 16 - ActiveReports on the Web 141

Using the Viewer Control with Internet Explorer 141

Using the Java Viewer Control 142

Creating a ReportServer with ASP and ActiveReports 143

Support and Licensing 146

AR2Std | 5

Page 6: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Production Registration 146

Technical Support 147

Web Site 147

NewsGroups 147

Product Upgrades 148

Suggestions 148

Disk Defects Policy 148

License Agreement and Limited Warranty 148

ActiveReports Error Codes 149

Reference 152

Constants 152

ActiveReports' Architecture 159

Report Sections 159

Report Processing 161

Events 161

Reports Passes 161

Printing Process 162

Common Properties 162

BackColor 162

BackStyle 163

DataField 163

Font 164

ForeColor 165

Common Methods 165

ZOrder 165

ActiveReport 166

ActiveReport Properties 167

AllowSplitter 168

Canvas 168

DocumentName 169

Fields 169

LayoutAction 170

MaxPages 171

AR2Std | 6

Page 7: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

PageBorder 172

PageNumber 172

Pages 173

Parameters 174

ParentReport 174

Printer 175

PrintWidth 175

RulerVisible 176

Sections 176

Script 177

ScriptDebuggerEnabled 178

ScriptLanguage 178

ShowMessages 179

ShowParameterUI 179

Status 180

TOC 180

TOCEnabled 181

TOCVisible 181

TOCWidth 182

ToolbarVisible 182

UserData 183

Version 183

WaterMark 183

WaterMarkAlignment 184

WaterMarkPrintOnPages 185

WaterMarkSizeMode 185

Zoom 186

ActiveReport Methods 186

About 187

AddCode 187

AddControlLicense 188

AddNamedItem 189

AR2Std | 7

Page 8: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Cancel 189

Export 190

LoadLayout 190

Localize 191

PageSetup 192

PrintReport 192

ResetScripts 193

Restart 193

Run 194

SaveLayout 194

Stop 195

ActiveReport Events 195

DataInitialize 197

Error 197

FetchData 198

FindProgress 199

HyperLink 199

KeyDown 200

KeyPress 200

KeyUp 200

MouseOver 201

NoData 201

PageEnd 202

PageStart 202

PrintAborted 202

PrintProgress 203

PromptDialogClosed 203

ReportEnd 204

ReportStart 204

TOCClick 205

TOCSelChange 205

ToolbarClick 205

ARViewer Control 206

AR2Std | 8

Page 9: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ARViewer Properties 206

AllowSplitter 207

BackColor 207

BorderStyle 208

DataPath 208

Object 209

Pages 209

PaperColor 210

Printer 210

ReportSource 211

RulerVisible 211

Status 211

TOC 212

TOCEnabled 213

TOCVisible 213

TOCWidth 213

ToolBar 214

ToolbarVisible 214

UseSourcePrinter 215

Zoom 215

ARViewer Methods 215

CopyPageToClipboard 216

Find 216

Localize 217

MultiplePage 218

PrintReport 218

Refresh 219

SinglePage 219

ARViewer Events 220

DblClk 221

Error 221

FindProgress 222

AR2Std | 9

Page 10: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

hyperLink 223

KeyDown 223

KeyPress 223

KeyUp 224

LoadCompleted 224

MouseDown 224

MouseMove 225

MouseOver 225

MouseUp 226

PageModeChanged 226

PrintAborted 227

TOCClick 227

TOCSelChange 228

ToolbarClick 228

ZoomChanged 229

Border Properties 229

BottomColor, LeftColor, RightColor, TopColor 229

BottomStyle, LeftStyle, RightStyle, TopStyle 230

Shadow 230

Canvas 231

Canvas Properties 231

Alignment 231

BackColor 232

BackStyle 232

Font 233

ForeColor 233

Height 234

Orientation 234

PenStyle 235

PenWidth 236

Tag 236

TextAngle 237

VerticalAlignment 237

AR2Std | 10

Page 11: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Width 238

Canvas Methods 238

Clear 240

DrawEllipse 240

DrawLine 241

DrawPicture 241

DrawPictureLink 241

DrawRect 242

DrawRoundRect 243

DrawText 243

DrawTextLink 244

FillRect 245

IntersectClipRect 245

Load 246

MeasureParagraphHeight 247

MeasureText 248

Overlay 248

PopClipRect 249

PushClipRect 250

Save 251

TextOut 251

Controls 252

Controls Methods 252

Add 252

Count 253

Item 254

Remove 254

RemoveAll 255

BarCode Control Properties 255

Alignment 256

BackColor 256

BarWidth 257

AR2Std | 11

Page 12: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Caption 257

CaptionPosition 258

DataField 258

Direction 259

EnableCheckSum 259

Font 260

ForeColor 260

Style 261

Checkbox Properties 262

Alignment 263

BackColor 263

BackStyle 264

Caption 264

Font 265

ForeColor 265

Style 266

Value 267

Field Control Properties 267

Alignment 268

BackColor 269

BackStyle 269

CanGrow 270

CanShrink 271

ClassName 271

DataField 271

DataValue 272

Font 273

ForeColor 273

hyperLink 274

Multiline 274

OutputFormat 275

Style 275

SummaryDistinctField 276

AR2Std | 12

Page 13: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SummaryDistinctValue 276

SummaryFunc 276

SummaryGroup 277

SummaryRunning 278

SummaryType 278

Text 279

VerticalAlignment 279

WordWrap 280

ZOrder 281

Frames and Panes 282

Frame Control Properties 282

BackColor 282

CanGrow 283

CanShrink 283

CloseBorder 284

Panes 284

ZOrder 284

Panes 285

Pane Properties 285

BackColor 286

BackStyle 286

Border 287

CloseBorder 287

Controls 288

Pane Methods 288

Add 288

Count 289

Item 290

Remove 290

Image Properties 291

BackColor 291

BackStyle 292

AR2Std | 13

Page 14: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ForeColor 292

hyperLink 293

LineColor 293

LineStyle 294

LineWeight 294

Picture 295

PictureAlignment 295

SizeMode 296

ZOrder 296

Label Control Properties 297

Alignment 298

Angle 298

BackColor 299

BackStyle 299

Caption 300

ClassName 301

Font 301

ForeColor 302

hyperLink 302

Multiline 303

Style 303

VerticalAlignment 304

WordWrap 304

ZOrder 305

Line Properties 306

LineColor 306

LineStyle 306

LineWeight 307

X1 307

X2 308

Y1 308

Y2 309

ZOrder 309

AR2Std | 14

Page 15: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

OLE Control 310

OLE Object Properties 310

BackColor 311

BackStyle 311

Class 312

Object 312

PictureAlignment 313

SizeMode 313

VerbCount 314

ZOrder 314

OLE Object Methods 315

CreateEmbedded 316

DoVerb 316

GetUserType 317

GetVerbID 317

GetVerbName 318

InsertObject 318

PageBreak Control Properties 318

Enabled 319

RTF Text Control 319

RTF Text Control Properties 319

BackStyle 321

BulletIndent 321

CanGrow 321

CanShrink 322

GetTab 322

MaxLength 323

Multiline 323

SelAlignment 323

SelBold 324

SelBullet 324

SelCharOffset 325

AR2Std | 15

Page 16: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SelColor 325

SelFontName 326

SelFontSize 326

SelHangingIndent 326

SelIndent 327

SelItalic 327

SelLength 328

SelProtected 328

SelRightIndent 328

SelStart 329

SelStrikeThru 329

SelTabCount 330

SelTabs 330

SelText 330

SelTextBackColor 331

SelUnderline 331

Tag 332

Text 332

TextRTF 332

ZOrder 333

RTF Text Control Methods 334

Clear 334

Copy 334

Cut 335

DeleteField 335

Find 335

InsertField 336

LoadFile 336

Paste 337

ReplaceField 337

SaveFile 338

SelectField 338

Shape Control Properties 339

AR2Std | 16

Page 17: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BackColor 339

BackStyle 340

LineColor 340

LineStyle 341

LineWeight 341

Shape 342

SubReport Control Properties 342

CanGrow 343

CanShrink 343

DataField 344

Object 344

ReportName 345

ZOrder 345

Data Controls 346

ADO 347

ADO Data Control Properties 347

CommandTimeOut 348

Connection 348

ConnectionString 349

ConnectionTimeOut 350

CursorLocation 350

CursorType 351

DataSourceName 351

DefaultDatabase 352

LockType 352

MaxRows 352

NRecords 353

Password 353

Provider 354

RecordSet 354

Source 355

UserID 355

AR2Std | 17

Page 18: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ADO DB Data Control Methods 356

Refresh 356

DAO 356

DAO Data Control Properties 356

Connect 357

DatabaseName 358

DefaultCursorType 358

DefaultType 358

Exclusive 359

MaxRows 359

Options 360

Password 360

Recordset 361

RecordsetType 361

RecordSource 362

SystemDB 362

UserName 363

DAO Data Control Methods 363

Refresh 363

RDO 364

RDO Data Control Properties 364

Connect 365

Connection 366

CursorDriver 366

DataSourceName 366

Environment 367

ErrorTheshold 367

KeysetSize 367

LockType 368

LoginTimeout 368

LogMessages 369

MaxRows 369

Options 369

AR2Std | 18

Page 19: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Password 369

Prompt 370

QueryTimeout 371

Resultset 371

ResultsetType 371

RowsetSize 372

SQL 372

UserName 373

Version 373

RDO Data Control Methods 373

Refresh 374

XML 374

XML Data Control Properties 374

BOF 375

Count 375

CurrentPosition 376

EOF 376

FileURL 376

NodeList 377

RecordSetPattern 377

ValidateOnParse 378

XML Data Control Methods 379

Field 379

LoadXML 380

MoveNext 380

Reset 381

History 381

History Properties 381

Count 381

Position 382

History Methods 383

Back 383

AR2Std | 19

Page 20: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Forward 383

Item 384

Pages and PageSettings 385

PageSettings Properties 385

BottomMargin 386

Collate 386

Duplex 387

Gutter 388

LeftMargin 388

MirrorMargins 389

Orientation 389

PaperBin 390

PaperHeight 391

PaperSize 391

PaperWidth 393

RightMargin 393

TopMargin 394

Pages 394

Pages Properties 395

Password 395

Pages Methods 395

Add 396

Commit 396

Count 397

GetPagesInRange 398

Insert 398

InsertNew 399

Item 399

Load 399

Remove 400

RemoveAll 400

Save 401

PaperSizes Methods 402

AR2Std | 20

Page 21: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Count 402

Item 402

Name 403

Parameters 404

Parameter Properties 404

DefaultValue 404

Key 404

Prompt 405

Tag 406

Value 406

Parameters Methods 407

Count 407

Item 407

Printer 408

Printer Properties 408

Collate 409

ColorMode 410

Copies 410

DeviceCopies 411

DeviceName 411

Devices 411

DisplayProgressDialog 412

DPI 412

Duplex 413

FileName 413

FromPage 414

hDC 414

MaxPage 415

NDevices 415

NPorts 416

Orientation 416

PaperBinNames 417

AR2Std | 21

Page 22: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

PaperBins 417

PaperHeight 418

PaperSizes 419

PaperWidth 419

Port 420

Ports 420

PrintQuality 420

Status 421

ToPage 421

TrackDefault 422

TwipsPerPixelX, TwipsPerPixelY 422

Printer Methods 423

AbortJob 423

EndJob 424

EndPage 424

Escape 425

PrintPage 426

PrintDialog 426

SetupDialog 427

StartJob 428

StartPage 429

RptFields 430

RptFields Properties 430

Name 430

Tag 430

Value 431

RptFields Methods 431

Add 431

Count 432

Item 432

Remove 433

RemoveAll 433

Sections 433

AR2Std | 22

Page 23: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Section Properties 433

BackColor 435

BackStyle 435

CanGrow 436

CanShrink 436

ColumnCount 437

ColumnDirection 437

ColumnLayout 438

ColumnSpacing 439

Controls 439

DataField 439

GroupValue 440

GrpKeepTogether 441

Height 441

IsRepeating 442

KeepTogether 442

Name 442

NewColumn 443

NewPage 443

PrintAtBottom 444

Repeat 445

Script 445

Type 446

UnderlayNext 447

Visible 448

Section Methods 448

Add 448

Count 449

Item 449

Refresh 450

Remove 450

Section Events 450

AR2Std | 23

Page 24: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

AfterPrint 451

BeforePrint 451

Format 452

TOC 452

TOC Properties 452

Count 452

CurrentPage 453

History 453

SelectedItem 454

TOC Methods 454

Add 455

GotoPage 455

Item 456

Navigate 456

PageNumber 457

Remove 457

RemoveAll 458

TOCEntry Properties 458

Name 458

PageNumber 458

PageOffSet 459

Tools and Toolbar 459

DDToolbar Properties 459

DisplayTooltips 460

Font 460

Tools 460

DDToolbar Methods 461

Refresh 461

DDTools Methods 462

Add 462

AddEx 463

Count 464

Insert 464

AR2Std | 24

Page 25: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Item 465

DDTool Properties 465

Caption 466

Checked 466

Enabled 467

ID 467

Style 468

Tooltip 469

Type 469

Visible 470

DDTool Methods 470

AddIcon 470

AR2Std | 25

Page 26: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

User's Guide Introduction

Using ActiveReports' Documentation

Chapter 1 - Installation

Chapter 2 - Using ActiveReports for the First Time

Chapter 3 - Printer and Page Settings

Chapter 4 - Binding Reports to Data Controls

Chapter 5 - Bound Reporting and Grouping< /P>

Chapter 6 - Unbound Reporting and Grouping

Chapter 7 - Using Subreports

Chapter 8 - Dynamic (Run-Time) Reporting< /P>

Chapter 9 - Creating Reports from an XML Document

Chapter 10 - Additional Report Types

Chapter 11 - Organizing Reports with the TOC and Frame Control

Chapter 12 - Hyperlinking, CSS and ActiveReports

Chapter 13 - Saving and Loading

Chapter 14 - Scripting

Chapter 15 - Using ActiveReports' ActiveX Viewer Control

Chapter 16 - ActiveReports on the Web

Support and Licensing

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

Using ActiveReports' Documentation Document Conventions

Documentation Overview

Sample Reports

Document Conventions This book uses the following typographical conventions:

User's Guide

Introduction

Using ActiveReports' Documentation

Document Conventions

Convention Descriptionbold Programming language terms in text italic In Syntax italics indicate placeholders for information you would supply.

Dialog box elements are displayed in italics

AR2Std | 26

Page 27: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Documentation Overview ActiveReports' documentation consists of two separate manuals.

Developer's Guide

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

Developer's Reference Manual

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

ActiveReports 2.x Features

ActiveX Designer

ActiveReports is based on the Active Designer specification. This allows a component to be integrated into the hosting design environment while allowing it to make full use of its services.

The designer is a fully compliant ActiveX control and object host. You can insert ActiveX controls or OLE objects, such as graphs and documents, into your reports. OLE objects can be bound to BLOB fields in your database.

User Friendly interface

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

Familiar Programming Language

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

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 keypad Escape means the Escape or Esc key on your keyboard Enter means Enter, Return, or the Carriage Return key on your keyboard Ctrl-Key, Shift Key, and Alt-Key are two key combinations. Press and hold the first key then press the second key and release. For example, Ctrl-Z, press and hold the Control key and press the Z letter key on your keyboard.

Mouse Actions Click: Click the primary (left) mouse button once Right-click: Click the secondary (right) mouse button once Double-click: Click the primary (left) mouse button twice without moving the mouse while clicking Shift-click: Press and hold the SHIFT key on your keyboard and click the primary (left) mouse button

Documentation Overview

ActiveReports 2.x Features

AR2Std | 27

Page 28: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Small Distribution Overhead

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

Powerful Object Model

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

Multithreaded Reporting Engine

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

Table of Contents and Navigation History objects

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

Lightweight, Internet-enabled, ActiveX Control

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

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

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

Online Searchable Knowledgebase

http://www.datadynamics.com/kb

Data Dynamics provides an online searchable knowledgebase allowing all Data Dynamics customers to search for helpful articles on any of Data Dynamics' products. The Knowledgebase contains many useful articles and running samples on ActiveReports2.

New Features

Enhanced ActiveReports 2.0 Viewer Control

The ActiveReports 2.0 viewer control now has several advanced features. Users can preview multiple pages simultaneously, utilize the new text search feature to search through a report for a specified text string, and report pages can now be copied to the clipboard and pasted in another document. The viewer control also has enhanced IntelliMouse support, a splitter control, and the ability to add custom icons.

Expanded Toolbar in the Designer

The designer's toolbar has several new options. The additions include a page setup menu for modifying page settings, printer settings and style layouts during design time. Menus now include options to save and load reports from RPX files (ActiveReports' custom XML file format), a style 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 addition

AR2Std | 28

Page 29: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 RDF export allows for password protection and compression during saving as well as TOC exporting.

ActiveReports 2.0 Architectural Overview

Format

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

Report Header

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

Report Footer

ActiveReports 2.0 Architectural Overview

AR2Std | 29

Page 30: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

A report can have one 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 report's end.

Page Header

A report can have one page header section that prints at the top of each page. It is the first section that prints on the page except when the page contains a report header section. The page header section is used to print column headers, page numbers, a page title or any information that needs to appear at the top of each page.

Page Footer

A report can have one page footer section that prints at the bottom of each page. It is used to print page totals, page numbers or any other information that needs to appear at the bottom of each page.

Group Header, Group Footer

A report can consist of single or multiple (nested) groups, with each group having its own header and footer sections. The header section(s) are inserted and printed immediately before the detail section. The footer section(s) are inserted and printed immediately after the detail section.

The number of times each group section prints depends on how the data is grouped. ActiveReports starts a new group (Header, Detail, and Footer) when the data to which the group is bound changes.

Detail

A report has one detail section. The detail section is the body of the report and one instance is created for each record in the report.

Report Processing

The speed in processing and output generation of ActiveReports is attributed to its intelligent, 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 Process

ActiveReports output can be printed using different methods. The simplest is to call the PrintReport method. When the PrintReport method is called, ActiveReports checks to determine if the report has been processed earlier. If not, it starts the report processing to create the Pages collection. Then it starts a new print job and prints each page in the collection then ends the print job.

You can call the Stop or Cancel methods while the report is processing or printing. Both methods will cause the print job to end. The Stop method will continue to print processed pages before closing the print job. The Cancel will immediately close the print job and clear the pages collection.

In addition, you can call the Run method to process the report and create the pages collection. Next, start a print job using the Printer.StartJob method. Then, selectively print pages from the collection using the Printer.PrintPage method. Finally, close the print job using the Printer.EndJob method.

If you use background printing using Run(True) you will receive PrintProgress events. The Status property is updated while the report is printing in the background.

Section Events

Regardless of the sections type or content, there are three events for each section: Format, BeforePrint, and AfterPrint.

Because there are so many possible report designs, the event firing sequence must be dynamic in order to accommodate individual report demands.

Out of these three events, the Format event is generally used the most, followed by the BeforePrint event, and in rare circumstances, the AfterPrint event.

Note: The only guaranteed sequence of events is for each section to fire the Format event before firing the

AR2Std | 30

Page 31: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BeforePrint event, which in turn, occurs before the AfterPrint event. However, several 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 ActiveReports Installation Steps

Sample Reports

Client Distribution

Installation Steps 1. Select RUN from the Windows Start Menu.

2. Type <setup file path>\SETUP.EXE.

3. Click OK or press Enter to run the installation program.

4. When prompted, enter your name, organization and serial number.

5. Read the license agreement.

6. Select your installation directory or accept the suggested default directory.

7. Select the directory for the dll and ocx installation or accept the suggested default.

8. Select the components you wish to install.

9. Type the name of the program group or keep the default value.

10. Click Next to proceed with the installation.

11. The installation program will copy all of the selected ActiveReports components to the specified directory and register the control and DLLs in your system registry.

Chapter 1 - Installation

Installation Steps

AR2Std | 31

Page 32: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

12. You are now ready to use ActiveReports 2.

Included Sample Reports The ActiveReports installation includes many sample reports that employ different techniques for report design and programming. All sample reports include one or more pages in the report title section that describe the sample report and the techniques used to accomplish the desired results.

The code behind sections in the sample reports demonstrates many techniques that make ActiveReports a powerful report writer with its fully programmable objects and controls.

Following is a listing of these sample reports and the features that they demonstrate:

Sample Reports

# Name Description1 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. 27 Unbound Demonstrates using ActiveReports in unbound report from a variety of

data sources. 28 XML Demonstrates a variety of XML procedures.

AR2Std | 32

Page 33: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Web Server Distribution

To serve reports to clients in a web environment, your web server should have arview2.cab (if using ActiveReports Viewer Control), actrpt2.dll (always) and arpro2.cab (if using the professional editions end user designer). You should also register any export dlls needed.

Chapter 2 - Using ActiveReports for the First Time Adding ActiveReports to Visual Basic

Adding a Report to the Visual Basic Environment

User Interface

Toolbars

Context Menus

Report Explorer

Fields List

Adding Controls to Your Report

Adding ActiveX Controls and OLE Object

Selecting Multiple Controls

Sizing Sections

Control Alignment and Sizing

Formatting Controls

Quick Start - Creating Your First Report

Using ActiveReports' Print Preview

Using ActiveReports' Wizard

Converting Version 1.0 Reports to Version 2.0

Converting Access Reports

Converting Crystal Reports

Adding ActiveReports to Visual Basic ActiveReports is an ActiveX Designer control; the following steps describe how to include it in your Visual

Client Distribution

File Name DescriptionActRpt2.DLL The Reporting Engine (AR2Pro.dll For Professional Version) 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) 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

Adding ActiveReports to Visual Basic

AR2Std | 33

Page 34: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Basic IDE:

1. Start Visual Basic.

2. Choose Project > Components (Ctrl-T).

3. Click on the DesignersTab:

4. Choose Data Dynamics ActiveReports 2.0. If the ActiveReports entry does not appear in the list, make sure that "Selected Items Only" is not checked. If it still doesn't appear make sure that ActRpt2.DLL is registered by running regsvr32 on ActRpt2.DLL.

Note: If you have ActiveReports 1 installed you can use ActiveReports 1 and ActiveReports 2 side by side as seen in the image provided.

5. Click OK to close the dialog box.

Note: ActiveReports is not an ActiveX control, it is an ActiveX designer. So, it should not be referenced in the Controls tab under components. A reference to the appropriate dll is added automatically whenever you add ActiveReports to your project as explained in the next section.

Adding a Report to the Visual Basic Environment To add a new report to your project:

1. Click the Project menu in Visual Basic.

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.

Adding a Report to the Visual Basic Environment

AR2Std | 34

Page 35: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Toolbars

User Interface

Toolbars

AR2Std | 35

Page 36: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

To Move a Toolbar

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

Toolbar's Context Menu

To access a toolbar's context menu, click the right mouse button anywhere in the toolbar's area.

The context menu allows you to show or hide toolbars by selecting the toolbar name from the menu. In addition, you can customize the toolbars or create a new toolbar from the Customize option on the menu.

Customized toolbar settings are saved in a ArToolbarCfg.tb file and they are restored the next time you start ActiveReports.

Main Toolbar

Format Toolbar

Toolbox

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.

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.

AR2Std | 36

Page 37: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Alignment Toolbar

Print Preview Toolbar

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.

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.

AR2Std | 37

Page 38: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Report Explorer ActiveReports provides easy navigation through your report sections and controls by using the report

explorer. To access the report explorer, click on the explorer icon in the main toolbar.

You can navigate by clicking on the tree nodes representing the sections and controls on your report; ActiveReports will select each section or control as you click in the tree.

Fields List The second pane in the report explorer view displays a list of data source fields. The fields list is based on the data control in your report. Once the data control has been set up to connect to a database, the list is populated by clicking on the populate fields button located in this pane.

You can drag and drop fields from the fields list to any section on your report. ActiveReports will automatically create a textbox control for the field you dropped and bind it to the data source for you.

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

AR2Std | 38

Page 39: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Adding Controls to Your Report To add controls to a report:

1. Click the control you want to add in the toolbox.

2. Move the mouse pointer to the section where you want to add the control; the mouse pointer will change to a cross hair.

3. Click and drag the mouse to size the rubber band to the desired size of the control.

4. The control is placed at the specified location and the toolbox current selection changes back to a Select

pointer .

Note: To add multiple copies of the same control, you can hold the Ctrl key while selecting the control from the toolbox and placing the controls in the section.

Note: Line controls can be set to draw horizontally or vertically by holding the Ctrl (horizontal) or Shift (vertical) key while clicking and dragging the mouse.

Adding ActiveX Controls and OLE objects ActiveReports allows full access to OLE objects and ActiveX controls.

To insert an OLE control into your report:

1. Click the control icon from the toolbox.

2. Select the area of the control

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.

Adding Controls to Your Report

Adding ActiveX controls and OLE objects

AR2Std | 39

Page 40: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

To insert an ActiveX control into your report:

1. Select the ActiveX control icon from the toolbox.

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

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

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

1. Hold down the Shift or Ctrl key while you click on the control you want to select.

2. Click in an empty area, and then draw a "rubber-banding" rectangle around all the controls that you want to select. Rubber banding does not allow you to select controls in different section.

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

Moving and Sizing Controls

Selecting Multiple Controls

Moving and Sizing Controls

AR2Std | 40

Page 41: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

You can also adjust a control's size and location by specifying its coordinate properties in Visual Basic's property editor.

Note: When you size a control beyond the boundaries of a section, the section will adjust to contain the control's new size.

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

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

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

Sizing Sections

AR2Std | 41

Page 42: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

and drag it diagonally to change the size.

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

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

l Click the Align Left , Center or Right to align the controls as shown below:

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

Formatting Controls

Setting Font Properties

To format the text of a label or a field control, click on the Ellipse button (& ) of the Font property in Visual Basic's property window. You can set the typeface name, size and other font settings from the standard Font dialog.

In addition, you can use the Format toolbar button and combo-boxes to set those properties for any selected control or controls.

When working with non-English fonts, the language's script must be selected in the font property window and

Control Alignment and Sizing

Formatting Controls

AR2Std | 42

Page 43: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

the language must be available in the system's regional settings.

Setting Foreground and Background Colors

Foreground and background colors can be set using the color drop-down in either Visual Basic's property window or the color palette toolboxes in the Format toolbar.

The Format toolbar background color palette sets both the BackStyle property of the control to Normal and the BackColor property to the specified color. Background colors will not show if the BackStyle of the control is set to Transparent.

The color palette toolboxes can be dragged and floated or docked to any of the window edges for quick access.

Selecting a Border Style

1. ActiveReports allows you to set the border of most controls to a variety of line styles and options. You can set these border styles using the Borders property sheet available from the control's context menu. You can set the borders of a single or multiple controls at the same time.

2. Select a control such as a label or field on your report.

3. Click the right mouse button for the context menu.

4. Select Format Border from the menu.

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

Setting Output Formats

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

AR2Std | 43

Page 44: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Quick Start - Creating Your First Report 1. Start Visual Basic.

2. Create a new Standard EXE project.

3. Add a Data Dynamics' ActiveReport to your project.

4. Select and place a ADO Data Control in the Detail section.

5. Right-click on the ADO Data Control and select Properties to bring up the Data Control's property window.

6. Select Build from the Properties window.

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

Quick Start -Creating Your First Report

AR2Std | 44

Page 45: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

18. Set the Field2 DataField property to Phone (select from drop-down).

19. Click on the Slide control on the ruler beside the PageFooter and drag the PageFooter up to the bottom of the fields.

20. Add a button control to Form1.

21. In the Command1_Click event add the following code:

ActiveReport1.Show

22. Run the project.

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

Using ActiveReports' Print Preview You can use the preview window to preview single or multiple reports at the same time. The following code implements two click events to preview two different reports in the application.

Private Sub btnPreviewProductInventory_Click() Dim rpt As rptProductInventoryByCategory Set rpt = new rptProductInventoryByCategory rpt.show End Sub Private Sub btnPreviewProductList_Click() Dim rpt As rptProductPriceList Set rpt = new rptProductPriceList rpt.show End Sub

ActiveReports' multithreaded engine allows you to create several report instances that will run in parallel.

Running the first report will display the following form.

Using ActiveReports' Print Preview

AR2Std | 45

Page 46: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Using ActiveReports' Wizard ActiveReports' wizard provides an easy step-by-step process to create a new ActiveReport. To create a new report using the wizard, follow these steps:

1. Choose Project > Add Form from Visual Basic's menu or click on the New Form 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

AR2Std | 46

Page 47: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 Reports Access reports can easily be converted to ActiveReports format by running the Access upsizer wizard. Due to

Converting Version 1.0 Reports to Version 2.0

Converting Access Reports

AR2Std | 47

Page 48: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 AccessToAR.exe file located in the ActiveReports installation directory. You will be presented with the following dialog. Follow the steps to convert your reports.

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

Converting Crystal Reports

AR2Std | 48

Page 49: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Chapter 3 - Printer and Page Settings Using the Page Setup Dialog

Using the Printer Settings Dialog

Changing Page and Printer Settings in Code

Using the Page Setup Dialog With ActiveReports 2.0, page settings can be modified at design time, as well as run time. The Page Setup

•dialog (shown below) can be accessed by selecting File Page Setup from the toolbar menu.

From the Page Setup dialog, changes can be made to the page's margins (left, right, top and bottom), a gutter can be specified, and the mirror margins option can be selected.

By setting a Gutter and selecting Mirror Margins, reports can easily be set up for publishing purposes. When Mirror Margins is selected, the report sets the inside margins for opposite pages to be the same width and the outside margins for opposite pages to be the same width. Specifying a Gutter will give extra space between the page's edge and the page's margins. By using these settings, extra space is provided so reports can be bound together.

Using the Printer Settings Dialog With ActiveReports 2.0, printer settings can be modified at design time, as well as run-time. The Print

•Settings dialog (shown below) can be accessed by selecting File Page Setup from the toolbar menu and then selecting the Printer Settings option button from the Report Settings dialog box.

Chapter 3 - Printer and Page Settings

Using the Page Setup Dialogue

Using the Printer Settings Dialogue

AR2Std | 49

Page 50: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 Code With ActiveReports 2.0, page and printer settings can be changed at run time, as well as design time. Through code, the DeviceName (printer) can be changed, as well as all of the printer settings available in the Printer Settings dialog, plus several other printer setting options.

Note: When making changes to the printer settings, the code must be either in the ReportStart event or before.

DeviceName

By specifying a DeviceName, reports can be hard coded to use a certain printer. When Setting the DeviceName, use the full path and name for the printer. For example:

Private Sub ActiveReport_ReportStart() Printer.DeviceName = "\\ServerP01\HP LaserJet 5/5M" End Sub

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

Orientation

A report's orientation can be changed in code by using either of the following syntaxes:

Dim lFlag As Boolean Private Sub ActiveReport_ReportStart()

Changing Page and Printer Setting in Code

AR2Std | 50

Page 51: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

An individual page's orientation can also be set by using a similar call in the PageStart event. For example, the following few lines alternate each page's orientation from portrait to landscape.

Private Sub ActiveReport_PageStart() Static bFlag As Boolean If bFlag Then PageSettings.Orientation = ddOPortrait bFlag = False Else PageSettings.Orientation = ddOLandscape bFlag = True End If End Sub

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

PaperSize

The PaperSize property allows a report to be set to a number of pre-defined paper types. Below is a list of pre-defined PaperSize settings:

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

AR2Std | 51

Page 52: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Note: A can only be used if supports size. If printer does not support specified PaperSize, report will use default PaperSize for the selected printer.

To set the paper size in code, use the following syntax in either the ReportStart or PageStart events.

Dim pgCounter As Integer Private Sub ActiveReport_PageStart() pgCounter = pgCounter + 1 If pgCounter > 1 Then PageSettings.PaperSize = 1 'Letter End If End Sub Private Sub ActiveReport_ReportStart() PageSettings.PaperSize = 5 'Legal End Sub

In this example, the report's first page is set to legal and every page after is set to letter.

By specifying a PaperSize of 256, a custom PaperSize can be defined. For custom paper sizes, a PaperWidth and PaperHeight value will need to be specified.

Private Sub ActiveReport_ReportStart() PageSettings.PaperSize = 256 'Custom PaperSize PageSettings.PaperHeight = 6 * 1440 'Six inches PageSettings.PaperWidth = 6 * 1440 'Six inches End Sub

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

Margins

A report's margins can also be set in code by using the following:

Private Sub ActiveReport_ReportStart() PageSettings.BottomMargin = 720 '1/2 Inch PageSettings.TopMargin = 2880 '2 Inches PageSettings.LeftMargin = 720 '1/2 Inch PageSettings.RightMargin = 720 '1/2 Inch End Sub

Note: Margins are measured in twips, so a 1 inch margin will be equal to 1440 twips.

PrintWidth

Modifying the PrintWidth changes the amount of physical space a report can print to. If the report's size changes during run-time, such as changing a report's orientation when the designer is set to 8.5 inches, the PrintWidth will also need to be adjusted. This makes sure the report fills the entire printable area.

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

AR2Std | 52

Page 53: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub ActiveReport_ReportStart() PageSettings.Orientation = ddOLandscape 'Sets the new printwidth to be 11 inches 'minus the left an right margins Me.PrintWidth = 11 * 1440 - (PageSettings.LeftMargin + PageSettings.RightMargin) '11 inches End Sub

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

Chapter 4 - Binding Reports to Data Controls Using Remote Data Objects (RDO) Data Control

Using Data Access Objects (DAO) Data Control

Using ActiveX Data Objects (ADO) Data Control

Using XML Data Objects (XML) Data Control

Setting Recordset and Connection Properties

Binding Controls to a Data Control

RDO (Remote Data Objects) ActiveReports uses data controls that are similar to Visual Basic's data controls. Our Data Controls use standard Microsoft ADO, DAO, and RDO to connect to data sources.

Note: You can only place one Data Control on a report and the Data Control can only be placed in the detail section of the report.

The RDO Data control allows you to connect to your data source using Remote Data Objects (RDO) libraries. RDO is smaller than DAO and better suited for ODBC connections than DAO. RDO is only available in the Enterprise Edition of Visual Basic.

ADO is now the suggested data access object model recommended by Microsoft for all new applications being created.

DSN Connection

You can connect using a Data Source Name (DSN) by using the Connect property or DataSourceName, UserName and Password properties.

To connect using the DataSourceName property, you can select the DSN from the dropdown list in the property window. Then, type your UserName and Password in the corresponding properties.

To use the Connect property, you should type a valid ODBC connection string in the Connection property. A valid connection string with a DSN is:

DSN=<dsn>;[UID=<userid>;][PWD=<password>]

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

DSN-Less Connection

You can connect to your data source without the use of a DSN by using the Connect Property. You will need to specify the driver name in your connect string.

For example:

Chapter 4 - Binding Reports to Data Controls

RDO (Remote Data Objects)

AR2Std | 53

Page 54: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SQL server

DRIVER={SQL Server};SERVER=MySQLServer;DATABASE=pubs;UID=sa;PWD=admin;

MS Access

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

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

Connecting to Microsoft Access

1. •Set the Connect property to Access from the dropdown list.

2. Set the DatabaseName property to the full pathname of your mdb file drive:\path\filename.mdb.

3. Set the RecordSource property to the name of a table, query, or a valid SQL statement.

4. If the Access Database is locked using a password, set the Connect property to:

";DATABASE=<database path and filename>;Pwd=< password>"

Connecting to ISAM files (dBase, FoxPro, Paradox)

1. Set the Connect property to the ISAM access type from the dropdown list.

2. Set the DatabaseName property to the data file path drive:\path.

3. Set the RecordSource property to a valid SQL statement.

Excel Files

1. Set the Connect property to the ISAM access type from the dropdown list.

2. Set the DatabaseName property to the full pathname of your xls file drive:\path\filename.xls.

3. Set the RecordSource property to the name of the table.

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

Connecting to Microsoft Access using Jet 4.0

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

DAO (Data Access Objects)

ADO (ActiveX Data Objects)

AR2Std | 54

Page 55: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

2. Select Microsoft Jet 4.0 OLE DB Provider >> Click next.

3. Select or enter a database name >> Click test connection.

4. Click okay.

5. Enter a SQL statement into the source box (i.e. Select * from customers).

6. Click okay.

Connecting to SQL Server using SQLOLEDB

1. Right click on the ADO Data Control >> Properties >> Click Build Button.

2. Select Microsoft OLE DB Provider for SQL Server >> Click Next.

3. Select a server.

4. Choose Windows integrated security or a specific username and password.

5. Choose the database to connect to.

6. Click Test Connection >> Click okay.

7. Enter a SQL statement into the source box (i.e. Select * from customers).

8. Click okay.

Note: For further help on connecting ADO data controls to data sources, please consult http://MSDN.Microsoft.com

XML 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//* All nodes //ITEM All ITEM nodes

AR2Std | 55

Page 56: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

As you change the RecordSetPattern, the indicators in the Fields List window will be updated to reflect the new nodes that will be used to iterate through the XML document.

Note: In order to use the XML DataControl, MSXML3, or newer, is required to be on the system.

Setting Recordset and Connection Properties In addition to setting the connection and record source properties (source property for the ADO control) for data controls at design-time or run-time, you can set the Recordset property to a Recordset object at run-time. This allows ActiveReports to reuse the Recordset that you might have open in your VB application.

' Setting the recordset of a data control at run time Dim cn As ADODB.Connection ' ADO Connection Dim rs As ADODB.Recordset ' ADO Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\Program Files\Microsoft Visual" & _ "Studio\VB98\NWIND.MDB;Persist Security Info=False" rs.Open "SELECT * FROM Customers", cn '***************************************** 'DC1 is the name of the ADO data control * 'rptCustomers is the name of the report * '***************************************** rptCustomers.DC1.Recordset = rs rptCustomers.Show 'Preview the report

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

RDO/DAO/ADO Data Binding:

In relational databases, data binding is done through field names. The report assigns field names in the Recordset to each textbox control in the report.

Controls are bound using DataField properties. You can select a DataField from the dropdown list in the property window.

In addition to the above, you can use the Fields List Window to drag and drop fields on any of your report's sections. ActiveReports sets the name and DataField properties accordingly.

XML Data Binding:

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

/ 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

AR2Std | 56

Page 57: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Note: W3C XPath documents are located at:http://www.w3.org/TR/xpath, and a tutorial can be found at: http://www.zvon.org/xxl/XPathTutorial/General/examplesl

Chapter 5 - Bound Reporting and Grouping Simple Table or List Reports

Using Parameters in Reports

Grouping Records

Grouping on a Calculated Expression

Adding a Summary Field in the GroupFooter

Conditional Summary Fields

Using Formulas and Calculating Fields

Page N of M in the PageFooter

Page N of M in the GroupHeader

Simple Table or List Reports The simplest reporting style is a tabular listing of fields from a record source. This sample demonstrates the basics for setting up bound reports by introducing the ideas of using a DataControl and connecting field controls through their DataField property.

1. Create a new Visual Basic EXE.

2. Add two command buttons to Form1.

3. Name the command buttons cmdPrint and cmdPreview.

4. Add ActiveReports to the project.

5. Place the following code under the command buttons on Form1:

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

6. Place an ADO data control on ActiveReport1.

7. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

Note: The samples in this manual use the NorthWind database included with Microsoft Visual Basic.

8. Set the DataControl's source property to the following SQL statement:

SELECT * FROM customers

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

Chapter 5 - Bound Reporting and Grouping

Simple Table or List Report

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

AR2Std | 57

Page 58: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 Reports This sample demonstrates how to use parameters within a report's query string. Parameters allow reports to prompt users for specific bits of information so custom queries can be run. The syntax for setting up a parameter is as follows:

<%[Key • Required]|[Caption • Optional]|[Default Value • Optional]%>

1. Continuing with the sample started above, make the following modification to the DataControl's source property:

SELECT * FROM customers WHERE customerID ="'<%customerID|Enter Customer ID:|ALFKI%>'"

2. Add the following code to the report to close the report if the parameter's dialog is cancelled.

Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) If Cancelled Then Me.Cancel Unload Me End If End Sub

Tip: The PromptDialogClosed event can also be used to validate or format parameters entered by the user.

3. Save and run the report.

When the report is run, the parameter's dialog box will be displayed (shown below). The default value specified in the parameter's syntax is given along with the specified caption.

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

AR2Std | 58

Page 59: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Grouping Records Using the report we created in the first exercise, we will demonstrate grouping in ActiveReports. Reports can be grouped by using GroupHeaders/Footers with their DataField properties set to the database field being grouped on. ActiveReports allows up to 32 nested groupsin a single report.

Note: ActiveReports does not order the records for grouping. It assumes the Recordset is already sorted in the same grouping order. For example, in this exercise, the data source needs to be sorted by Country to get the desired results.

1. Continuing with the report created in the first exercise, select the data control and modify the Source property as follows:

SELECT * FROM Customers ORDER BY Country

2. Select the report's Detail section.

3. Right-click and select Insert to add a Group Header/Footer.

4. Click on the new section "GroupHeader1" to select it.

5. Modify the section's properties as follows:

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 Font.Size 12 Font.Bold True

AR2Std | 59

Page 60: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Grouping on a Calculated Expression Many reports require grouping based on a calculated expression such as the first letter in a company's name or total product sales ranges. This type of grouping can be achieved in ActiveReports by setting the GroupHeader's GroupValue property.

Note: In order to get correct grouping the data source should be sorted by the grouped fields.

Continuing with the project above, we can easily convert the project to group by the first letter of the Company Name.

1. Modify the Data Control's Source property to order the Recordset by CompanyName.

SELECT * FROM Customers ORDER BY CompanyName

2. Remove txtCountry from the GroupHeader.

3. Remove ghOrderGroup's DataField Property.

4. Insert a Label Control into the ghOrderGroup section and set its properties as follows:

5. Add the following code to the FetchData event:

Private Sub ActiveReport_FetchData(EOF As Boolean) If Not EOF Then ghOrderGroup.GroupValue = Left(DataControl1.Recordset.Fields("CompanyName"), 1) lblLetter.Caption = ghOrderGroup.GroupValue End If 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 Footer Summary fields can be added to any section to calculate totals, counts, averages and other aggregations. The summary field's placement dictates when the section containing the field, and sections after it, will be printed. A section with a summary field will be delayed until all the calculations are completed. This allows summary fields to be place ahead of their detail.

Grouping on Calculated Expression

Name lblLetter Caption "A" Height 540

Left 0 Top 0

Width 540 Alignment 2-ddTXCenter

VerticalAlignment 1-ddTXMiddle Font.Size 20 Font.Bold True

Adding a Summary Field in Group Footer

AR2Std | 60

Page 61: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Summary fields are calculated according to the field control's Summary properties. A summary field control is updated with each new detail record. When a field is placed ahead of the detail section (ReportHeader, PageHeader or GroupHeader), the detail section is formatted with each record and the summary field is updated. When all records for the summary level are read, the header section is printed followed by the delayed sections.

Summary fields are controlled by the following field control properties:

SummaryType

Specifies where the field's calculations will be done.

The summary types are:

GrandTotal • Calculates the summary expression once for all detail records in the report.

PageTotal • Calculates the summary expression once for each page.

SubTotal • Calculates the summary expression once per SummaryGroup section.

SummaryFunc

Sets the type of aggregation the summary field will use to calculate its total. Summary function can be set to Sum, Average, Count, Min, Max, Variance and Standard Deviation. In addition, you can set the summary function to calculate based on another field's distinct values.

Distinct summarization is valuable when the field's value repeats in several detail records and the summary function needs to include a single value from all repeating values. For example, transaction records of orders might look like this.

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

SummaryGroup

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

SummaryRunning

Calculates running totals that accumulate with each printing and reset at the specified level.

ddSRGroup - Keeps a running total of the specified field within a single group span.

ddSRALL - Keeps a running summary throughout the whole report.

In this exercise, we will count the number of customers in each group from the previous report. We will add a summary field in the group footer gfOrderGroup.

1. Start by opening the previous project.

2. Set the gfOrderGroup section height to 285.

3. Add a label control to the gfOrderGroup section and set its properties as follows:

Order ID Date Amount1001 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

AR2Std | 61

Page 62: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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

Sales For: 6/5/1996

Sales For: 6/5/1996

Top 0 Width 2070

Name txtCustomerCount Height 270

Left 2160 Top 0

Width 1980

DataField CompanyName SummaryFunc 2-ddSFCount

SummaryGroup ghOrderGroup SummaryType 3-ddSMSubTotal

Alignment 1-ddTXRight

Conditional Summary Fields

Last Name First Name Country SalesLeverling Janet USA 1000 Leverling Janet UK 560 Davolio Nancy USA 2000 Davolio Nancy UK 1067

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

AR2Std | 62

Page 63: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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.

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

6. Place an ADO data control on ActiveReport1.

7. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

8. Set the data control's source property to the following SQL statement.

SELECT DISTINCTROW Employees.Country, Employees.LastName, Employees.FirstName, Orders.ShippedDate, Orders.OrderID, [Order Subtotals].Subtotal AS SaleAmount FROM Employees INNER JOIN (Orders INNER JOIN [Order Subtotals] ON Orders.OrderID = [Order Subtotals].OrderID) ON Employees.EmployeeID = Orders.EmployeeID ORDER BY Orders.ShippedDate Desc

9. Right-click and insert a GroupHeader/Footer.

10. Click on the New Section "GroupHeader1" to select it.

11. Modify the section's properties as follows:

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:

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

AR2Std | 63

Page 64: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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:

Name lblTotalUSA lblTotalUK Caption US Total Sales UK Total Sales Height 270 270

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

AR2Std | 64

Page 65: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

21. Set the Detail sections CanShrink property to True.

22. Add the following code to the Detail_Format event to increment a integer variable for each country's SaleAmount detail item and then set the variable's total value to the separate fields in gfShippedDate_Format sub.

Dim iTotalUSA As Integer Dim iTotalUK as Integer Private Detail_Format() If txtCountry = "USA" Then iTotalUSA = iTotalUSA + txtSaleAmount.DataValue ElseIf txtCountry = "UK" Then iTotalUK = iTotalUK + txtSaleAmount.DataValue End If End Sub Private Sub gfShippedDate_Format() txtTotalUK.DataValue = iTotalUK txtTotalUSA.DataValue = iTotalUSA iTotalUK = 0 iTotalUSA = 0 End Sub

Using Formulas and Calculated Fields In this example, we will create a new report that prints customers sales from the order details records. The report will be grouped and summarized by customer, and total sales will be calculated as the total of the quantity in each detail record multiplied by the product price. This example demonstrates the ability to use a field's DataField property to perform calculations.

1. Create a new ActiveReport as shown in the first tutorial.

2. Insert a ADO data control in the detail section.

3. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

4. Set the data control's source property to the following SQL statement:

SELECT Customers.CompanyName, [Order Details].UnitPrice, [Order Details].Quantity FROM Products INNER JOIN ((Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID WHERE (((DatePart("yyyy",[OrderDate]))=1995)) ORDER BY Customers.CompanyName, Products.ProductName

5. Insert a group header/footer section.

6. Set the GroupHeader properties as follows:

Top 0 540 540 540 540 Width 1530 1440 2520 2790 1440

Font.Bold True True True True True Font.Size 16 Alignment ddTXRight

Using Formulas and Calculated Fields

Name ghCustomer DataField CompanyName

AR2Std | 65

Page 66: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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

Height 765

Name txtCompanyName DataField CompanyName

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

AR2Std | 66

Page 67: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

= Quantity * UnitPrice

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

Using Formulas and Calculated Fields

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

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 Header You can add page numbering to your groups by using the field's PageCount summary type. Page numbers are created using a running summary field.

Page N of M in the Page Footer

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

AR2Std | 67

Page 68: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

1. Add two text fields and two labels to your Group Header section.

2. Set the following properties:

First Field

Second Field

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 Grouping Unbound Reports

Simple Unbound Reports

Grouping with Unbound Reports

Adding Summary Fields to Unbound Reports

Unbound Reporting with Arrays

Unbound Reporting with Collections

Unbound Reporting with Text Files

Unbound Reports ActiveReports gives you complete control to bind reports to any type of data source, including arrays,

Name txtPageNumber SummaryGroup GroupHeader1

SummaryRunning 1-ddSRGroup SummaryType 4-ddSMPageCount

Name txtPageCount SummaryGroup GroupHeader1 SummaryType 4-ddSMPageCount

Name lblPage Caption Page

Name lblOf Caption of

Chapter 6 - Unbound Reporting and Grouping

Unbound Reports

AR2Std | 68

Page 69: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

through its programmable object model. You can create a report without using a data control, and then load the data from your data source into the report's control at runtime.

ActiveReports' Fields property allows data binding between the control and the run-time fields. It also allows the control's DataField property to be set to any of the run-time defined field names.

The DataInitialize and FetchData events are used to define the run-time fields and feed the data values of these fields so they can be used with unbound controls.

Note: These two events can also be used to create calculated fields in bound reports (reports that have a data control).

Simple Unbound Reports This sample demonstrates the fundamentals of using the DataInitialize and FetchData events to set up unbound reports. The DataInitialize event must be used to add fields to the report's fields 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.Connection Dim rs As ADODB.RecordsetPrivate Sub ActiveReport_DataInitialize()

Simple Unbound Reports

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

AR2Std | 69

Page 70: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

8. Run the report.

Grouping with Unbound Reports Continuing with the report created in the first example, this sample will demonstrate how to set up grouping in unbound reports. When setting up grouping, the GroupHeader's DataField property is used in the same manner as a field control's to retrieve the grouping data from the database.

1. Modify the code's SQL statement to match the following:

2. Select the Detail Section in the report.

3. Right-click and Insert a Group Header/Footer.

4. Click on the new section "GroupHeader1" to select it.

5. Modify the section properties as follows:

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.

Grouping With Unbound Reports

Name ghOrderGroup DataField Country

Height 360

AR2Std | 70

Page 71: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Adding Summary Fields to Unbound Reports Continuing with the report created in the previous example, this sample will demonstrate how to add summary fields to unbound reports.

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

2. Place a textbox in the gfOrderGroup section.

3. Set the field's properties as follows:

4. Place a label in the gfOrderGroup Section.

5. Set the label's properties as follows:

6. Run the report.

Adding Summary Fields to Unbound Reports

Name gfOrderGroup Height 500

Name txtCustomerTotal Text CustomerTotal

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

AR2Std | 71

Page 72: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Unbound Reporting with Arrays This sample demonstrates how to set up and use an array with ActiveReports. Reports using arrays use the FetchData and DataInitialize events in the same manner as unbound database reports. When using arrays, it is also important to make sure the report uses the FetchData event to increment the array.

1. Create a new ActiveReport as shown in the first tutorial.

2. Select the Detail Section in the report.

3. Right-click and Insert a Group Header/Footer.

4. Click on the new section "GroupHeader1" to select it.

5. Modify the section properties as follows:

6. Place a textbox in the ghOrderGroup section.

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:

Name ghOrderGroup DataField Country

Height 690 BackColor &H00C0FFFF& BackStyle 1-ddBKNormal

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

AR2Std | 72

Page 73: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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:

12. Add the following code to the report:

Option Explicit Public bLastIsSingle As Boolean Private arr(1 To 12) As OrderItem Private iRow As Integer Private tmpAmount As Currency Private bNewGroup As Boolean Private Type OrderItem OrderNo As Long ProductID As Long ProductName As String Qty As Integer Price As Currency Amount As Currency End Type Private Sub ActiveReport_DataInitialize() Fields.Add "OrderID" Fields.Add "ProductID" Fields.Add "ProductName" Fields.Add "Qty" Fields.Add "Price" Fields.Add "Amount" iRow = LBound(arr) initarray End Sub Private Sub ActiveReport_FetchData(eof As Boolean) If iRow > UBound(arr) Then eof = True Exit Sub End If Fields("OrderID") = arr(iRow).OrderNo

Name gfOrderGroup

Height 330

BackColor &H00FFFFC0&

BackStyle 1-ddBKNormal

Name txtOrderTotal Text OrderTotal

DataField Amount Height 270

Left 7200 Top 0

Width 1440 Alignment 1-ddTXRight

SummaryType 1-ddSMGrandTotal

AR2Std | 73

Page 74: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

13. Run the report.

Unbound Reporting with Collections This sample demonstrates how to set up and use a collection with ActiveReports. Reports using collections use the FetchData and DataInitialize events in the same manner as unbound database reports. When using a collection, it is also important to make sure the report uses the FetchData event to increment the collection.

1. Continuing with the project started in the last example, add two classes to the project and set their properties as follows:

2. Add the following code to the Order class:

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

3. Add the following code to the Orders class:

Option Explicit 'local variable to hold collection Private mCol As Collection Public Function Add(Key As String, Optional sKey As String) As Order 'create a new object

Unbound Reporting with Collections

Name Order Orders

AR2Std | 74

Page 75: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Dim objNewMember As Order Set objNewMember = New Order 'set the properties passed into the method objNewMember.Key = Key If Len(sKey) = 0 Then mCol.Add objNewMember Else mCol.Add objNewMember, sKey End If 'return the object created Set Add = objNewMember Set objNewMember = Nothing End Function Public Property Get Item(vntIndexKey As Variant) As Order 'used when referencing an element in the collection 'vntIndexKey contains either the Index or Key to the collection, 'this is why it is declared as a Variant 'Syntax: Set foo = x.Item(xyz) or Set foo = x.Item(5) Set Item = mCol(vntIndexKey) End Property Public Property Get Count() As Long 'used when retrieving the number of elements in the 'collection. Syntax: Debug.Print x.Count Count = mCol.Count End Property Public Sub Remove(vntIndexKey As Variant) 'used when removing an element from the collection 'vntIndexKey contains either the Index or Key, which is why 'it is declared as a Variant 'Syntax: x.Remove(xyz) mCol.Remove vntIndexKey End Sub Public Property Get NewEnum() As IUnknown 'this property allows you to enumerate 'this collection with the For...Each syntax Set NewEnum = mCol.[_NewEnum] End Property Private Sub Class_Initialize() 'creates the collection when this class is created Set mCol = New Collection End Sub Private Sub Class_Terminate() 'destroys collection when this class is terminated Set mCol = Nothing End Sub

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

Option Explicit Public bLastIsSingle As Boolean Private colOrders As New Orders Private Sub ActiveReport_DataInitialize() Fields.Add "OrderID" Fields.Add "ProductID" Fields.Add "ProductName"

AR2Std | 75

Page 76: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

5. Run the report.

Unbound Reporting with Text Files This sample demonstrates how to set up and use a text file with ActiveReports. Reports using text files use the FetchData and DataInitialize events in the same manner as unbound database reports.

1. Create a new ActiveReport as shown in the first tutorial.

2. Select the PageHeader section and set the section's height to 270.

3. Place four labels in the PageHeader and set their properties as follows:

Unbound Reporting with Text Files

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

AR2Std | 76

Page 77: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 Explicit Private hFile As Integer Private Sub ActiveReport_DataInitialize() hFile = FreeFile Open App.Path & "\Products.txt" For Input As #hFile ' This sets up the fields used in data binding Fields.Add "ProductID" Fields.Add "ProductName" Fields.Add "QuantityPerUnit" Fields.Add "UnitPrice" End Sub Private Sub ActiveReport_FetchData(eof As Boolean) Dim sLine As String Dim arr() As String ' We reached the end of the file we exit leaving the ' eof parameter as True (default except on first call) that will ' tell AR that we are done feeding data ' otherwise we have to set the eof parameter to False so that ' AR continues fetching data, until we're done ' if the report had a data control, the value of the parameter ' will be ignored, AR will always follow the data control's recordset ' EOF property If VBA.eof(hFile) Then eof = True Exit Sub Else eof = False End If Line Input #hFile, sLine arr = Split(sLine, ",") ' Here we set the values of the fields that we defines as unbound ' or user defined. Fields("ProductID").Value = Val(arr(0)) Fields("ProductName").Value = arr(1) Fields("QuantityPerUnit").Value = arr(4) Fields("UnitPrice").Value = arr(5) End Sub Private Sub ActiveReport_ReportEnd() If hFile <> 0 Then Close #hFile

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

AR2Std | 77

Page 78: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

End If End Sub

7. Create a text file named Products.txt in the project's directory.

8. Add the following entries to the text file:

1,Chai,1,1,10 boxes x 20 bags,$18.00,39,0,10,0 2,Chang,1,1,24 - 12 oz bottles,$19.00,17,40,25,0 3,Aniseed Syrup,1,2,12 - 550 ml bottles,$10.00,13,70,25,0

9. Run the report.

Chapter 7 - Using Subreports Subreports

Bound Subreports

Using Parameters with Subreports

Embedded Subreports

Shaped/Hierarchical Subreports

Unbound Subreports

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

You can use subreports to print any of the following types of reports.

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

Adding a Subreport

To insert a Subreport into your report:

1. Click the Subreport control on the toolbox.

2. Place the control in the section where the Subreport will be printed. The Subreport will be executed each time the specified section is printed.

Note: The Subreport will be confined by the width of the control, but the height will grow according the needs of the Subreport.

Linking a Subreport to the Main Report

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

Chapter 7 - Using Subreports

Subreports

Bound Subreports

AR2Std | 78

Page 79: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Bound Subreports The following sample demonstrates the fundaments for using subreports. The sample demonstrates how to set the Subreport control's object property to the child report, and how to modify the child report's record source based off of the data in the parent report to retrieve the correct information.

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

With rptSupplier

1. Insert a ADO data control in the detail section.

2. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

3. Set the data control's source property to the following SQL statement:

SELECT * FROM suppliers ORDER BY country

4. Insert a Group Header/Footer section.

5. Set the GroupHeader's properties as follows:

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

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

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

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

AR2Std | 79

Page 80: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 ID If Not Me.DataControl1.Recordset.EOF Then i_SupID = Me.DataControl1.Recordset!supplierID End If End Sub Private Sub ActiveReport_ReportEnd() Unload subProducts.object Set subProducts.object = Nothing End Sub Private Sub ActiveReport_ReportStart() Set subProducts.object = New rptProducts End Sub Private Sub Detail_Format() 'Sets the subreport's recordsource to the current supplier subProducts.object.DataControl1.Source = "SELECT * FROM products INNER _ JOIN categories ON products.categoryid = categories.categoryid _ WHERE products.supplierID = " & i_SupID End Sub

With rptProducts

1. Insert a ADO data control in the detail section.

2. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

3. Set the data control's source property to the following SQL statement:

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

AR2Std | 80

Page 81: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Width 2970 2160 990 OutputFormat Currency

AR2Std | 81

Page 82: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

12. Run the report.

Using Parameters with Subreports Parameters can be used with subreports to connect the Subreport to the parent report. By setting a parameter for the field that links the parent report to the child report, the parent report can pass the information to the child through the parameters. The main difference when working with subreports is that the Subreport's ShowParametersUI should be set to false.

By adding the following modification to the above code, the previous sample can be adapted to use parameters:

With rptProducts

1. Set the ShowParametersUI to False.

2. Modify the DataControl's source property to match the following:

"SELECT * FROM products INNER JOIN categories ON products.categoryid = categories.categoryid WHERE products.supplierID = <%supplierID%>"

With rptSuppliers

1. Comment out the code in the detail section.

2. Save and run the report.

Embedded Subreports The following sample demonstrates how to set up embedded subreports. When setting up embedded subreports, the principles are the same as setting up a parent-child report, but applied to the child-grandchild reports.

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

With rptEmployees

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

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

AR2Std | 82

Page 83: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Name subOrders Height 900

Left 0

AR2Std | 83

Page 84: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

12. Add the following code to rptSupplier:

Dim empID As Integer Private Sub ActiveReport_FetchData(EOF As Boolean) ' Store the current records employee ID If Not DataControl1.Recordset.EOF Then empID = DataControl1.Recordset!employeeID End If End Sub Private Sub ActiveReport_ReportEnd() ' Unload the subreport's object Unload subOrders.object Set subOrders.object = Nothing End Sub Private Sub ActiveReport_ReportStart() ' Set the subreport control's object the a new rptOrder Set subOrders.object = New rptOrders End Sub Private Sub Detail_Format() Dim s_SQL As String 'Set the SQL string for the rptOders recordset s_SQL = "SELECT DISTINCT Products.ProductName, Products.ProductID, _ Orders.*, [Order Details].*" s_SQL = s_SQL & " FROM Products INNER JOIN (Orders INNER JOIN _ [Order Details] ON Orders.OrderID = [Order Details].OrderID)" s_SQL = s_SQL & " ON Products.ProductID = [Order Details].ProductID_ Where orders.EmployeeID = " s_SQL = s_SQL & empID & " Order By products.ProductName, _ [order details].quantity desc" subOrders.object.DataControl1.Source = s_SQL End Sub

With rptOrders

1. Insert a ADO data control into the Detail section.

2. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

3. Set the data control's source property to the following SQL statement:

SELECT Products.ProductName, Products.ProductID,Orders.*, [Order Details].* FROM Products INNER JOIN (Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID

4. Remove the PageHeader/Footer section.

5. Insert a GroupHeader/Footer section.

6. Set the GroupHeader's properties as follows:

Top 0 Width 9540

Name ghOrders DataField Orders.OrderID

Height 555 GroupKeepTogether 2-All

KeepTogether True BackColor &H008080FF& BackStyle 1-Normal

AR2Std | 84

Page 85: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

8. Place three 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:

12. Add the following code to rptOrders:

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

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 9540

AR2Std | 85

Page 86: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

With rptCustomers

1. Insert a ADO data control into the Detail section.

2. Connect to Nwind.mdb (see Chapter 3 for help with connecting)

3. Set the data control's source property to the following SQL statement:

select * from customers

4. Remove the PageHeader/Footer section.

5. Insert a GroupHeader/Footer section.

6. Set the GroupHeader's properties as follows:

7. Set the GroupFooter's properties as follows:

8. Set the Detail section's 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

AR2Std | 86

Page 87: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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

11. Run the report.

Shaped/Hierarchical Subreports This sample demonstrates how to set up a report and subreports to use Hierarchical Recordset. The example shows how to pass the shaped Recordset to the child reports by setting the Subreport's Recordset to the shaped child Recordset.

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

With rptOrders

1. Insert a ADO data control into the Detail section.

2. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

3. Set the data control's source property to the following SQL statement:

SELECT * FROM Orders

4. Select the newest Microsoft ActiveX Data Object Library from Visual Basic's reference list.

5. Remove the PageHeader/Footer section.

6. Insert a GroupHeader/Footer section.

7. Set the GroupHeader's properties as follows:

Name txtCompanyName txtContactName txtPhone txtAddress txtCity txtPostalCodeDataField 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 lblPostalCodeCaption 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

AR2Std | 87

Page 88: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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:

Height 810 BackColor &H00800000& BackStyle 1-Normal

Name txtShippedDate txtRequiredDate txtShipName txtFreight txtShipAddress txtShipCity DataField ShippedDate RequiredDate ShipName Freight ShipAddress ShipCity

Height 270 270 270 270 270 270 Left 1440 4320 1440 7830 1440 7830 Top 0 0 270 270 540 540

Width 1440 1440 4320 1350 5580 1440 ForeColor White 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

AR2Std | 88

Page 89: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

With rptCustomers

1. Insert a ADO data control into the Detail section.

2. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

3. Set the data control's source property to the following SQL statement:

SELECT * FROM Customers

4. Remove the PageHeader/Footer section.

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

CanShrink True

AR2Std | 89

Page 90: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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 = 380 End Enum Public Property Set sourceRecordSet(ByVal rs As ADODB.Recordset) On Error GoTo errhndler If rs Is Nothing Then Err.Raise ERRS_VBINVALIDPROPERTYVALUE, "rptCustomers.<Property _ End If Set Me.DataControl1.Recordset = rs Exit Property errhndler: Debug.Print Err.Number & Err.Description End Property

With rptEmployees

1. Insert an ADO data control into the Detail section.

2. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

3. Set the data control's source property to the following SQL statement:

BackColor &H00000080& BackStyle 1-Normal

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

AR2Std | 90

Page 91: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SELECT * FROM Employees

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:

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

8. Add the following code to rptCustomers:

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

Height 300 CanShrink True BackColor &H00000080& 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

AR2Std | 91

Page 92: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Exit Property errhndler: Debug.Print Err.Number & Err.Description End Property

9. Run the report.

Using the SubReport's DataField Property

ActiveReports 2.0 also provides an easier way to used shaped/hierarchical recordsets by using the Subreport • •control s DataField property. The report generated above can also be created by setting subCustomers

DataField property to rsCustomers and subEmployees' DataField property to rsEmployee. After setting these •properties, the code in the parent report s Detail_Format and all the code in the child reports are not

needed.

Unbound Subreports This sample demonstrates how to set up unbound subreports by passing information and search criteria from the parent report to the Subreport. This sample demonstrates two different methods for passing the Recordset. One method is to clone the recordset and the second is to establish a new Recordset in the Subreport. When working with unbound reports, it is important to use the DataInitialize and FetchData events to add fields to the report's field collection and retrieve data from the database.

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

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

With rptCustomers

1. Remove the PageHeader/Footer section.

2. Insert a GroupHeader/Footer section.

3. Set the GroupHeader's properties as follows:

4. Place a textbox in the ghCountry section and set its 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

AR2Std | 92

Page 93: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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.Connection Dim rs As ADODB.Recordset Public myCloneRS As ADODB.Recordset Private s_Country As String Private Sub ActiveReport_DataInitialize() Dim cnnStr As String ' Open data base here (called from form) Set cn = New ADODB.Connection Set rs = New ADODB.Recordset Set myCloneRS = New ADODB.Recordset ' Add fields to ActiveReports' Fields Collection Fields.Add "Country" ' Set Connection String and connect to DB cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program _ Files\Microsoft Visual Studio\VB98\NWind.mdb" cn.Open cnnStr ' Set recordset properties and generate recordset rs.CursorType = adOpenStatic

Top 0 Width 2880

Font.Size 22 Font.Bold True

Name lblCustomer lblCity lblPostalCode Caption Customer City Postal Code 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

AR2Std | 93

Page 94: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

rs.LockType = adLockOptimistic rs.Open "Select * from customers order by Country", cn ' Create a clone of the current recordset to use in the subreport Set myCloneRS = rs.Clone End Sub Private Sub ActiveReport_FetchData(EOF As Boolean) ' Exit sub if EOF is true If rs.EOF Then Exit Sub ' Sets ActiveReports' fields collection values to the ' current recordset value Fields("Country").Value = rs!country s_Country = rs!country ' Advance recordset rs.MoveNext If Not rs.EOF Then ' If not EOF set the FetchData's EOF value to False EOF = False End If End Sub Private Sub ActiveReport_ReportEnd() ' Unload the subreport Unload subCustomersClone.object Set subCustomersClone.object = Nothing ' Unload the recordsets and database Set myCloneRS = Nothing Set rs = Nothing Set cn = Nothing End Sub Private Sub ActiveReport_ReportStart() ' Set the subreport's object to a new rptCustomersClone Set subCustomersClone.object = New rptCustomersClone End Sub Private Sub Detail_Format() ' Filter the cloned recordset to select the country country myCloneRS.Filter = "Country = '" & s_Country & "'" End Sub

With rptCustomersClone

1. Remove the PageHeader/Footer section.

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

3. Place three textboxes 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

AR2Std | 94

Page 95: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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.Recordset Private s_CustomerID As String Private Sub ActiveReport_DataInitialize() Fields.RemoveAll ' Add fields to ActiveReports' Fields Collection Fields.Add "Customer" Fields.Add "City" Fields.Add "Country" Fields.Add "PostalCode" Set rsClone = New ADODB.Recordset Set rsClone = rptCustomer.myCloneRS ' Move to the beginning of the cloned recordset If Not rsClone.EOF Or Not rsClone.BOF Then rsClone.MoveFirst End If End Sub Private Sub ActiveReport_FetchData(EOF As Boolean) ' Exit sub if EOF is true If rsClone.EOF Then Exit Sub ' Sets ActiveReports' fields collection values to the ' current recordset value Fields("Customer").Value = rsClone!CompanyName Fields("City").Value = rsClone!City Fields("Country").Value = rsClone!country Fields("PostalCode").Value = rsClone!PostalCode s_CustomerID = rsClone!CustomerID ' Advance recordset rsClone.MoveNext

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

Name subOrders Height 630

Left 0 Top 630

Width 9360

AR2Std | 95

Page 96: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

If Not rsClone.EOF Then ' If not EOF set the FetchData's EOF value to False EOF = False End If End Sub Private Sub ActiveReport_ReportStart() ' set the subreport's object to a new rptOrders Set subOrders.object = New rptOrders End Sub Private Sub Detail_Format() ' Pass the current customer ID to the rptOrders subreport subOrders.object.CustomerID = s_CustomerID End Sub

With rptOrders

1. Remove the PageHeader/Footer section.

2. Insert a GroupHeader/Footer section.

3. Set the GroupHeader's properties as follows:

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:

Name ghOrders Height 60

BackColor &H000040C0& BackStyle 1-Normal

GrpKeepTogether 2-All KeepTogether True

Name gfOrders Height 60

BackColor &H000040C0& BackStyle 1-Normal

GrpKeepTogether 2-All KeepTogether True

Height 270 BackColor &H00C0E0FF& BackStyle 1-Normal CanShrink True

KeepTogether True

Name txtOrdered txtRequired txtShipped txtCost Text Ordered Required Shipped Cost

AR2Std | 96

Page 97: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

7. Add the following code to rptOrders:

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

8. Run the report.

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

Creating Dynamic Reports

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

Chapter 8 - Dynamic (Run-Time) Reporting

AR2Std | 97

Page 98: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Dynamic Reports

Modifying and Formatting Controls at Run Time ActiveReports objects and controls are completely accessible at run time. You can modify the properties of any of the report sections and controls to get a dynamic view of your report.

The format event allows you to modify all properties of the section or controls including height, visibility and other visual properties. This is the only event in which you can modify the printable area of a section. Once this event is completed, any changes to the section's height will not be reflected in the report output.

You can use the BeforePrint event to modify other aspects of the sections or controls in your report.

Creating Dynamic Reports ActiveReports provides you with two powerful methods that allow you to create an ad hoc report based on the user input. The report can include any number of sections and controls and you can adjust the properties of each section or control in your code to lay out the report according to the user's specifications.

To create an ad hoc report at run time, you must have a template of the report you wish to create. This template can be a blank report or a starting point of all your ad hoc reports, which might contain some standard layout.

This template is necessary because the report object is created at run time directly from the main ActiveReport class and it will not inherit the container extended properties such as the Show method, Width and Height properties and so on.

After you create an instance of your report template, you can use the Sections.Add and Controls.Add methods to add new sections and controls to your report. You can add data sources using the built-in data controls, bind your controls to it using the DataSource and DataField properties of bindable controls.

This capability allows you to create ad hoc reports and translate forms and grids in your application into printable reports on the fly.

Dynamic Reports This sample demonstrates how to generate a report at run time by using Sections.Add, and Controls.Add to add controls and sections. As well as use WithEvents to gain access to section events in the class. It is important to remember controls and sections should not be added after the ReportStart event has finished.

1. Add a Visual Basic form to a Project and set its name to frmDynamic.

2. Add a new ActiveReports to the project as shown in the first tutorial.

3. Add a Command Button to the form and set its properties as follows:

Modifying and Formatting Controls at Run Time

Creating Dynamic Reports

Dynamic Reports

Name cmdRun Caption Run Report Height 615

Left 960 Top 240

Width 2295

AR2Std | 98

Page 99: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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

5. Add the following code to frmDynamic:

' Using WithEvents allows access to the different ' section events (_Format,_BeforePrint,_AfterPrint) Dim WithEvents subDetail As DDActiveReports2.Section Dim WithEvents myGHeader As DDActiveReports2.Section Public CustomerID As String Dim rptMain As ActiveReport1 Dim rptSub As ActiveReport1 Private Sub BuildMain() Dim oCtrl As Object Dim hCtrl As Object Dim ghCtrl As Object Dim gfCtrl As Object rptMain.PageSettings.BottomMargin = 720 rptMain.PageSettings.TopMargin = 720 rptMain.documentName = "Customer" 'Setting up a control in the detail section Set oCtrl = rptMain.Sections("Detail").Controls.Add("DDActiveReports2.subreport") With oCtrl .Name = "sub" .Height = 300 .Width = 6000 .Top = 0 .Left = 0 End With 'Add a datacontrol to the main report and set the connection 'ConnectionString and Source. Set oCtrl = rptMain.Sections("Detail").Controls.Add("DDActiveReports2.DataControl") oCtrl.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data _ Source=C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb;_ Persist Security Info=False" oCtrl.Source = "select * from Customers" 'setting up the detail section rptMain.Detail.Height = 300 rptMain.Detail.BackStyle = 1 '1 = normal 0 = transparent rptMain.Detail.BackColor = &HC0C0C0 rptMain.Detail.ColumnCount = 1 rptMain.Detail.KeepTogether = True rptMain.Detail.CanGrow = True rptMain.Detail.CanShrink = True 'Add a report heading and grouping to the report rptMain.Sections.Add "Group", 1, ddSTGroupHeader, 500 Set myGHeader = rptMain.Sections("group") Set subDetail = rptMain.Sections("detail") rptMain.Sections.Add "foot", 3, ddSTGroupFooter, 60 rptMain.Sections("group").GrpKeepTogether = True rptMain.Sections("group").KeepTogether = True rptMain.Sections("group").BackStyle = 1 rptMain.Sections("group").BackColor = &H808080 rptMain.Sections("group").DataField = "CustomerID"

AR2Std | 99

Page 100: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

rptMain.Sections("foot").BackStyle = 1 rptMain.Sections("foot").BackColor = vbBlack 'Add a text field to the group header Set ghCtrl = rptMain.Sections("group").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt1" .Height = 300 .Width = 1500 .Left = 0 .BackStyle = 1 '1 = normal 0 = transparent .BackColor = &H800000 .ForeColor = &HC0FFFF .DataField = "CustomerID" .Border.Shadow = True End With Set ghCtrl = rptMain.Sections("group").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt2" .Height = 300 .Width = 4500 .Top = 100 .Left = 1750 .BackStyle = 1 '1 = normal 0 = transparent .BackColor = &H800000 .ForeColor = &HC0FFFF .DataField = "CompanyName" .Border.Shadow = True End With Set ghCtrl = rptMain.Sections("group").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt3" .Height = 300 .Width = 2500 .Top = 100 .Left = 6500 .BackStyle = 1 '1 = normal 0 = transparent .BackColor = &H800000 .ForeColor = &HC0FFFF .DataField = "ContactName" .Border.Shadow = True End With 'Add a label to the groupfooter rptSub.documentName = "Report Order" rptSub.Detail.BackColor = &HC0C0C0 rptSub.Detail.BackStyle = 1 rptSub.Detail.KeepTogether = False rptSub.Detail.Height = 300 rptSub.Detail.CanGrow = True rptSub.Detail.CanShrink = True Set ghCtrl = rptSub.Sections("detail").Controls.Add("DDActiveReports2.Field") With ghCtrl .Name = "txt1" .Height = 300 .Width = 1500 .Top = 0 .Left = 1 .BackStyle = 1 '1 = normal 0 = transparent .BackColor = &HC0C0C0 .ForeColor = &H800000 .DataField = "OrderDate" .OutputFormat = "MM/DD/YYYY" End With

AR2Std | 100

Page 101: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Creating Dynamic Reports without a Templete DSR

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

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

Chapter 9 - Creating Reports from XML Documents Bound XML Data Reports

XML Data Reports and Subreports

XML Reports using LoadXML

Chapter 9 - Creating Reports from an XML Document

Bound XML Data Reports

AR2Std | 101

Page 102: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Bound XML Data Reports This sample demonstrates the fundamentals for connecting reports to an XML database. One of the main differences when creating reports with XML data is that the DataField property must be set to a valid Xpath expression.

Note: More information on Xpath standards can be found at http://www.w3.org/TR/xpath, and a tutorial can be found at: http://www.zvon.org/xxl/XPathTutorial/General/examplesl

1. Create a new Visual Basic project.

2. Add a new report to the project, as shown in the first tutorial, and set its name to rptCustomer.

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

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.

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

FileURL C:\Customer.xml RecordSet Pattern //CUSTOMER

Name lblCustomers Caption Customers Height 540

Left 0 Top 0

Width 8820 Font.Size 24 Font.Bold True Alignment 2-ddTXCenter

VerticalAlignment 1-ddTXMiddle

AR2Std | 102

Page 103: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 Subreports This sample demonstrates how to use the Subreport's DataField property to pass nodelists from the parent report to the child. Continuing with the project started above, add two more reports to the project and set their properties as follows:

With rptCustomers

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

2. Add the following code to the project:

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

Name srptOrders DataField ORDER

Height 360 Left 0 Top 810

Width 9270

AR2Std | 103

Page 104: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

With srptOrders

1. Remove the PageHeader/Footer section.

2. Set the Detail Section's height to 570.

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

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:

6. Add the following code to the project:

Option Explicit Private Sub ActiveReport_ReportEnd() Unload srptItems.object Set srptItems.object = Nothing End Sub Private Sub ActiveReport_ReportStart() Set srptItems.object = New srptOderItems End Sub

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

AR2Std | 104

Page 105: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

With srptOrderItems

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

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

8. Add an XML DataControl to the report 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 SummaryType 3-ddSMSubTotal

FileURL customer.xml RecordSet Pattern (blank)

AR2Std | 105

Page 106: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 property

When working with XML data the returned fields list is not static like it is when working with tables. Because of this, special operations can be performed based off of the current node by navigating through the XML tree. The current node is indicated by the specified Recordset pattern. In the sample project above, Order is the current node for rptCustomers with the XML databases' structure as follows:

Customers Order Item Item Order Item

Since the current node is Orders, the item and customers information can be reached by using an XPath expression. For example ./Item can be used to access the item node and ../Customers can be used to access the customer's node.

Note: More information on XPath expressions can be found at msdn.microsoft.com/library/psdk/smlsdk/xslr3prn.

For example:

By adding the following code to rptOrderItems, from the sample project above, the project can be modified to check if an item has a publisher (./PUBLISHER). If the item has a publisher the txtTitle field can be modified to include the publisher.

Private Sub Detail_Format() If dc.Field("./PUBLISHER", False) <> "" Then txtTitle.Text = txtTitle.Text & vbCrLf & "Published _ By: " & dc.Field("./PUBLISHER", False) End If End Sub

Returning a NodeList

The DataControl's field property can also return a full NodeList. The code segment below is also a modification of the project above. By using the following code in srptOrder, instead of setting the Subreport control's DataField property to ITEM, the returned NodeList can be passed to the Subreport.

Private Sub Detail_Format() Dim nodList As Object ' This demonstrates the use of nodeList property and ' Field method as an alternative to automatic subreport linking Set nodList = dc.Field("ITEM", True) srptItems.object.dc.NodeList = nodList End Sub

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

AR2Std | 106

Page 107: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

XML Reports using LoadXML Using LoadXML with the XML DataControl allows an XML string to be used with a report. The following sample demonstrates how an XML string can be used to load data into a report.

1. Create a new Visual Basic project.

2. Add a new report to the project, as shown in the first tutorial, and set its name to rptOrderItems.

3. Add an XML DataControl to the report.

4. Add the following code to the ActiveReport_DataInitialize event:

Private Sub ActiveReport_DataInitialize() XMLDataControl1.ValidateOnParse = True XMLDataControl1.RecordsetPattern = "//Order/Customer/Manifest/Item" XMLDataControl1.LoadXML ("<Order><Customer><Name>John _ Doe</Name><Cardnum>131 131 131 131</Cardnum><_ Manifest><Item><ID>204</ID><Title>_ Making the Transition from C++ to the Java(tm)Language</Title>_ <Quantity>1</Quantity><UnitPrice>$10.75<_ /UnitPrice></Item></Manifest><Receipt><_ Subtotal>$23.75</Subtotal><Tax>$2.43</Tax>_ </Receipt></Customer></Order>") End Sub

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

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

7. Save the report and run it.

Chapter 10 - Additional Report Types Top N Reports

Master Detail Reports

Summary Reports

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

Chapter 10 - Additional Report Types

AR2Std | 107

Page 108: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Mail-Merge Reports

Columnar Reports

Creating Labels

Conditional Printing

Green-bar Printout Report

Multi-Page Sections

Charts

Multiple Records per Section

Modifying the Pages Collection of a Processed Report

Report Coding Tips

Top n Reports ActiveReports requires no special handling for Top n Records report styles. You can easily implement such reports by setting your data source to a Top n filtered query. If your data source does not support Top n queries, you can set your query to return your records ordered by the Top n value descending. Then set the MaxRows property to n.

For example, to list the Top 10 customers by their sales number. You can create a query that returns all customer sales ordered by the sales value descending and set the MaxRows property of the data control to 10. ActiveReports will process only 10 records from the sorted query results.

Master Detail Reports Master detail reports are implemented in ActiveReports using a JOIN SQL query and adding a group on the master key. The master records can be placed in the group header and footer sections and the detail records placed in the detail section.

For example, to create a master-detail of orders and order detail records, you can create a query such as:

"SELECT * FROM order, [order details] WHERE orders.OrderID = [order details].OrderID".

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

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

For example, to create a summary of sales of all orders, you can create the same report mentioned above and set the detail height to 0. ActiveReports will print the summary of each order without printing its detail level.

Note: In most instances it is more efficient to use aggregated SQL queries to retrieved summarized data instead of reading through all the records in a database.

Mail-Merge Reports

Top n Reports

Master Detail Reports

Summary Reports

Mail-Merge Reports

AR2Std | 108

Page 109: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ActiveReports supports mail-merge reports using the RichText control. The RichText control can contain field placeholders that are replaceable with their values (merged) at run time.

To create a mail-merged report, insert a RichText control in the detail section of your report; edit the text of your letter as you would a word-processing document. Use the insert field command to add a mail-merge field into the text.

In the detail format event, add the following code to update the field values in the RichText control for each record in your detail section.

Private Sub Detail_Format() With dcRptData.Recordset rtf.ReplaceField("LastName",.Fields("LName").Value) rtf.ReplaceField("FirstName",.Fields("FName").Value) End With End Sub

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

Creating Labels You can use ActiveReports to print any label size by using the newspaper column layout.

To create a report that prints labels to a laser printer labels sheet:

1. Set the report width to the total width of the label sheet.

2. Set the columns property of your Detail section to the number of labels across the page.

3. Adjust the column spacing property, if needed, to increase/decrease the space between columns.

4. Remove the page header and footer sections from your report.

5. Set the height of the Detail section to the exact height of the label.

6. Set the detail section's CanGrow/CanShrink properties to false.

7. Adjust the top, right, bottom and left margins to match the sheet.

8. Finally, place your text and label controls in the column area in the detail section.

Skipping Labels

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

The section will be skipped without moving to the next record in the data source.

Dim iSkipLabels As Integer Private Sub Detail_Format() If iSkipLabels > 0 Then •iSkipLabels = iSkipLabels 1 LayoutAction = ddLAMoveLayout End If End Sub

Columnar Reports

Creating Labels

Conditional Printing

AR2Std | 109

Page 110: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Conditional Printing ActiveReports allows you to print or suppress any control at run time based on a condition in your data. This can be achieved by modifying the Visible property of the control in the Format event of the parent section.

For example, you can print an "Outstanding" label for employees that exceeded their sales goals for the period by adding the following code in the Detail Format event:

Private Sub Detail_Format() If txtEmployeeSales.DataValue > txtEmployeeGoal.DataValue Then lblOutstanding.Visible = True Else lblOutstanding.Visible = False End If End Sub

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

Green-Bar Printout Reports You can create green-bar printouts by alternating the shading or background color of your detail section in the format event.

Dim I As Integer Private Sub Detail_Format() If (I Mod 2) = 0 Then ' Set the detail BackStyle to normal Detail.BackStyle = ddBKNormal Detail.BackColor = vbGreen Else Detail.BackStyle = ddBKTransparent End If I = I + 1 End Sub

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

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

Green-Bar Printout Reports

Multi-Page Sections

Charts

AR2Std | 110

Page 111: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

report. This allows you to fully process the data for the chart and then render it into the main report using the Subreport control. However, this would require going through more than one Recordset, one for the main report and another for the child report.

Multiple Records Per Section LayoutAction property allows you to control how many records are printed in a single section. In the Detail section format event you can set the LayoutAction to ddLANextRecord, which moves the record pointer but keeps the current section active for printing.

This allows you to print multiple records in the same section. You can use this functionality to print Aging reports, calendar of events in a calendar format, and more such reports. See the Samples directory for an

•example of using this powerful feature (Students and Classes Schedule).

Modifying the Pages Collection of a Processed Report ActiveReports caches the printed pages into canvas objects in the Pages collection. Once a report is completed, you can access each canvas object in the collection and modify its contents using the canvas drawing methods.

In addition, you can save and load canvas objects into the collection using the Save and Load methods. You can overlay a preset layout to any of the pages (pre-printed forms) using the Overlay method.

ActiveReports allows you to reorder the pages in the collection and selectively print odd or even pages. You can also change the printer device of each page or group of pages.

Report Coding Tips 1. A control should not be referenced outside of its section. If information from a control in one section

needs to be used in another, use a variable to pass the information.

2. The PageHeader/Footer should not contain bound controls.

3. The PageHeader/Footer should not be used to group information. Grouping should be done with GroupHeaders/Footers.

4. Section events do not fire in a sequential order so reports should not be structured to rely on section event order.

5. The BeforePrint event should be used to do page specific formatting.

6. Controls should not be dynamically added after the ReportStart event finishes.

7. If a report's PrintWidth is greater than the paper's width, a blank page will print after each report page.

8. If a printer does not support a specified PaperSize, the default paper size will be used instead.

9. When working with web servers, it is extremely important to set up the default users for the web site to have read/write permissions to project files, ActiveReport's dlls, the export directory and the database.

10. Once a report finishes running, the report will need to be re-run to reflect any changes to the layout. For example: if the orientation is changed from the print dialog box after a report has run, the report's layout will not be rendered for the new layout until it is re-run.

Chapter 11 - Organizing Reports with the TOC and Frame Control Setting Up a Table of Contents

Multiple Records Per Section

Modifying the Pages Collection of a Processed Report

Report Coding Tips

Chapter 11 - Organizing Reports with the TOC and Frame Control

AR2Std | 111

Page 112: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Using the TOC with Subreports

Using the TOC with Groups

Working with the Frame Control

Using the Frame Control for a Table

Setting Up a Table of Contents Setting up a table of contents 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:

Using the TOC with Subreports The table of contents can also be used in conjunction with subreports to generate a collapsible item tree. By using the "\" when adding an item to the TOC, a level break will be created. The following code demonstrates how to set up TOC to work with subreports.

Private Sub Detail_Format() TOC.Add Me.ParentReport.txtCompanyName & "\" & txtProductName

Setting Up a Table of Contents

Using the TOC with Subreports

AR2Std | 112

Page 113: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

End Sub

The code above generates the following table of contents:

Using the TOC with Groups Depending on the desired page location of each TOC entry, different section events can be used to add the items to the table of contents. For example, using the GroupHeader_Format event will mark the TOC entry at the beginning of the GroupHeader, while using the GroupHeader_AfterPrint event will mark the TOC entry at the end of the GroupHeader. The following code sample demonstrates setting up a table of contents with grouping.

Dim sCountry As String Private Sub ActiveReport_FetchData(EOF As Boolean) If Not DataControl1.Recordset.EOF then sCountry = DataControl1.RecordSet.Fields("country") End if End Sub Private Sub Detail_Format() TOC.Add sCountry & "\" & txtCustomer End Sub Private Sub ghOrderGroup_Format() TOC.Add sCountry End Sub

The code above generates the following table of contents:

Using the TOC with Groups

AR2Std | 113

Page 114: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Working with the Frame Control The frame control adds another element to help organize a report's visible appearance. The frame control makes it easier to set up tables and corrects problems with controls and sections not growing when static objects, such as an image are used. The frame control also has a CloseBorder property to adjust whether or not a line should printed at the bottom of the page if a section spans across multiple pages.

The frame control works by dragging the control into the desired section and adding panes for each column or row needed. Each pane has the ability to split horizontally or vertically. Each pane can also have its own border properties and backcolors specified, as well as contain controls.

Using the Frame Control for a Table This sample demonstrates how to set up a table by using the frame control. It makes use of the unbound grouping project set up in chapter 6.

1. In ghOrderGroup add a frame control and split the frame, vertically, into four panes.

2. Set the width of each pane to equal the width of the label it will contain.

3. On the first three panes set a border on the top, bottom and left side.

4. On the last pane set a border on every side.

5. Set each panes back color to &H00C0C0C0&.

6. Set the frame control's CanShrink property to True.

7. Set ghOrderGroup's CanShrink property to True.

8. In the Detail section, repeat the same process with another frame control for each field control.

9. On the first three panes set a border on the bottom and left side.

Working with the Frame Control

Using the Frame Control for a Table

AR2Std | 114

Page 115: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 Styles Using Hyperlinks:

Chapter 12 - Hyperlinking, CSS and ActiveReports

AR2Std | 115

Page 116: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

l Using HTML Links

l Using Hyperlinks for DrillDown Reports

l Using Hyperlinks with the TOC

l Using the MouseOver Event with Hyperlinks

Using Style Class:

l Creating Global Styles

l Using Special Style Classes

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

Using HTML links This sample project demonstrates setting up labels with HTML style hyperlinks.

1. Create a new ActiveReport, as shown in the first tutorial, and set the report's name to rptRDFs.

2. Insert an ADO data control into the Detail section.

3. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

4. Set the data control's source property to the following SQL statement:

SELECT * FROM Suppliers ORDER BY CompanyName

5. Change the PageFooter's Height to 930.

6. Place a line control in the PageFooter and set its properties as follows:

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

AR2Std | 116

Page 117: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 Integer Dim sHTML As String 'This strips out the url from the database entry and 'replaces the "#" character If txtHomePage.Text <> "" Then iStart = InStr(1, txtHomePage.Text, "#", vbTextCompare) sHTML = Right(txtHomePage.Text, (Len(txtHomePage.Text) - iStart)) sHTML = Replace(sHTML, "#", "", 1, -1, vbTextCompare) txtHomePage.Hyperlink = sHTML txtHomePage.Text = Replace(txtHomePage.Text, "#", " ", 1, -1, vbTextCompare) End If End Sub

10. Save the project and run it.

Using Hyperlinks for Drill-Down reports This sample project demonstrates how to emulate drill-down reporting by using the report's HyperLink event to run and preview the child reports.

1. Continuing with the project above, add a second report to the project and set its properties as follows:

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

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

AR2Std | 117

Page 118: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

5. Insert a GroupHeader/Footer section.

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 txtUnitPriceText ProductName QuantityPerUnit UnitPrice

DataField ProductName QuantityPerUnit UnitPrice Height 270 270 270

Left 0 4230 7200 Top 0 0 0

Width 4140 2880 1440

AR2Std | 118

Page 119: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 Integer Private Sub ActiveReport_FetchData(EOF As Boolean) If Not EOF Then 'Gets the current records SupplierID i_CompanyID = DataControl1.Recordset.Fields("SupplierID") End If End Sub

3. Add the following code to the ActiveReport_hyperlink event:

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

4. Add the following lines to the Detail_Format Event:

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

5. Save the project and run the report

Using Hyperlinks with the TOC This sample project demonstrates how to use the hyperlink property to reference back to the TOC. In this sample, a directory is set up to match the items entered in the TOC.

1. Continuing with the project above, add a second report to the project and set its name to arTOC.

2. Set the PageHeader's height to 1080.

3. Place three labels in the PageHeader and set their properties as follows:

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

Width 9360 2790 1170

AR2Std | 119

Page 120: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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.TOC Private iEntry As Integer Private Sub ActiveReport_FetchData(eof As Boolean) iEntry = iEntry + 1 If iEntry >= PrintTOC.Count + 1 Then Exit Sub eof = False End Sub Private Sub ActiveReport_Initialize() Set PrintTOC = Nothing End Sub Private Sub ActiveReport_ReportStart() If PrintTOC Is Nothing Then Me.Cancel End If End Sub

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

AR2Std | 120

Page 121: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

With rptWebLinks

1. Adjust the ActiveReport_hyperLink event to check to see if a TOC hyperlink has been selected:

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

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

TOC.Add txtCompanyName

3. Add the following code to the ActiveReport_ReportEnd event:

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

4. Save the project and run it.

Using the MouseOver Event with Hyperlinks The report and viewer control both have MouseOver events, giving access to the control's Hyperlink and

Using the MouseOver event with Hyperlinks

AR2Std | 121

Page 122: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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

Creating Global Styles 1. Select "File" from the designer menu.

2. Select "Page Settings" from the dropdown menu to open up the "Report Settings" window.

3. Select the "Styles" menu to display the style sheet (seen below).

4. Select "New" to add a new style, or select predefined style to modify.

5. Give the new style an identifiable name and select a base style.

Using CSS

Creating Global Styles

AR2Std | 122

Page 123: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Note: The Base style sets the initial properties for the new style to match those of the selected predefined style.

6. Modify the properties to set up the desired effect and select "OK".

7. To apply a global style, select the control(s) you wish to apply the style to and select the new style from the style drop-down box.

Using the ClassName Property

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

Using Special Style Classes There are a couple of different ways to implement special styles for individual controls. At design time, setting a control's style property in the property window to a properly formatted CSS string will change the control's appearance. For example, the following code sets a control to use dark green, underlined, 16 point Verdana.

font-family: verdana; font-size: 16pt; color: rgb(0,64,0); font-weight: bold; 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

AR2Std | 123

Page 124: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Chapter 13 - Saving and Loading Saving and Loading RDF Files

Using ActiveReports' Export Filters

Saving and Loading Canvas Object

Saving and Loading Report Layouts

Saving and Loading to a Byte Array

Saving And Loading RDF Files ActiveReports allows reports to be saved into their own standard format called an RDF file (Report Document Format). Once a report has been saved to an RDF file, it can be loaded into the viewer control and used to display reports in custom preview applications and on the web. Below is a sample project demonstrating how to save and load these RDF files.

1. Create a new Visual Basic EXE project.

2. Change the name of From1 to frmRDFs.

3. Create a new ActiveReport, as shown in the first tutorial, and set the report's name to rptRDFs (See Chapter 15).

With frmRDFs

1. Add the ActiveX Viewer 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.Run rptRDFs.Pages.Save App.Path & "\SavedRDF.RDF" cmdLoad.Enabled = True End Sub

4. Add the following code to the cmdLoad_Click event:

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

With rptRDFs

1. Insert a ADO data control in the Detail section.

2. Connect to Nwind.mdb (see Chapter 3 for help with connecting).

3. Set the data control's source property to the following SQL statement:

SELECT * FROM Employees ORDER BY Title

4. Remove the PageHeader/Footer sections from the report.

5. Add a GroupHeader/Footer to the report.

6. Set the GroupHeader's properties as follows:

Saving And Loading RDF Files

Name cmdSave cmdLoad Caption Save Report Load Report Enabled True False

BackColor Black

AR2Std | 124

Page 125: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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:

13. Save the project and run it.

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 txtCity Text Title HireDate Extension HomePhone Address City

DataField Title HireDate Extension HomePhone Address City Height 270 270 270 270 270 270

Left 90 1620 3150 90 90 90 Top 90 90 90 1260 540 810

Width 1440 1440 1440 1440 9180 1530 ForeColor &H00E0E0E0& &H00E0E0E0& &H00E0E0E0& &H00E0E0E0& BackColor &H00E0E0E0& &H00E0E0E0& BackStyle 1-ddBKNormal 1-ddBKNormal

AR2Std | 125

Page 126: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Using ActiveReports' Export Filters Included with ActiveReports are several specialized export filters (PDF, RTF, Text, Excel, TIFF and HTML). With these export filters, reports can easily be made available to others in various formats.

In order to use ActiveReports' export filters, the filter must first be referenced through Visual Basic's reference list. The reference names will generally be ActiveReports <filter> Export Filter.

1. Once a filter is referenced, it can be used with the report.

2. The sample project below demonstrates the basics for exporting a report to each of the different filters.

3. Using the same sample above, add a second Form to the project and set the Project's properties startup object to this form.

4. Select all of the export filter references for VB's reference list.

5. Add a command button to the form and set its properties as follows:

6. Add the following code to the cmdExport_Click event:

Dim exportType As String Private Sub cmdExport_Click() exportType = cExportType.Text ExportReport MsgBox cExportType.Text & " Export Completed" End Sub

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

Using ActiveReports' Export Filters

Name cmdExport Caption Export Report

Name cExportType

List PDF Excel TIFF HTML Text

AR2Std | 126

Page 127: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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

9. Save project and run it.

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

Using OnProgress

Each filter has an OnProgress event that can be used to track an export's page progress. This event can be used to display a status bar or counter showing the export's status. Below is a code snippet demonstrating how to use WithEvents to gain access to this event.

Dim myFilter Dim WithEvents FilterEvents As ActiveReportsPDFExport.ARExportPDF Private Sub cmdExport_Click() Set myFilter = New ActiveReportsPDFExport.ARExportPDF rptExport.Run False 'Set the progress bar's max value to the number 'of pages in the report ProgressBar1.Max = rptExport.Pages.Count ProgressBar1.Value = 0 myFilter.FileName = App.Path & "\out.pdf" Set FilterEvents = myFilter myFilter.Export rptExport.Pages End Sub Private Sub FilterEvents_OnProgress(ByVal PageNumber As Long) 'Updates the progress bar ProgressBar1.Value = PageNumber ProgressBar1.Refresh

AR2Std | 127

Page 128: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

End Sub

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

Saving and Loading Canvas Files Saving and loading canvas files allows individual report pages to be saved, loaded or combined together with other reports. Below is a sample, continuing with the project started at the beginning of this chapter, demonstrating the basics for how to save and load these canvas files.

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

Dim cnv As Canvas Dim pgs As Integer Private Sub cmdLoad_Click() Dim rptTemp As ActiveReport Set rptTemp = New ActiveReport For x = 0 To pgs - 1 Set cnv = new Canvas cnv.Load App.Path & "\rptRDF_" & x & ".cnv" rptTemp.Pages.Insert x, cnv Next rptTemp.Pages.Commit ARViewer21.ReportSource = rptTemp End Sub

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

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

3. Save the report and run it.

Saving and Loading Report Layouts Report layouts can be save into XML format (.RPX files) by using two different methods. The first method uses the ActiveReports Save/Open menu to save the selected report designer.

Note: When saving reports to RPX, only script code will be saved.

Below is a code sample, continuing with the project started at the beginning of the chapter, demonstrating how to save and load XML-formatted files (.RPX files) at run time.

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

Private Sub cmdLoad_Click() Dim rptTemp As ActiveReport Set rptTemp = New ActiveReport rptTemp.LoadLayout App.Path & "\rptRDF.RPX" ARViewer21.ReportSource = rptTemp

Saving and Loading Canvas Files

Saving and Loading Report Layouts

AR2Std | 128

Page 129: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

End Sub

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

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

3. Save the report and run it.

Saving and Loading to a Byte Array Saving reports as byte arrays make it possible to save and load reports from a database, or pass reports back and forth between dlls.

Below is a code sample, continuing with the project started at the beginning of the chapter, demonstrating how to save and load reports to a byte array.

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

Dim rByte() as Byte Private Sub cmdLoad_Click() Dim rptTemp As ActiveReport Set rptTemp = New ActiveReport rptTemp.LoadLayout rByte ARViewer21.ReportSource = rptTemp End Sub

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

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

3. Save the report and run it.

Chapter 14 - Scripting What are Scripts For?

How to Add Scripts

Working with Scripts

Using XML (.RPX) Files

What are Scripts for? The main purpose for scripts is to allow reports saved to an XML file to contain code. RPX files are

Saving and Loading to a Byte Array

Chapter 14 - Scripting

What are Scripts for?

AR2Std | 129

Page 130: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 expression in the DataField property of fields and group sections to create calculated fields and custom grouping.

Note: More information about ActiveScripting can be found on Microsoft's site at http://msdn.microsoft.com/scripting/

How to Add Scripts

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

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

How to Add Scripts

AR2Std | 130

Page 131: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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.

Working with Scripts In order to interact with the controls on a report, the following syntax must be used in the script.

rpt.Sections("name of section").Controls("name of control")

Important: "rpt" must be used with all calls relating back to the report. It functions in the same way as calling "me" in Visual Basic. If the script references a control, a public variable, or a public property in the DSR's code, "rpt" must be used.

For example:

If a report's database settings need to be modified, the following code could be used in a script.

Sub OnDataInitialize Dim cnnStr ' Set Connection String and connect to DB cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWind.mdb" rpt.DataControl1.ConnectionString = cnnStr ' Set recordset properties and generate recordsset rpt.Sections("Detail").Controls("DataControl1").Source = "Select * from_ customers order by Country" End Sub

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

Working With a DSR File

When using an RPX file that contains scripts with a DSR file, the DSR file's code can be run in conjunction with the scripting code. By loading the RPX file from the file menu, or at run-time, the RPX file can be

Working With Scripts

AR2Std | 131

Page 132: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

imported into the existing report designer.

Note: If an RPX file is loaded into the designer, the report being displayed in the designer will be replaced by the RPX file's layout.

When an RPX file is loaded, the event firing sequence will be the standard report event sequences with the saved VB code being called first, followed by the scripting code. Since scripting code is called second, scripts can be used to override pre-existing report code.

Working Without a DSR file

In order to use an RPX file without a DSR file, the saved report needs to be independent of any visual basic code. However, it is also very important to keep sensitive information, such as a connection string, out of the RPX file because the file is not secure. In the following example, the script generates an unbound report in much the same way as setting up a normal unbound report. The sample demonstrates how to use the AddNamedItem method to allow the script to reference a function contained within a class in the project. This allows the connection to be made inside the visual basic project, with the resulting Recordset returned to the script.

The sample unbound grouping project from chapter 6 can easily be converted to an unbound scripting sample by removing all the code from the visual basic project and adding the following code in the script editor:

Dim rs ' as ADODB.Recordset Sub OnDataInitialize ' Add fields to ActiveReports' Fields Collection rpt.Fields.Add "Customer" rpt.Fields.Add "City" rpt.Fields.Add "Country" rpt.Fields.Add "PostalCode" ' Set recordset to the recordset returned from calling the ' public function getRSet in clsDB. set rs = myDB.getRSet End Sub Sub OnFetchData(eof) ' Exit sub if EOF is true If rs.EOF Then Exit Sub ' Sets ActiveReports' fields collection values to the ' current recordset value rpt.Fields("Customer").Value = rs.fields("CompanyName") rpt.Fields("City").Value = rs.fields("city") rpt.Fields("Country").Value = rs.fields("Country") rpt.Fields("PostalCode").Value = rs.fields("PostalCode") ' Advance recordset rs.MoveNext ' If not EOF set the FetchData's EOF value to False EOF = False End Sub

1. Once the script has been entered, save the report as "UnboundScript.RPX" and start a new visual Basic project.

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

3. Add a class to the project and set its name to clsDB.

4. Add the following public function to the class.

Public Function getRSet() As ADODB.Recordset Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset ' Set Connection String and connect to DB cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft _ Visual Studio\VB98\NWind.mdb" cn.Open cnnStr ' Set recordset properties and generate recordsset rs.Open "Select * from customers order by Country", cn

AR2Std | 132

Page 133: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Set getRSet = rs End Function

5. Add the ActiveX viewer control to the form and size as desired (see chapter 15).

6. In the Form_Load event, add the following code to load and display the saved RPX file:

Private Sub Form_Load() Dim rptXML As ActiveReport Set rptXML = New ActiveReport rptXML.LoadLayout App.Path & "\UnboundScript.RPX" rptXML.AddNamedItem "myDB", new clsDB rptXML.Run Set ARViewer21.ReportSource = rptXML End Sub

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

Using AddNamedItem and AddCode

The AddNamedItem and AddCode methods are used to add items to the script's global name space. By using AddNamedItem or AddCode code, elements from inside the Visual Basic project can be used inside the scripts. By using AddNamedItem, as seen above, scripts can become aware of functions in a visual basic class contained inside the project. By using AddCode, actual code segments can be added to the script at run-time. The sub added through AddCode must be a properly formatted string. The code segment below demonstrates how to use AddCode within a project:

Private Sub ViewPreview() On Error GoTo ehViewPreview Set m_rpt = Nothing Set m_rpt = New ActiveReport m_rpt.ResetScripts m_rpt.AddNamedItem "vbo", m_vbo m_rpt.AddCode ScriptCode() m_rpt.ScriptDebuggerEnabled = True m_rpt.Run False Set arv.ReportSource = m_rpt Exit Sub ehViewPreview: MsgBox Str(Err.Number) & " - " & Err.Description, vbOKOnly, _ "Error: ViewPreview" End Sub Private Function ScriptCode() As String Dim sCode As String sCode = sCode & _ "Function IIf(Expression, TruePart, FalsePart) " & vbCrLf & _ "IIf = vbo.IIf(Expression, TruePart, FalsePart)" & vbCrLf & _ "End Function" & vbCrLf & vbCrLf sCode = sCode & _ "Function Format(expr, fmt) " & vbCrLf & _ " Format = vbo.Format(expr, fmt)" & vbCrLf & _ "End Function" & vbCrLf & vbCrLf ScriptCode = sCode End Function

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

Using XML (.RPX) Files

Using RPX Files

AR2Std | 133

Page 134: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

RPX files contain report layouts that use an open XML based format. The XML schema contains the layout and scripts for each report. The RPX files allow distributed reports to be changed and modified without having to recompile the project. Using RPX files also makes it possible to use a database of report file names to set up a collection of reports to run. Since RPX files are using an open format, future compatibility with platforms such as .NET is built in.

When saving your report layouts to RPX files you should not use compiled VB events because that code cannot be stored in the RPX files and loading and running the RPX file might result in runtime errors.

Chapter 15 - Using ActiveReports' ActiveX Viewer Control ActiveReports' ARViewer Control

Adding the Viewer to VB

Creating a Custom Preview Form (HX_Creating_a_Custom_Preview_Screen_.html)

Using Split Windows with the Viewer

Adding Buttons to the Viewer Control

Controlling Printing and Printer setup on the Viewer

ActiveReports' ActiveX Viewer Control ActiveReports 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.

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

Chapter 15 - Using ActiveReports' ActiveX Viewer Control

ActiveReports' ActiveX Viewer Control

AR2Std | 134

Page 135: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

functionality to your preview.

Adding the Viewer Control to VB 1. Select Project > Components from Visual Basic menu or press Ctrl-T to display the components dialog

box.

2. Select and check the "Data Dynamics ActiveReports Viewer 2.0" entry in the list.

3. The ActiveReport Viewer icon should appear in your toolbox.

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

Creating a Custom Preview Screen 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:

Private Sub Form_Load()

Adding the Viewer Control to VB

Creating a Custom Preview Screen

AR2Std | 135

Page 136: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

arv.ReportSource = New ActiveReport1 End Sub

Your form should look like this:

Using Split Windows on the Viewer Control

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

Using Split Windows on the Viewer Control

AR2Std | 136

Page 137: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Adding Buttons to the Viewer Control

AR2Std | 137

Page 138: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Adding Buttons to the Viewer Control This sample project demonstrates how to customize the viewer control by adding additional buttons 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 = 2 arv.ToolBar.Tools.Item(1).ID = 999 'Insert the Close botton in the 'third position arv.ToolBar.Tools.Insert 2, "Close" arv.ToolBar.Tools.Item(2).Caption = "&Close" arv.ToolBar.Tools.Item(2).Tooltip = "Close Project" arv.ToolBar.Tools.Item(2).ID = 1000 'Insert another splitter in the 'fourth position arv.ToolBar.Tools.Insert 3, "" arv.ToolBar.Tools.Item(3).Type = 2 arv.ToolBar.Tools.Item(3).ID = 1001 'Insert the Open button in the 'fifth position and assign it 'and icon arv.ToolBar.Tools.Insert 4, "O&pen" arv.ToolBar.Tools.Item(4).AddIcon LoadPicture("C:\Program Files\Microsoft _ Visual Studio\Common\Graphics\Icons\Win95\openfold.ico") arv.ToolBar.Tools.Item(4).Tooltip = "Open RDF File" arv.ToolBar.Tools.Item(4).ID = 1002 'Insert the Save button in the sixth 'position and assign it an icon and 'disable it arv.ToolBar.Tools.Insert 5, "&Save" arv.ToolBar.Tools.Item(5).AddIcon LoadPicture("C:\Program Files\Data _ Dynamics\ActiveReports Pro\Samples\Professional Edition\Diamond Reports_ \res\Standard\tfsave.ico") arv.ToolBar.Tools.Item(5).Tooltip = "Save Report to RDF"

Name frmViewer BorderStyle 1-Fixed Single

Height 8310 Width 13440

Name arv Height 7815

Left 120 Top 0

Width 13095

AR2Std | 138

Page 139: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

8. Add the following code to the Form_Load event:

Private Sub Form_Load() addButtonsToARV End Sub

9. Add the following code to the arv_ToolbarClick event:

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

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

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

AR2Std | 139

Page 140: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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

11. Save the project and run it.

Controlling Printing and Printer Setup on the Viewer The viewer control has a Printer property that you can use to set up the printer or call the print method for some pages in the Pages collection.

Note: Paper size and page orientation will not be reflected in the report until you restart it since the report has been rendered to the original print specification.

You can create a global printer object and use it for all reports included in your application. Before starting each report you can set the printer property of the report to the global printer object.

Using the same preview form, we will implement printer setup and print menu options. Add the following code to your form:

1. Continuing with the project started above, add the following code to the Form_Load event:

Private Sub Form_Load() addButtonsToARV ' This overrides the print tool For cnt = 0 To arv.ToolBar.Tools.Count - 1 If "&Print..." = arv.ToolBar.Tools(cnt).Caption Then arv.ToolBar.Tools(cnt).ID = CONST_PRINTTOOLID End If Next cnt End Sub

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

Private Sub arv_ToolbarClick(ByVal Tool As DDActiveReportsViewer2Ctl.DDTool) Dim bReturn As Boolean Select Case Tool.Caption Case Is = "O&pen" 'call the open sub tbOpen

Controlling Printing and Printer Setup on the Viewer

AR2Std | 140

Page 141: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Case Is = "&Close" 'call the exit sub tbExit Case Is = "&PDF" 'call the PDFExport sub tbPDFExport Case Is = "&Save" 'call the Save sub tbSave Case Is = "&Print..." arv.UseSourcePrinter = True arv.Printer.SetupDialog bReturn = arv.Printer.PrintDialog(Me.hWnd) If bReturn Then arv.PrintReport False CancelledJob = False Else CancelledJob = True End If End Select End Sub

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

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

Chapter 16 - ActiveReports on the Web Using the ARViewer Control with Internet Explorer

Using the Java Viewer Control

Creating a ReportServer with ASP and ActiveReports

Using the ARViewer Control with Internet Explorer Saved RDF reports can be used in conjunction with the ActiveX viewer in Microsoft Internet Explorer. The DataPath property allows you to download pages asynchronously to the client browser.

This is an example of inserting the viewer control into your page.

<object ID="arv" classid="clsid:8569D715-FF88-44BA-8D1D-AD3E59543DDE" codebase="arview2.cab" width=100%

Chapter 16 - ActiveReports on the Web

Using the Viewer Control with Internet Explorer

AR2Std | 141

Page 142: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

height=70%> /object> <Script LANGUAGE="VBScript"> •<! ' Set the data path to the relative path ' of your pages output Sub Window_onLoad() ARViewer1.DataPath="salesbycountry.rdf" End Sub --> </Script>

Note: The Window_OnLoad event should be used to set the DataPath. If this event is not used, reports may not be displayed.

There are several ways distribute reports on the web. If you have periodic reports you can schedule a VB application to process reports and transfer new RDF files to your web site. On the other hand, if you want live reports you can generate reports on the fly by either using ASP pages or using CGI scripts which will run reports interactively.

Using the Java Viewer Control ActiveReports' Java viewer (ARViewer.jar) can be used with browsers not supporting ActiveX controls. Below is a sample html page demonstrating how to use the JavaViewer to load RDF reports:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- saved from url=(0052)http://www.datadynamics.com/test/arvj/NSIEWinSol.asp--> <HTML><HEAD><TITLE>ARJavaViewer HTML Test Page</TITLE> <META content="text/html; charset=windows-1252" http-equiv=Content-Type> <SCRIPT event=actionPerformed(ActionEvent1) for=Arvj language=javascript type=text/javascript> <!-- //window.alert("TOC or Hyperlink:[" + ActionEvent1.getSource().toString() + "]." );//--> </SCRIPT> <SCRIPT language=JavaScript type=text/javascript> <!-- function cboReport_onChange() { var sFile = Form1.cboReport.options(Form1.cboReport.selectedIndex).text; Form1.Arvj.setDataPath("reports/" + sFile ); //alert(cboReport.options(cboReport.selectedIndex).text); return; } //--> </SCRIPT> </HEAD> <BODY> <DIV style="BORDER-BOTTOM: 1px; BORDER-LEFT: 1px; BORDER-RIGHT: 1px; BORDER-TOP:1px"><LABEL for=txtPassword>Enter the password for your report file here and click 'set':</LABEL> <INPUT id=txtPassword name=txtPassword size=6> <INPUT id=button1 name=button1 onclick=Form1.Arvj.getPages().setPassword(txtPassword.value); type=button value="Set Password"> </DIV><!--"CONVERTED_APPLET"--><!-- CONVERTER VERSION 1.3 --> <FORM action="" id=Form1><BR>Please select a report from the list below:<BR> <SELECT id=cboReport name=cboReport onchange="return cboReport_onChange()"> <OPTION selected>AnnualReport.rdf</OPTION> <OPTION>Catalog.rdf</OPTION>

Using the Java Viewer Control

AR2Std | 142

Page 143: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

<OPTION>CustomerLabels.rdf</OPTION> <OPTION>CustomersPhoneBook.rdf</OPTION> <OPTION>EmployeeProfiles.rdf</OPTION> <OPTION>EmployeeSales.rdf</OPTION> <OPTION>EmployeeSalesByCountry.rdf</OPTION> <OPTION>Invoice.rdf</OPTION> <OPTION>PriceListByCategory.rdf</OPTION> <OPTION>ProductInventoryByCategory.rdf</OPTION> <OPTION>ProductWeeklySales.rdf</OPTION> <OPTION>Top10.rdf</OPTION> </SELECT> <BR>com.datadynamics.activereports.ActiveReportsViewer will appear below in a Java enabled browser.<BR> <OBJECT align=middle classid=clsid:8AD9C840-044E-11D1-B3E9-00805F499D93 codeBase=http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0 height="70%" id=Arvj name=Arvj width="80%"><PARAM NAME="ARCHIVE" VALUE="ARViewer.jar"> <PARAM NAME="cache_option" VALUE="Plugin"> <PARAM NAME="cache_archive" VALUE="ARViewer.jar"> <PARAM NAME="cache_version" VALUE="1.0"> <PARAM NAME="CODE" VALUE="com.datadynamics.activereports.ActiveReportsViewer"> <PARAM NAME="CODEBASE" VALUE="."> <PARAM NAME="NAME" VALUE="ArvjName"> <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3"> <PARAM NAME="scriptable" VALUE="true"> <PARAM NAME="bridgeevents" VALUE="no"> <!-- PARAM NAME="dataPath" VALUE="reports/CustomerLabels.rdf" --> COMMENT> <EMBED type="application/x-java-applet;version=1.3" CODE = "com.datadynamics.activereports.ActiveReportsViewer.class" CODEBASE = "." ARCHIVE = "ARViewer.jar" NAME = "TestApplet" WIDTH = 480 HEIGHT = 640 ALIGN = middle VSPACE = 0 HSPACE = 0 dataPath = "reports/CustomerLabels.rdf" scriptable=true pluginspage="http://java.sun.com/products/plugin/1.3/plugin-installl"> <NOEMBED> </NOEMBED> </EMBED> </COMMENT> </OBJECT></ FORM><!-- <APPLET CODE = "com.datadynamics.activereports.ActiveReportsViewer.class" CODEBASE = "." ARCHIVE = "ARViewer.jar" WIDTH = 480 HEIGHT = 640 NAME = "TestApplet" ALIGN = middle VSPACE = 0 HSPACE = 0> <PARAM NAME = "dataPath" VALUE = "reports/CustomerLabels.rdf"> </APPLET> --><!--"END_CONVERTED_APPLET"--></BODY></HTML>

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

Creating a ReportServer with ASP and ActiveReports

Setting up the ReportServer DLL

One possible way to use ActiveReports to serve reports on the web is to create an ActiveX DLL that combines all your reports with a class. The class will then manage running and saving the reports to a selected export filter.

The class will create an instance of the requested report and save it to a directory where the ASP script can push it to the client.

The most critical part of creating a reporting ActiveX DLL is to not display any type of UI, including message boxes, forms or report preview screens. It is also important to make sure each event in the report has proper error handling. Using "On Error Goto & " and the ActiveReport Error event, with the event's CancelDisplay parameter set to True, will help prevent any messages. Any UI appearing in the server DLL will cause the

Creating a ReportServer with ASP and ActiveReports

AR2Std | 143

Page 144: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

server to lock-up while waiting on input.

Errors should be handled and can be logged using the App.LogEvent method. If a report server appears to be locking up, using App.LogEvent will help track down which event is being called last. Once the specific event has been identified, App.LogEvent can be used to track the problem down to a specific line. When using logging and error handling, pay close attention to the following report events: Initialize, DataInitialize, NoData, Error, ReportStart, ReportEnd, and Terminate.

The sample code below gives an example for a basic class. In the sample, a specified report, from the Report property, and a specified export filter, from the OutputFormat property, are used to indicate which report to run and which export filter to use when saving the report.

Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" _ (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, _ ByVal lpTempFileName As String) As Long Enum eOutputFormat eRDF ePDF End Enum Enum eReport erptAnnualReports erptCatalog erptCustomerLabels End Enum Public Property Let Report(iRpt As eReport) Dim hr As Long App.LogEvent "Report: " & iRpt Debug.Print "Report: " & iRpt m_iReport = iRpt End Property Public Property Let OutputFormat(iFormat As eOutputFormat) App.LogEvent "OutputFormat: " & iFormat Debug.Print "OutputFormat: " & iFormat m_iFormat = iFormat End Property Public Property Get FileName() As String App.LogEvent "FileName" Debug.Print "FileName" m_sFName = StripFileName(m_sFName) FileName = m_sFName End Property Public Function RunReport() As Boolean On Error GoTo Errhndl Dim rpt As Object Dim pdf As New ActiveReportsPDFExport.ARExportPDF 'Use App.LogEvents to debug compiled code App.LogEvent "RunReport Started" Debug.Print "RunReport Started" Select Case m_iReport Case erptAnnualReports: Set rpt = New rptAnnualReport Case erptCatalog: Set rpt = New rptCatalog Case erptCustomerLabels: Set rpt = New rptCustomerLabels Case Else RunReport = False Exit Function End Select App.LogEvent "Preparing to Run" Debug.Print "Preparing to Run"

AR2Std | 144

Page 145: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

rpt.Run False App.LogEvent "Report Ran" Debug.Print "Report Ran" m_sFName = String(255, Chr$(0)) ' GetTempFileName is a Win32 API function, you need ' to add the declaration in one of your modules If Not GetTempFileName(sServerPath, "AR", -1, m_sFName) Then RunReport = False Exit Function End If m_sFName = Left$(m_sFName, InStr(m_sFName, Chr$(0)) - 1) App.LogEvent "File name = " & m_sFName Debug.Print "File name = " & m_sFName If m_iFormat = eRDF Then App.LogEvent "Exporting to RDF" Debug.Print "Exporting to RDF" rpt.Pages.Save m_sFName App.LogEvent "Export to RDF Complete" Debug.Print "Export to RDF Complete" ElseIf m_iFormat = ePDF Then pdf.FileName = m_sFName App.LogEvent "Exporting to PDF" Debug.Print "Exporting to PDF" pdf.Export rpt.Pages App.LogEvent "Export to PDF Complete" Debug.Print "Export to PDF Complete" App.LogEvent "RunReport Completed" Debug.Print "RunReport Completed" Exit Function ErrHndl: App.LogEvent "Error Fired in RunReport: " & Err.Number & ":" & Err.Description, 2 Debug.Print "Error Fired in RunReport: " & Err.Number & ":" & Err.Description RunReport = False

Setting up the ASP script

When setting up the ASP page for access on the web, it is very important to verify that the default user for the web site has the necessary permissions to access the page, the report dll, ActiveReports cab file and dll files, and the database. It is also important to make sure the default user has write access to the folder being used for exporting. If a project exhibits problems, such as not initiating the report server dll or failing on the export, the problem will probably be related to permissions. A quick way to rule out a permissions problem is to temporarily add the web site's default user to the administrators group.

The ASP script below will set the two properties Report and Output Format and then run the report.

<%@ LANGUAGE="VBSCRIPT" %> <% Dim rptServer Dim fname Set rptServer = CreateObject("ARASPSample.ReportServer") rptServer.Report = Request.Form("cboReport") rptServer.OutputFormat = 1 If rptServer.RunReport() Then fname = rptServer.FileName %> <CENTER> <object ID="arv" classid="clsid:8569D715-FF88-44BA-8D1D-AD3E59543DDE" codebase="arview2.cab"

AR2Std | 145

Page 146: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

width=% height=70%> </object> </CENTER> <BODY FONT="Arial"> <script LANGUAGE="VBScript"> <!-- Sub window_onload() ' set the initial reportsource data path arv.DataPath="Reports/<%Response.Write fname%>" end sub --> </script> <%else%> <BODY> <P> Error: Unable to create report.<BR> Please send email to <A HREF="mailto:[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 Distribution

To serve reports to clients in a web environment, your web server should have arview2.cab (if using ActiveReports Viewer Control), actrpt2.dll (always) and arpro2.cab (if using the professional editions end user designer). You should also register any export dlls needed.

Support and Licensing Registration

Technical Support

Data Dynamics Web Site

Data Dynamics News Server

Upgrades

Suggestions

Defects Policy

License Agreement

ActiveReports Error Codes

Product Registration In order to receive telephone support and product news and upgrade announcements, you must register your product purchase with Data Dynamics. We encourage you to register your purchase as soon as you receive it using any of the following:

Fill out the enclosed registration card and mail it to Data Dynamics, 5870 Cleveland Avenue, Columbus, Ohio 43231 or fax it to Data Dynamics at (614) 899-2943.

Or, you can use our online registration form on our web site at http://www.datadynamics.com

Support and Licensing

Production Registration

AR2Std | 146

Page 147: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Technical Support If you are having problems using ActiveReports 2.0, please make sure the control is properly registered by the installation program. If not, use RegSvr32.exe to register the ActRpt2.dll, ARView2.ocx and ARDesign2.DLL files.

Note: RegSvr32.EXE is included with the Visual Basic installation.

If the problem remains, and no solution is listed on our support web site or newsgroups server, please contact our technical support staff.

Note: Telephone support is only available to registered customers.

Registered users are allowed up to five support incidents resolved over the telephone. Additional support requests should be directed to our newsgroup. If desired, additional telephone support can be acquired by purchasing any of our support packages. Contact [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 - Data Dynamics' Official Web page.

http://www.datadynamics.com/support - Data Dynamics' Support page. A source for patches, updates and product downloads.

http://www.datadynamics.com/kb - Data Dynamics' Knowledgebase. Search the knowledgebase to find help with common problems, "How To" articles and downloaded able samples.

FTP

ftp://ftp.datadynamics.com/activereports2 - Data Dynamics' FTP site. A source for finding sample projects.

Newsgroups

news://news.datadynamics.com - 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 (9 a.m. to 5 p.m. EST, M-F)

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

Web server address: http://www.datadynamics.com

NewsGroups

Technical Support

Web Site

NewsGroups

AR2Std | 147

Page 148: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Use our news server 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 newsgroups 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 news server.

News server address: news.datadynamics.com

Product Upgrades Minor upgrades and service packs will be made available for download from our web site free of charge.

Major upgrades will carry an upgrade price that is determined separately for each release. You will be entitled to a free major upgrade if you purchased within 30 days of the upgrade release date.

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

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

License Agreement and Limited Warranty The product in this package (libraries and object code) is proprietary to Data Dynamics, Ltd. and is protected by Federal Copyright Law. Data Dynamics retains the title to and ownership of the Product. You are licensed to use this Product on the following terms and conditions:

LICENSE: The licensee is defined as the individual software developer utilizing the Product. This license is not for an entire company but for a single developer. Data Dynamics hereby grants the licensee a nonexclusive license authorizing the licensee to use the enclosed Product on one computer at a time for development purposes. Distribution of the application(s) using ActiveReports is royalty-free, requiring no additional license fees. You may incorporate the sample code into your applications. Use of this product by more than one individual or by anyone other than the licensee terminates, without notification, this license and the right to use this product.

YOU 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: You may use this Product in your business application for sale or distribution as long as:

The product that you produce and/or distribute 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.

The software serial number and user must be registered with Data Dynamics in order to receive support or distribution rights.

Product Upgrades

Suggestions

Disk Defects Policy

License Agreement and Limited Warranty

AR2Std | 148

Page 149: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

You may not remove any proprietary notices, labels, trademarks on the software or documentation.

You may not modify, de-compile, disassemble, reverse engineer or translate the software.

FILES THAT MAY BE DISTRIBUTED WITH YOUR APPLICATION: ACTRPT2.DLL, PDFExpt.DLL, RTFExpt.DLL, ARVIEW2.OCX, ARVIEW2.CAB, HTMLExpt.DLL, TEXTExpt.DLL, TIFFExpt.DLL and EXCLExpt.DLL.

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

TERM: You may terminate your License and this Agreement at any time by destroying all copies of the Product and Product Documentation. They will also terminate automatically if you fail to comply with any term or condition in this Agreement.

LIMITED WARRANTY: This software and documentation are sold "as is" without any warranty as to their performance, merchantability or fitness for any particular purpose. The 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 Object2000 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

2015 SubReport.Object property was set to invalid object. Subreport

AR2Std | 149

Page 150: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

The object property only supports a valid ActiveReport instance.

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 Canvas, Pages

AR2Std | 150

Page 151: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

target file exists or is read-only. See description 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

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

AR2Std | 151

Page 152: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Reference Constants

ActiveReports' Architecture

Common Properties

Common Methods

ActiveReport

ARViewer Control

Border Properties< /P>

Canvas

Controls

Data Controls< /P>

History

Pages and PageSettings

PaperSizes Methods

Parameters

Printer

RptFields

Sections

TOC

Tools and Toolbar

Constants

ADOLockType

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.

Value Mnemonic Description 0 ddADOOpenForwardOnly Default - Creates a forward-only cursor.

AR2Std | 152

Page 153: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BackStyle

BarCodeCaptionPosition

BarCodeDirection

BarCodeStyle

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

AR2Std | 153

Page 154: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BorderLineStyle

ColumnDirections

DAOCursorType

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

DAODefaultType

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

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

AR2Std | 154

Page 155: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

GrpKeepTogether

Job Status

LayoutAction

LoadSaveConstants

LineStyle

NewPageConstants

PictureAlignment

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

AR2Std | 155

Page 156: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

PrtCollate

PrtDuplex

PrtOrientation

PrtQuality

ReportStatus

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

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.

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.

AR2Std | 156

Page 157: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

SaveOptionTypes

SectionType

ShapeType

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

AR2Std | 157

Page 158: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SizeMode

SplitType

SummaryFunctions

SummaryRunningType

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

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.

AR2Std | 158

Page 159: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SummaryType

TextAlignment

VerticalTextAlignment

ViewerStatus

ActiveReports' Architecture Report Sections

Report Processing

Events

Reports Passes

Printing Process

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

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

AR2Std | 159

Page 160: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Report Header

An ActiveReport can have a report header section that prints at the beginning of the report. It is generally used to print a report title, a summary table, a chart or any information that needs to appear only once at the beginning of the report.

Note: A report header can span multiple pages by inserting a page break control within its content.

Report Footer

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

Page Header

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

Page Footer

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

Group Header, Group Footer

An ActiveReport can have multiple nested groups; each group has a header and a footer section. The header section prints before any detail sections in the group. The footer section prints after all the detail sections in the group. Group sections are inserted immediately before and after the detail section.

The number of times that a group section would print depends on how the data is grouped. ActiveReports will start a new group (Header, Detail, and Footer) for each change in the data that binds the group.

Detail

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

AR2Std | 160

Page 161: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Report Processing ActiveReports starts processing the report by initializing the data sources if any, then starts firing events for processing the report header followed by page header, groups, detail and page footer for each page in the report.

Report sections are rendered into a drawing object called the Canvas. A canvas represents a single drawing surface that can be used for printing, serialization and remoting of a page. The pages are displayed immediately after they are rendered to the canvas object. ActiveReports continues the processing while caching the pages in its internal page cache.

Each canvas object is stored in the Pages collection in the order it was created. The canvas can be accessed and modified through the canvas drawing methods. Canvas objects can be merged (overlaid) and used as form templates.

In addition, you can create canvas objects directly (e.g. Dim mypage as Canvas) and draw on them using methods such as DrawText. The preview window of ActiveReports uses the Pages collection to view pages. Therefore, you will need to insert canvas objects you create into the Pages collection. For example, once a report is completed you can parse the table of contents and render it to a canvas object then insert the new canvas as a page at the beginning of the report. To finalize manual changes to the Pages collection call Pages.Commit so that viewers will be updated with new content.

The Pages collection allows for complete control over the order and contents of each page in your report. You can modify the contents using the low-level Canvas methods or shuffle the order of the pages before printing or exporting them.

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

Format

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

BeforePrint

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

AfterPrint

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

Reports Passes The 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.

Report Processing

Events

Reports Passes

AR2Std | 161

Page 162: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Summary fields and KeepTogether constraints are the two reasons that a page would not be rendered completely. The summary field is not complete until all the data needed for calculation is read from the data source. When a summary field such as a grand-total is placed ahead of its completion level such as placing it in the report header, the report header section and all following sections will be delayed until all the data is read.

Printing Process ActiveReports output can be printed using different methods. The simplest is to call the PrintReport method. When the PrintReport method is called, ActiveReports checks to determine if the report has been processed earlier. If not, it starts the report processing to create the Pages collection. Then, it starts a new print job and prints each page in the collection. Then, it ends the print job.

You can call the Stop or Cancel methods while the report is processing or printing. Both methods will cause the print job to end. The Stop method will continue to print processed pages before closing the print job. The Cancel will immediately close the print job and clear the pages collection.

In addition, you can call the Run method to process the report and create the pages collection. Next, start a print job using the Printer.StartJob method. Then, selectively print pages from the collection using the Printer.PrintPage method. Finally, close the print job using the Printer.EndJob method.

If you use background printing using Run(True) you will receive PrintProgress events. The Status property is updated while the report is printing in the background.

Note: You can call Printer.AbortJob while printing to abort the print job in case of a fatal error.

Common Properties These properties are shared with several objects in ActiveReports.

BackColor

Description

Sets or returns the background color or fill color for the objects.

Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Printing Process

Common Properties

Property Data Type DescriptionBackColor 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

AR2Std | 162

Page 163: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

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

BackStyle

Description

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

Data Type

BackStyle

Availability

Example

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

DataField

Description

Sets or returns the database field a control will pull its data from. When the DataField property is set to a field contained within the DataSource, ActiveReports binds the field's data from each record to the control. The recordset data is first saved into the DataValue property. It then passes through any OutputFormats and is set as the control's text.

BackStyle

Design time Read / Write Run time Read / Write

DataField

AR2Std | 163

Page 164: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 expression by stating the property's with an "=". This allows fields to be set up to display calculated results. For example, a field control or a group section's datafield can be set to an expression such as "=UnitPrice * Qty" or "=Trim(CompanyName)" where UnitPrice, Qty and CompanyName are members of the RptFields collection.

Data Type

String

Availability

Example

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

Font

Description

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

Data Type

stdFont

Availability

Design time Read / Write Run time Read / Write

Font

Design time Read / Write Run time Read / Write

AR2Std | 164

Page 165: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor

Description

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

Data Type

OLE_COLOR

Availability

Example

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

Common Methods

ZOrder

ForeColor

Design time Read / Write Run time Read / Write

Common Methods

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

AR2Std | 165

Page 166: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

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

Return Type

None

Syntax

Sub Zorder(Position As Integer)

Parameters

Settings

Example

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

ActiveReport ActiveReport Properties

ActiveReport Methods

ActiveReport Events

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

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

ActiveReport

AR2Std | 166

Page 167: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ActiveReport Properties

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

AR2Std | 167

Page 168: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

AllowSplitter

Description

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

Data Type

Boolean

Availability

Example

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

Canvas

Description

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

AR2Std | 168

Page 169: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Data Type

Canvas

Availability

Example

' This example uses the DrawText method of the canvas ' to write directly to the page. Private Sub PageHeader_Format() Dim lW As Long, lH As Long With Canvas .Font.Size = 48 .MeasureText "Confidential", lW, lH .ForeColor = &HE0E0E0 .DrawText "Confidential", _ (Me.PrintWidth - lW) / 2, _ (Me.Printer.PaperHeight - lH) / 2, _ 5200, 2400 End With End Sub

DocumentName

Description

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

Data Type

String

Availability

Example

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

Design time N/A Run time Read / Write

DocumentName

Design time Read / Write Run time Read / Write

Fields

AR2Std | 169

Page 170: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Fields

Description

Fields is a collection of report Field objects used to bind controls, bind summary fields and group sections to a data source when working with bound or unbound reporting.

In bound reports, the report's fields collection is initialized to all the fields available in the data control's recordset before the DataInitialize event fires. At run time, calculated fields can be added to the report's fields collection in the DataInitialize event by using the Add method, and their values can be calculated in the FetchData event.

In unbound reports, the report's fields collection must be initialized in the DataInitialize event by using the Add method to add one field into the report's fields collection for every field being used from the recordset. After the fields have been added to the report's fields collection, the FetchData event is used to populate the report's fields collection with the Recordset's field data. When using unbound reporting, set the DataField property for the control equal to the name used to add the field to the report's field collection.

Note: The ActiveReports fields collection is not the same as the Recordset's fields collection.

Data Type

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 here Fields.Add "OrderID" Fields.Add "ProductID" Fields.Add "ProductName" Fields.Add "Qty" Fields.Add "Price" Fields.Add "Amount" ' iRow is the current record pointer iRow = LBound(arr) End Sub Private Sub ActiveReport_FetchData(eof As Boolean) ' After processing all the elements, exit the event ' by leaving the eof parameter to its default(True) ' value. This will promp AR to end the report If iRow > UBound(arr) Then Exit Sub Fields("OrderID").Value = arr(iRow).OrderNo Fields("ProductID").Value = arr(iRow).ProductID Fields("ProductName").Value = arr(iRow).ProductName Fields("Qty").Value = arr(iRow).Qty Fields("Price").Value = arr(iRow).Price Fields("Amount").Value = arr(iRow).Amount iRow = iRow + 1 ' We must set the eof parameter to True as ' long as there is more data to be processed eof = False End Sub

Design time N/A Run time Read / Write

LayoutAction

AR2Std | 170

Page 171: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

LayoutAction

Description

ActiveReports typically performs the following actions for each section:

1. Prints the section.

2. Moves the layout (sets the next position for the rest of the report).

3. Moves to the next record.

The LayoutAction property gives control over these steps. Using a combination of layout actions when the report is run, previewed, printed, or saved can change a report's layout.

Note: The following table shows the results for setting different LayoutAction setting combinations.

Data Type

Integer

Settings

Availability

Example

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

MaxPages

Description

Sets or returns the maximum number of pages ActiveReports will process. Once the number of maximum pages is reached, ActiveReports will stop processing the report.

This property can be used to limit the number of output pages when running large reports and distributing

Value Print Layout NextR Description7 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. 5 True False True Print the next record on top of the current record (UnderlayNext).

Value Mnemonic Description1 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

AR2Std | 171

Page 172: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

the results over a slow connection.

Data Type

Long

Availability

Example

rptSales.MaxPages = 10

PageBorder

Description

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

Data Type

Border

Availability

Example

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

PageNumber

Description

Returns the page number the report is currently on. This property allows the viewer host to display the report's progress while it is running in the background. This property should only be used in the BeforePrint event. Using it in any of the other events will result in erroneous data.

Note: The PageNumber property should not be used to set up actual page numbering on a report. The Page N of M routines should be handled by the SummaryFunctions.

Data Type

Long

Design time Read / Write Run time Read / Write

PageBorder

Design time N/A Run time Read / Write

PageNumber

AR2Std | 172

Page 173: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

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

Pages

Description

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

Note: The Pages collection is zero based.

Data Type

Pages Collection

Availability

Example

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

Design time N/A Run time Read

Pages

Design time N/A Run time Read-Only

AR2Std | 173

Page 174: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

End If Printer.EndJob End Sub

Parameters

Description

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

Data Type

ARParameters

Availability

Example

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

ParentReport

Description

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

Note: This property is read-only and available only from the time the Subreport's DataInitialize event fires to the time the ReportEnd event fires. Trying to access ParentReport during the Initialize or Terminate events will return nothing.

Data Type

Object

Parameters

Design time N/A Run time Read-Only

ParentReport

AR2Std | 174

Page 175: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

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

Printer

Description

Returns a reference to the printer object. This property can be used modify printer settings at run time.

Note: The Printer object and PageSettings collection share several properties, so whichever property is used last will take precedence.

Data Type

Printer

Availability

Example

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

PrintWidth

Description

Sets or returns the report's printable width in twips (1440 twips = 1 inch). The PrintWidth is the amount of physical space to which a report can print. If the size of the report is changed during 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 Type

Single

Design time N/A Run time Read-Only

Printer

Design time N/A Run time Read / Write

PrintWidth

AR2Std | 175

Page 176: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Default Value

1440 twips = 1 inch

Availability

Example

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

RulerVisible

Description

Sets or returns whether or not the report's top and side rulers are shown at run time.

Data Type

Boolean

Availability

Example

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

Sections

Description

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

Data Type

Sections collection

Design time Read / Write Run time Read / Write

RulerVisible

Design time Read / Write Run time Read / Write

Sections

AR2Std | 176

Page 177: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

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

Script

Description

Sets or returns an ActiveScript string to implement at run time. The scripts can be used to make modifications to the report outside the code written in the report's events. The scripts run immediately after their matching ActiveReports' events and take precedence over the code inside the project.

If reports with scripts are saved to XML, the scripts are incorporated into the XML file. Changes can be made to the XML file scripts and then loaded back into a report project to show the changes. This allows reports to be modified without requiring the project to be recompiled.

The report's script property allows access to the following scripting events.

sub OnReportStart() end sub sub OnReportEnd() end sub sub OnPageStart() 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

Design time N/A Run time Read / Write

Script

AR2Std | 177

Page 178: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

http://msdn.microsoft.com/scripting/

Data Type

String

Availability

Example

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

ScriptDebuggerEnabled

Description

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

Data Type

Boolean

Availability

Example

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

ScriptLanguage

Design time Read / Write Run time Read / Write

ScriptDebuggerEnabled

Design time Read / Write Run time Read / Write

ScriptLanguage

AR2Std | 178

Page 179: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

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

Data Type

String

Availability

Example

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

ShowMessages

Description

Specifies whether ActiveReports should display any run-time error or alert message boxes. Setting this property to False, disables all message boxes. It should be used when the reports are running on a web

•server where the message box UI would cause the server to lock up. The report s Error event will continue to fire, allowing you to log the errors to the event log or to a fileThis is typically set to False on servers.

DataType

Boolean (Default = True)

Availability

Example

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

ShowParameterUI

Description

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

Design time Read / Write Run time Read / Write

ShowMessages

Design time N/A Run time Read / Write

ShowParameterUI

AR2Std | 179

Page 180: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

the ShowParameterUI to True (default) will cause the query parameter box to appear when the report is run.

Data Type

Boolean

Availability

Example

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

Status

Description

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

Data Type

ReportStatus

Settings

Availability

Example

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

TOC

Design time Read / Write Run time Read / Write

Status

Value Mnemonic Description0 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

TOC

AR2Std | 180

Page 181: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

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

Note: The TOC entries are only available after the report has run.

Data Type

TOC

Availability

Example

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

TOCEnabled

Description

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

Note: The TOC properties and methods can still be used even if the TOC is disabled.

Data Type

Boolean

Availability

Example

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

TOCVisible

Design time N/A Run time Read / Write

TOCEnabled

Design time Read / Write Run time Read / Write

TOCVisible

AR2Std | 181

Page 182: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

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

Data Type

Boolean

Availability

Example

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

TOCWidth

Description

Sets or returns the table of contents tree width in twips.

Data Type

Single

Availability

Example

rpt.TOCWidth = 2880

ToolbarVisible

Description

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

Data Type

Boolean

Availability

Design time Read / Write Run time Read / Write

TOCWidth

Design time N/A Run time Read / Write

ToolbarVisible

Design time Read / Write Run time Read / Write

AR2Std | 182

Page 183: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

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

UserData

Description

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

Data Type

Variant

Availability

Example

ActRpt1.UserData = "Annual Report Build 106"

Version

Description

Returns the product's version number.

Data Type

String

Availability

Example

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

WaterMark

UserData

Design time Read / Write Run time Read / Write

Version

Design time Read Run time Read

WaterMark

AR2Std | 183

Page 184: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

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

Note: The watermark properties must be used in the ReportStart sub. The watermark will be clipped and centered on the page unless the WaterMarkSizeMode and WaterMarkAlignment are specified.

Data Type

stdPicture

Availability

Example

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

WaterMarkAlignment

Description

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

Note: The watermark properties should be used in the ReportStart sub. If no WaterMarkAlignment is specified the image will be centered on the page.

Data Type

PictureAlignment

Settings

Availability

Example

Private Sub ActiveReport_ReportStart() Me.WatermarkAlignment = ddPATopRight

Design time Read / Write Run time Read / Write

WaterMarkAlignment

Value Mnemonic Description0 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

AR2Std | 184

Page 185: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

WaterMarkPrintOnPages

Description

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

Note: The watermark properties should be used in the ReportStart sub.

Data Type

String

Availability

Example

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

WaterMarkSizeMode

Description

Sets or returns how the watermark will be sized when the image is rendered on the canvas. The image can be stretch to fill the page, zoomed in on to extended the image to the closest edges, or clipped to keep the image's default size.

Note: The watermark properties should be used in the ReportStart sub. If no WaterMarkSizeMode is specified, the SizeMode will be ddSMClip.

Data Type

SizeMode

Settings

Availability

WaterMarkPrintOnPages

Design time Read / Write Run time Read / Write

WaterMarkSizeMode

Value Mnemonic Description0 ddSMClip (Default) Clips the image. 1 ddSMStretch Stretches the image to fill the print area. 2 ddSMZoom Zooms in on the image.

AR2Std | 185

Page 186: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

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

Zoom

Description

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

Data Type

Integer

Availability

Example

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

ActiveReport Methods

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

AR2Std | 186

Page 187: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

About

Description

Displays the product's information dialog box.

Return Type

None

Syntax

Sub About()

Parameters

None

Example

Private Sub ActiveReport_ReportStart() Me.About End Sub

AddCode

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

AR2Std | 187

Page 188: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

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

Note: The script string should be in an ActiveScripting language.

Return Type

None

Syntax

Sub AddCode(script As String)

Parameters

Example

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

In the Script

Sub OnDataInitialize SetCnnString End Sub

AddControlLicense

Description

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

Return Type

None

Syntax

Sub AddControlLicense(progID As String, licenseKey As String)

Parameters

Name Type DescriptionScript String An ActiveScript string expression containing the full code to be added.

AddControlLicense

Name Type DescriptionProgID String String value indicating the full program ID for the added control LicenseKey String String value indicating the full LicenseKey for the added control

AR2Std | 188

Page 189: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

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

AddNamedItem

Description

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

Return Type

None

Syntax

Sub AddNamedItem(Name As String,Value As Object)

Parameters

Example

RptMain.addNamedItem "GetCos", new clsMath

In the Script Code

Sub OnReportStart myCos = GetCos.ReturnCos End Sub

Cancel

Description

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

Note: Use this method to cancel a job that was started using the Show or Print methods.

AddNamedItem

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

Cancel

AR2Std | 189

Page 190: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

None

Syntax

Sub Cancel()

Parameters

None

Example

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

Export

Description

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

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

Return Type

None

Syntax

Sub Export(Export As Object)

Parameters

Example

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

Export

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

LoadLayout

AR2Std | 190

Page 191: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

LoadLayout

Description

Loads a report layout from either an array or a report saved as an XML file.

Tip: This method can be used to load individualized reports on a client machine and also allows reports to be updated inside a report DLL without having to recompile.

Return Type

None

Syntax

Sub LoadLayout(Data)

Parameters

Example

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

Localize

Description

Localizes the strings used in the preview window for PageWidth, WholePage and the table of contents caption.

Note: To localize the toolbar captions you can use the Tool.Caption property of each tool in the toolbar object.

Return Type

None

Syntax

Sub Localize(stringid text As String)

Parameters

Settings

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.

AR2Std | 191

Page 192: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

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

PageSetup

Description

Displays the system's standard page setup dialog, giving access to the page size, margins, orientation, source and printer settings.

Note: In order to reflect any changes, the report must be run after changes are made to the page setup.

Return Type

Boolean

Syntax

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

Parameters

Settings

Example

Private Sub miFPageSetup() rpt.PageSetup End Sub

PrintReport

Description

PageSetup

Name Type DescriptionhWndParent 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

AR2Std | 192

Page 193: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

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

Return Type

None

Syntax

Sub PrintReport(bDisplayDialog As Boolean)

Parameters

Example

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

ResetScripts

Description

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

Return Type

None

Syntax

Sub ClearNamedItems()

Example

RptMain.ClearNamedItems

Restart

Description

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

Return Type

None

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

AR2Std | 193

Page 194: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Syntax

Sub Restart()

Parameters

None

Example

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

Run

Description

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

Run can be used before an export command or to manipulate the output, such as reordering pages or applying a form template before printing the report.

Return Type

None

Syntax

Sub Run(RunInBackground As Boolean)

Parameters

Example

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

SaveLayout

Description

Saves a report layout in the format specified by SerializeOptions. Saved reports can be loaded into a project during design time and run time.

Tip: This method can be used to save individualized reports to a client's machine so each machine can have individualized reports. This method also allows reports to be saved and loaded back into a report DLL without having to recompile.

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

AR2Std | 194

Page 195: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

None

Syntax

Function SaveLayout(FileName As String, SerializeOptions As SaveOptionTypes)

Parameters

Settings

Example

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

Stop

Description

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

Return Type

None

Syntax

Sub Stop()

Parameters

None

Example

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

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

AR2Std | 195

Page 196: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ActiveReport Events

ActiveReport Events

Event DescriptionDataInitialize Event fired before ReportStart to add custom fields to

report fields collection.

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

AR2Std | 196

Page 197: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

DataInitialize

Description

Event fired before ReportStart to add custom fields to report fields collection. Custom fields can be added to a bound report (one that uses a Data Control to connect and retrieve records) or an unbound report (one that does not depend on a data control to get its records).

In a bound report, the recordset is opened and the recordset fields are added to the custom Fields collection then the DataInitialize event is fired so that new custom fields can be added.

Syntax

Sub DataInitialize()

Parameters

None

Example

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

Error

Description

Occurs only as the result of an ActiveReports error that takes place when no Visual Basic code is being executed.

Note: If you do not code an event procedure for the Error event, Visual Basic will display the error message.

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)

DataInitialize

Error

AR2Std | 197

Page 198: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Syntax

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

Parameters

Example

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

FetchData

Description

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

Syntax

Sub FetchData(eof As Boolean)

Parameters

Example

Private Sub ActiveReport_FetchData(eof As Boolean) ' If we processed all element then we exit the event ' leaving the eof paramter at its default True value ' this will promp AR to end the report If iRow > UBound(arr) Then Exit Sub Fields("OrderID") = arr(iRow).OrderNo Fields("ProductID") = arr(iRow).ProductID

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

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.

AR2Std | 198

Page 199: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Fields("ProductName") = arr(iRow).ProductName Fields("Qty") = arr(iRow).Qty Fields("Price") = arr(iRow).Price Fields("Amount") = arr(iRow).Amount iRow = iRow + 1 ' We must set the eof parameter to False as ' long as there is more data to be processed eof = False End Sub

FindProgress

Description

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

Syntax

Sub ActiveReport_FindProgress(ByVal Result As DDActiveReports2.FindResults)

Parameters

Settings

Example

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

hyperLink

Description

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

Syntax

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

Parameters

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.

HyperLink

Name Type Description Button Integer Integer indicating the mouse button used to click on the hyperlink.

AR2Std | 199

Page 200: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Description

Occurs when the user presses a key while the viewer has focus.

Syntax

Sub KeyDown(KeyCode As Integer, Shift As Integer)

Parameters

KeyPress

Description

Occurs when the user presses and releases an ANSI key.

Syntax

Sub KeyPress(KeyAscii As Integer)

Parameters

KeyUp

Description

Occurs when the user releases a key while the viewer has focus.

Syntax

Sub KeyUp(KeyCode As Integer, Shift As Integer)

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

Name Type Description KeyAscii Integer The standard numeric ANSI code of the pressed key.

KeyUp

AR2Std | 200

Page 201: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Parameters

MouseOver

Description

This event fires when the mouse moves over a report's page. If the mouse moves over a control with a hyperlink, the link is returned. The PageX and PageY parameters are twip values and relative to the canvas displayed.

Syntax

Sub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal hyperLink As String)

Parameters

Example

Private Sub ActiveReport_MouseOver(ByVal PageX As Long, _ ByVal PageY As Long, ByVal hyperLink As String) If hyperLink <> "" And Me.Caption <> "Active Link: " & _ hyperLink Then ' If the hyperlink changes and is not blank update the ' caption Me.Caption = "Active Link: " & hyperLink ElseIf hyperLink = "" And Me.Caption <> _ "Annual Report: Fall Quarter" Then ' If the user has just moved off of a link, update ' caption Me.Caption = "Annual Report: Fall Quarter" End If End Sub

NoData

Description

Occurs when the data control's recordset is empty. There is no data to be processed.

Note: You can use this event to either cancel the report or print a page with message informing the user that the report did not return any records to print.

Syntax

Sub NoData()

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 HyperLink String String value for the hyperlink

NoData

AR2Std | 201

Page 202: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub ActiveReport_NoData() Dim sMsg As String sMsg = "Report has no data, " & _ "click Cancel to abort, " & _ "OK to print without data" If MsgBox(sMsg, vbOKCancel, "No Data") = vbCancel Then rptInvoice.Cancel End If End Sub

PageEnd

Description

Occurs after each page in the report is rendered.

Note: You can use this event to update any variables that you need for each page when running an unbound report.

Syntax

Sub PageEnd()

Example

Private Sub ActiveReport_PageEnd() ' Update the total number of pages iTotalPages = iTotalPages + 1 End Sub

PageStart

Description

During the report's processing, this even Occurs before a page is rendered.

Note: You can use this event to initialize any variables that you need for each page when running an unbound report.

Syntax

Sub PageStart()

Example

Private Sub ActiveReport_PageStart() ' Reset the page total lPageTotal = 0 End Sub

PrintAborted

PageEnd

PageStart

PrintAborted

AR2Std | 202

Page 203: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Called in the PrintReport Method when the user cancels a print job before it finishes.

Syntax

Sub PrintAborted()

Example

Private Sub ActiveReport_PrintAborted() bPrintFlag = False End Sub

PrintProgress

Description

Fired for each page during a print job, you can use this event to update a custom print dialog if the built-in progress dialog is not used.

Syntax

Sub PrintProgress(PageNumber As Long)

Parameters

Example

' in your progress dialog form Public bCancelled As Boolean Private Sub btnCancel_Click() bCancelled = True End Sub ' In the report PrintProgress Event Private Sub ActiveReport_PrintProgress(PageNumber As Long) frmProgress.lblCurrPage.Caption = Str(PageNumber) If bCancelled Then rpt.Cancel End Sub

PromptDialogClosed

Description

Fired after parameter values for a query are entered or the parameters dialog is cancelled.

Syntax

Sub PromptDialogClosed(ByVal Cancelled As Boolean)

Parameters

PrintProgress

Name Description PageNumber The current page number being printed.

PromptDialogClosed

AR2Std | 203

Page 204: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim i As Integer If Cancelled = True Then Me.Cancel Exit Sub End If 'If date parameter is empty set the default date If Me.Parameters(0).Value = "" Then Me.Parameters(0).Value = "1/1/95" End If 'if orderID parameter is empty set the default to zero If Me.Parameters(1).Value = "" Then Me.Parameters(1).Value = "0" End If End Sub

ReportEnd

Description

Occurs when report finishes processing.

Note: You can use this event to close or free any objects that you were using while running a report in unbound mode, or to display an information message to the end user.

Syntax

Sub ReportEnd()

Example

' When Report is completed, close all open recordsets. Private Sub ActiveReport_ReportEnd() rsInvoices.Close Set rsInvoices = Nothing End Sub

ReportStart

Description

Occurs before a report starts processing.

Note: You can use this event to initialize any objects or variable that you might need while running a report.

Syntax

Sub ReportStart()

Example

Private Sub ActiveReport_ReportStart()

Name Type Description Cancelled Boolean Returns true if the parameters dialog is cancelled.

ReportEnd

ReportStart

AR2Std | 204

Page 205: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

' Open the recordset for unbound report Set rs = db.OpenRecordset("SELECT * FROM Invoices") End Sub

TOCClick

Description

This event is fired when mouse is clicked inside the table of contents area.

Syntax

Sub TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long)

Parameters

Settings

TOCSelChange

Description

Fired when the TOC selection changes.

Syntax

Sub 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 &H40 ddHT_ONITEMSTATEICON On the state icon for a tree view item that is in a user-defined state. &H100 ddHT_ABOVE Above the client area of the treeview window. &H200 ddHT_BELOW Below the client area of the treeview window. &H300 ddHT_TORIGHT To the right of the client area &H400 ddHT_TOLEFT To the left of the client area

TOCSelChange

Name Type Description ItemIndex Long The index of the TOC entry item that was selected.

ToolbarClick

AR2Std | 205

Page 206: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ToolbarClick

Description

Fired when the user clicks on one of the preview window tools.

Syntax

Sub ToolbarClick(ByVal Tool As DDTool)

Parameters

Example

Private Sub ActiveReport_ToolbarClick(ByVal tool As _ DDActiveReports2.DDTool) If tool.Caption = "Printer Setup" Then rpt.Printer.SetupDialog End If End Sub

ARViewer Control ARViewer Properties

ARViewer Methods

ARViewer Events

ARViewer Properties

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

AR2Std | 206

Page 207: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

AllowSplitter

Description

Sets or returns whether or not the viewer can be split into two windows. Setting AllowSplitter to False will remove the SplitterBar from the viewer control.

Data Type

Boolean

Availability

Example

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

BackColor

Description

Sets or returns the background color of the viewer control.

Data Type

OLE_COLOR

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

AR2Std | 207

Page 208: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

BorderStyle

Description

Sets or returns the viewer control's border style.

Data Type

Integer

Settings

Availability

DataPath

Description

Sets or returns the report file (RDF) URL to download and view in an HTML page.

Data Type

String (URL)

Availability

Example

<script LANGUAGE="VBScript"> <!-- Sub window_onload() ' set the initial reportsource data path arv.DataPath="reports/catalog.rdf" End Sub Sub cboReport_OnChange() Select case cboReport.Value Case "optRpt1":

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

AR2Std | 208

Page 209: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

Description

Returns an object in a collection.

Data Type

Object

Availability

Pages

Description

Returns a reference to the pages displayed in the viewer.

Note: The pages collection is zero based.

Data Type

Pages Collection

Availability

Example

Object

Run time Read-Only

Pages

Run time Read / Write

AR2Std | 209

Page 210: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

' Run two or more reports and display both in the viewer by inserting their pages ' into the viewer's pages collection Dim pg As Canvas Report1.Run False Report2.Run False For Each pg In Report1.Pages ARViewer1.Pages.Insert ARViewer1.Pages.Count, pg Next For Each pg In Report2.Pages ARViwer.Pages.Insert ARViewer1.Pages.Count, pg Next

PaperColor

Description

Sets or returns the background color of the paper in the viewer window.

Data Type

OLE_COLOR

Availability

Example

Private Sub btnViewReport_Click() Load frmRptViewer ' Change the Paper Color from White to Grey frmRptViewer.arv.PaperColor = &HC0C0C0 ' Set the Table of Contents Tree to Visible frmRptViewer.arv.TOCVisible = True frmRptViewer.arv.ToolBar.Tools.Add "Printer Setup" frmRptViewer.Show End Sub

Printer

Description

Returns a reference to the viewer's printer object. You can use this property to set or modify printer settings at run time.

Data Type

Printer

Availability

Example

PaperColor

Design time Read / Write Run time Read / Write

Printer

Run time Read / Write

AR2Std | 210

Page 211: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

' Set the number of copies to print Printer.Copies = 2

ReportSource

Description

Sets or returns a reference to the linked report object. This property is set to a new instance of the report you want the control to preview.

Data Type

Object

Availability

Example

Private Sub cmdOpenReport_Click() ARViewer1.ReportSource = New rptCustomerInfo End Sub

RulerVisible

Description

Sets or returns whether or not the viewer's top and side rulers are shown at run time.

Data Type

Boolean

Availability

Example

Private Sub cmdSetRuler_Click() If ARViewer1.RulerVisible Then cmdSetRuler.Caption = "&Show Ruler" ARViewer1.RulerVisible = False Else cmdSetRuler.Caption = "&Hide Ruler" ARViewer1.RulerVisible = True End If End Sub

ReportSource

Run time Read / Write

RulerVisible

Design time Read / Write Run time Read / Write

Status

AR2Std | 211

Page 212: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Status

Description

Returns the status of the viewer when loading report pages asynchronously into its internal cache. You can use this property to verify that all report pages have been loaded into the pages collection.

When the viewer is connected to a report using the ReportSource property, it creates a proxy of the reports Pages collection locally. It then starts loading the pages into that proxy. This allows you to download pages asynchronously over a slow connection.

Data Type

ViewerStatus

Availability

TOC

Description

Returns a reference to the report's table of contents object. The TOC object gives access to adding and removing TOC entries as well as methods for navigating through the TOC. The table of contents is used as a navigation tree or an index to the report and may contain entries from any page on the report.

The TOC entries are indexed by their page numbers and is a zero based collection. When a TOC item is selected, the displayed report will jump to the top of the section where the item was added to the TOC, unless the report is in full page view. For instance, if the entry was added in a GroupFooter, selecting the item from the TOC will take you to the top of the item's GroupFooter.

Note: The TOC entries are only available after the report has run.

Data Type

TOC

Availability

Example

' Command button implementations of a custom toolbar Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position = 0) btnForward.Enabled = (.Position = .Count) End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position = 0)

Design time N/A Run time Read

TOC

Design time N/A Run time Read / Write

AR2Std | 212

Page 213: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

btnForward.Enabled = (.Position = .Count) End With End Sub

TOCEnabled

Description

Enables or disables the table of contents tree.

Data Type

Boolean

Availability

Example

' Disable the table of contents tree arv.TOCEnabled = False

TOCVisible

Description

Determines whether the viewer's toolbar is displayed in the viewer window.

Data Type

Boolean

Availability

Example

Private Sub btnViewReport_Click() Load frmRptViewer frmRptViewer.arv.TOCVisible = True frmRptViewer.arv.ToolBar.Tools.Add "Printer Setup" frmRptViewer.Show End Sub

TOCEnabled

Design time Read / Write Run time Read / Write

TOCVisible

Design time Read / Write Run time Read / Write

TOCWidth

AR2Std | 213

Page 214: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

TOCWidth

Description

Sets or returns the width of the table of contents tree in twips.

Data Type

Single

Availability

Example

arv.TOCWidth = 2880

Toolbar

Description

Returns a reference to the viewer's toolbar object. The toolbar object allows you modify the toolbar's icons and tools.

Data Type

Toolbar

Availability

Example

Private Sub btnViewReport_Click() Load frmRptViewer frmRptViewer.arv.TOCVisible = True frmRptViewer.arv.ToolBar.Tools.Add "Printer Setup" frmRptViewer.Show End Sub

ToolbarVisible

Description

Determines whether the viewer's toolbar is displayed in the viewer window.

Data Type

Boolean

Availability

Design time N/A Run time Read / Write

ToolBar

Run time Read

ToolbarVisible

Design time Read / Write Run time Read / Write

AR2Std | 214

Page 215: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

' Turn the toolbar off and use our own custom toolbar Load frmViewer frmViewer.arv.ToolbarVisible = False

UseSourcePrinter

Description

Sets or returns whether the viewer's printer (False) or ReportSource printer (True) is used to print the report.

Data Type

Boolean

Availability

Zoom

Description

Sets or returns the zoom factor of the displayed page.

Data Type

Integer - Valid range is 10-800 or -1 for Fit PageWidth and -2 for Fit Whole Page.

Availability

Example

' Load the viewer form and set the zoom to 75% frmViewer.Show frmViewer.arv.Zoom = 75

ARViewer Methods

UseSourcePrinter

Design time Read / Write Run time Read / Write

Zoom

Design time Read / Write Run time Read / Write

ARViewer Methods

Method DescriptionCopyPageToClipboard Copies the indicated page to the clipboard.

AR2Std | 215

Page 216: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

CopyPageToClipboard

Description

Copies the indicated page to the clipboard. The page is an integer value indicating the page number, minus 1, you wish to copy. If no page number is indicated, the current page will be copied to the clipboard.

Note: The page count begins with 0.

Return Type

None

Syntax

Sub CopyPageToClipboard([Page])

Parameters

Example

Private Sub cmdCopy_Click() ARV.CopyPageToClipboard 0 'Copies the first page End Sub

Find

Description

Searches the report for a specified string.

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.

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

AR2Std | 216

Page 217: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

None

Syntax

Sub Find(View As SplitViewTypes, SearchText As String, Direction As SearchDirectionTypes, MatchCase As Boolean, MatchWord As Boolean)

Parameters

Settings

SplitViewTypes

SearchDirectionTypes

Example

Private Sub cmdSearch_Click() ARV.Find ddSVFirst, txtSrch.Text, ddSDDown, False, True End Sub

Localize

Description

Allows you to localize the strings used in the viewer window.

Note: To localize the toolbar captions, you can use the Tool.Caption property of each tool in the toolbar object.

Return Type

None

Syntax

Sub Localize(Type As LocalizeTypes, text As String)

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

AR2Std | 217

Page 218: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Parameters

Settings

Example

Private Sub Form_Load() 'Change "Page Width" caption arv.Localize ddLTPageWidth, "Largura Da Página " 'Change TOC Header caption arv.Localize ddLTViewerTocHeader, "Índice " 'Change "Whole Page" caption arv.Localize ddLTWholePage, "Página Inteira " End Sub

MultiplePage

Description

Switches the viewer settings so multiple pages can be displayed at one time.

Return Type

None

Syntax

Sub MultiplePage(View As SplitViewTypes, rows As Integer, cols As Integer)

Parameters

Settings

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.

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

AR2Std | 218

Page 219: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

PrintReport

Description

Prints the viewer pages collection to the selected device.

Return Type

None

Syntax

Sub PrintReport(bDisplayDialog As Boolean)

Parameters

Example

' Menu Item Print Private Sub miFPrint_Click() ARViewer1.PrintReport False End Sub

Refresh

Description

Forces the viewer control to repaint itself.

Return Type

None

Syntax

Sub Refesh()

Parameters

None

Example

arv.Refresh

SinglePage

Description

Switches the Viewer back to displaying a single page.

Return Type

Name Type Description bDisplayDialog Boolean Specifies whether ActiveReports should

display the print dialog before printing the report.

Refresh

SinglePage

AR2Std | 219

Page 220: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

None

Syntax

Sub SinglePage(View As SplitViewTypes)

Parameters

Settings

ARViewer Events

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.

ARViewer Events

Event Description DblClick Fired when the user double clicks the mouse in the viewer.

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

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() MouseDown Fired when a mouse button is pressed down.

Sub MouseDown(Button As Integer, Shift As Integer, X As

AR2Std | 220

Page 221: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

DblClick

Description

Fired when the user double clicks the mouse (left mouse button) in the viewer area. You can use this event to retrieve information about the clicked position and display more detail about it.

Syntax

Sub DblClick()

Parameters

None

Error

Description

Occurs only as the result of an ActiveReports error that takes place when no Visual Basic code is being executed.

Note: If you do not code an event procedure for the Error event, Visual Basic will display the error message.

Syntax

Single, Y As Single) MouseMove Fired as the mouse moves over the viewer area.

Sub MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

MouseOver This event fires when the mouse moves over a report page. If the mouse moves over a control with a hyperlink, then the link will be returned.

Sub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal Hyperlink As String)

MouseUp Fired when a mouse button is released.

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) ZoomChanged Fired when the viewer's zoom percentage changes.

Sub ZoomChanged()

DblClk

Error

AR2Std | 221

Page 222: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sub Error (ByVal Number As Integer, ByVal DescriptionAs String, ByVal SCode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)

Parameters

Example

Private Sub ARViewer1_Error(ByVal Number As Integer, ByVal Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean) CancelDisplay = True App.LogEvent "Error Number: " & str(Number) & " " & _ Description & " Source: " & Source End Sub

FindProgress

Description

This event fires when a search is performed on a report loaded into the viewer. When a search reaches a report's end or beginning, the event will fire.

Syntax

Sub arv_FindProgress(ByVal Results As DactiveReportsViewer2Ctl.FindResults)

Parameters

Settings

Example

Private Sub arv_FindProgress(ByVal Result As DDActiveReportsViewer2Ctl.FindResults) 'If the end of the report is reached show a message If Result = ddFRNotFount Then

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.

AR2Std | 222

Page 223: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

MsgBox "No Matching Records" End If End Sub

hyperLink

Description

This event fires when a hyperlink is clicked. The event can be used to redirect the hyperlink or prevent the link from activating.

Syntax

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

Parameters

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

Description

Occurs when the user presses a key while the viewer has focus.

Syntax

Sub KeyDown(KeyCode As Integer, Shift As Integer)

Parameters

KeyPress

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

AR2Std | 223

Page 224: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Occurs when the user presses and releases an ANSI key.

Syntax

Sub KeyPress(KeyAscii As Integer)

Parameters

KeyUp

Description

Occurs when the user releases a key while the viewer has focus.

Syntax

Sub KeyUp(KeyCode As Integer, Shift As Integer)

Parameters

LoadCompleted

Description

LoadCompleted is fired when all the pages from the ReportSource are loaded into the viewer control.

Syntax

Sub LoadCompleted()

Parameters

None

Example

' Update a PageCount label and enable the TOC button ' when all pages are loaded Private Sub LoadCompleted() lblPages.Caption = Str(arv.Pages.Count) arv.TOCEnabled = True End Sub

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

AR2Std | 224

Page 225: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

MouseDown

Description

Fired when the user presses one of the mouse buttons in the viewer area.

Syntax

Sub MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Parameters

<

MouseMove

Description

Occurs when the user moves the mouse over the viewer control area.

Syntax

Sub MouseMove( As Integer, Shift As Integer, X As Single, Y As Single)

Parameters

MouseOver

Description

This event fires when the mouse moves over a report page in the viewer. If the mouse moves over a control with a hyperlink, the link will be returned. The PageX and PageY parameters are twip values relative to the canvas displayed.

Syntax

Name Type DescriptionButton 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 DescriptionButton 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

AR2Std | 225

Page 226: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sub MouseOver(ByVal PageX As Long, ByVal PageY As Long, ByVal hyperLink As String)

Parameters

Example

Private Sub ActiveReport_MouseOver(ByVal PageX As Long, _ ByVal PageY As Long, ByVal hyperLink As String) If hyperLink <> "" And arv1.Caption <> "Active Link:" &_ hyperLink Then ' If the hyperlink changes and is not blank update the ' caption arv1.Caption = "Active Link: " & hyperLink ElseIf hyperLink = "" And Me.Caption <> _ "Annual Report: Fall Quarter" Then ' If the user has just moved off of a link, update ' caption arv1.Caption = "Annual Report: Fall Quarter" End If End Sub

MouseUp

Description

Fired when the user releases the pressed mouse button in the viewer area.

Syntax

Sub MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Parameters

PageModeChanged

Description

Fired when the viewer switches between displaying a single page and multiple pages.

Name Type DescriptionPageX 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

MouseUp

Name Type DescriptionButton 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

AR2Std | 226

Page 227: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Syntax

Sub PageModeChanged(ByVal MultiplePage As Boolean)

Parameters

PrintAborted

Description

Called in the PrintReport Method when the user cancels a print job before it finishes.

Syntax

Sub PrintAborted()

Example

Private Sub ARViewer21_PrintAborted() bPrintFlag = False End Sub

TOCClick

Description

This event is fired when mouse is clicked inside the table of contents area.

Syntax

Sub TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long)

Parameters

Settings

Name Type DescriptionMultiplePage 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

TOCClick

Name Type DescriptionButton 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.

AR2Std | 227

Page 228: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

TOCSelChange

Description

Fired when the TOC selection changes.

Syntax

Sub TOCSelChange (ByVal ItemIndex As Long)

Parameters

ToolbarClick

Description

Fired when the user clicks on one of the viewer's toolbar tools.

Syntax

Sub ToolbarClick(ByVal Tool As DDTool)

Parameters

Example

Private Sub arv_ToolbarClick(ByVal tool As _ DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

&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 &H40 ddHT_ONITEMSTATEICON On the state icon for a tree view item that is

in a user-defined state. &H100 ddHT_ABOVE Above the client area of the treeview

window. &H200 ddHT_BELOW Below the client area of the treeview

window. &H300 ddHT_TORIGHT To the right of the client area. &H400 ddHT_TOLEFT To the left of the client area.

TOCSelChange

Name Type DescriptionItemIndex Long The index of the TOC entry item that was

selected.

ToolbarClick

Name Type DescriptionTool DDTool A reference to the tool object that specified

the clicked tool.

AR2Std | 228

Page 229: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ZoomChanged

Description

Fired when the viewer's zoom percentage changes.

Syntax

Sub ZoomChanged()

Border Properties

BottomColor, LeftColor, RightColor, TopColor

Description

Sets or returns the color of the line drawn at the specified edge.

Data Type

OLE_COLOR

Availability

Example

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

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

AR2Std | 229

Page 230: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

PageBorder.TopStyle = ddBLSolid

BottomStyle, LeftStyle, RightStyle, TopStyle

Description

Sets or returns the line style at the specified edge.

Data Type

BorderLineStyle

Availability

Example

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

Shadow

Description

Determines whether to draw a shadow around the control.

Data Type

Boolean

Availability

Example

Private Sub Detail_Format() If txtSlaes.Datavalue > 10000 Then txtCompanyName.Border.Shadow = True End If End Sub

BottomStyle, LeftStyle, RightStyle, TopStyle

Design time Read / Write (Borders Property Sheet) Run time Read / Write

Shadow

Design time Read / Write (Borders Property Sheet) Run time Read / Write

AR2Std | 230

Page 231: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Canvas Canvas Properties

Canvas Methods

Canvas Properties

Alignment

Description

Sets or returns the horizontal alignment of the text drawn using DrawText method.

Data Type

Integer

Settings

Availability

Example

Canvas

Canvas Properties

Property Data Type DescriptionAlignment 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. 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 Description0 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

AR2Std | 231

Page 232: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub PageHeader_Format()< ' Draw a round rectangle with Top Secret centered With Canvas .DrawRoundRect 100, 100, 1500, 300, 10, 10 .Alignment = ddTXCenter .DrawText "Top Secret", 100, 100, 1500, 300 End With End Sub

BackColor

Description

Sets or returns the background color or fill color for the objects.

Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

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

BackStyle

Description

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

Data Type

BackStyle

Availability

BackColor

Design time Read / Write Run time Read / Write

BackStyle

AR2Std | 232

Page 233: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

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

Font

Description

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

Data Type

stdFont

Availability

Example

Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor

Description

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

Data Type

Design time Read / Write Run time Read / Write

Font

Design time Read / Write Run time Read / Write

ForeColor

AR2Std | 233

Page 234: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

OLE_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 font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial" Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

Height

Description

Sets or returns the vertical drawing area for the canvas in twips.

Data Type

Long

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 = vbRed Me.Canvas.BackStyle = 1 Me.Canvas.Width = 4 * 1440 Me.Canvas.Height = 5 * 1440 Me.Canvas.DrawRect 0, 0, Canvas.Width, Canvas.Height End Sub

Orientation

Description

Sets or returns the orientation of the canvas object. This property should be used when working with, or adding, individual canvases. The canvas orientation is separate from changing the PageSettings' or printer's orientation because it only affects the specified page. By using Canvas.Orientation, a project can be set up to

Design time Read / Write Run time Read / Write

Height

Design time N/A Run time Read / Write

Orientation

AR2Std | 234

Page 235: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

manipulate the individual page's orientation. After manipulating the canvas orientation, the canvas' width and height must also be specified to reflect the correct page size.

Note: Setting a page's canvas orientation will not set the PageSettings' or Printer's orientation for that page.

Data Type

PrtOrientation

Availability

Example

Private Sub CreateCoverSheet() ' Add a new page to a viewer control and set its ' orientation to Landscape regardless of what the ' other pages are set to ARViewer1.Pages.InsertNew(0) ARViewer1.Pages(0).Orientation = ddPOLandscape ' draw text on the page. End Sub

PenStyle

Description

Sets the pen style that is used to draw lines and shapes to the canvas.

Data Type

Integer

Settings

Availability

Example

Private Sub PageHeader_Format() ' Draw a round rectangle with Top Secret centered With Canvas .PenStyle = ddLSSolid .PenWidth = 2 .DrawRoundRect 100, 100, 1500, 300, 10, 10

Run time Read / Write

PenStyle

Value Mnemonic Description0 ddLSTransparent No line. 1 ddLSSolid 2 ddLSDash 3 ddLSDot 4 ddLSDashDot 5 ddLDDashDotDot

Design time N/A Run time Read / Write

AR2Std | 235

Page 236: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

.Alignment = ddTXCenter .DrawText "Top Secret", 100, 100, 1500, 300 End With End Sub

PenWidth

Description

Sets or returns the line weight used to draw lines and shapes to the canvas object.

Data Type

Integer (line width 1lw=10 twips)

Availability

Example

Private Sub PageHeader_Format() ' Draw a round rectangle with Top Secret centered With Canvas .PenStyle = ddLSSolid .PenWidth = 2 .DrawRoundRect 100, 100, 1500, 300, 10, 10 .Alignment = ddTXCenter .DrawText "Top Secret", 100, 100, 1500, 300 End With End Sub

Tag

Description

Sets or returns a user-defined value associated with the canvas object. You can use this property to store information about the page that you might want to retrieve later from the Pages collection.

Data Type

Variant

Availability

Example

Private Sub ghCustomer_AfterPrint()

PenWidth

Design time N/A Run time Read / Write

Tag

Design time N/A Run time Read / Write

AR2Std | 236

Page 237: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

'Set the tag to the customer fax number 'Use it later to change printer settings to send the fax Canvas.Tag = txtCustomerFax.DataValue End Sub

TextAngle

Description

Sets or returns the clock-wise angle used to rotate the text drawn to the canvas object.

Note: Units are in 1/10 of a degree. For example, 900 units = 90 degrees clock-wise.

Data Type

Long

Availability

Example

' Draw Confidential Message at 45 degree angle Canvas.TextAngle = 450 Canvas.Font.Name = "Arial" Canvas.Font.Size = 48 Canvas.DrawText("Confidential", _ 3*1440, 2*1440, 3*1440, 4*1440)

VerticalAlignment

Description

Sets or returns the vertical position of the text relative to the containing area.

Data Type

Integer

Settings

Availability

Example

TextAngle

Design time N/A Run time Read / Write

VerticalAlignment

Value Mnemonic Description0 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

AR2Std | 237

Page 238: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Canvas.VerticalAlignment = ddTXTop

Width

Description

Sets or returns the horizontal drawing area for the canvas in twips.

Data Type

Long

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 = vbRed Me.Canvas.BackStyle = 1 Me.Canvas.Width = 4 * 1440 Me.Canvas.Height = 5 * 1440 Me.Canvas.DrawRect 0, 0, Canvas.Width, Canvas.Height End Sub

Canvas Methods

Width

Design time N/A Run time Read / Write

Canvas Methods

Method DescriptionClear Clear the canvas object.

Sub Clear() DrawEllipse Draws an elliptical shape to the canvas at the specified

coordinates.

Sub DrawEllipse(left As Long, top As Long, width As Long, height As Long)

DrawLine Draws a line to the canvas at the specified coordinates. The line width and style depend on the PenWidth and PenStyle property settings.

Sub DrawLine( x1 As Long , y1 As Long , x2 As Long , y2 As Long )

DrawPicture Draws a picture to the canvas at the specified coordinates.

Sub DrawPicture(hPic As StdPicture, left As Long, top As Long, width As Long, height As Long)

DrawPictureLink Draws the specified picture, with a hyperlink, to the canvas surface at the specified coordinates.

Sub DrawPictureLink( Picture as stdPicture , Left As

AR2Std | 238

Page 239: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Long , Top As Long , Width As Long , Height As Long , HyperLink As String )

DrawRect Draws a rectangular shape to the canvas at the specified coordinates. The line width and style depend on the PenWidth and PenStyle property settings.

Sub DrawRect(left As Long, top As Long, width As Long, height As Long)

DrawRoundRect Draws a round rectangular shape to the canvas at the specified coordinates. The line width and style depend on the current PenWidth and PenStyle property settings.

Sub DrawRoundRect( left As Long , top As Long , width As Long , height As Long , w As Long , h As Long)

DrawText Prints a text string to the canvas. The font and color of the printed text depend on the current Font, BackColor, BackStyle and ForeColor property settings. The text is clipped to the specified coordinates.

Sub DrawText( text As String , x As Long , y As Long , width As Long , height As Long )

DrawTextLink

Prints a text string with a hyperlink to the canvas. The font and color of the printed text depend on the current Font, BackColor, BackStyle and ForeColor property settings. The text is clipped to the specified coordinates.

Sub DrawTextLink( Text As String , X As Long , Y As Long , Width As Long , Height As Long , Hyperlink As String )

FillRect Fills the rectangle at the specified coordinates with solid ForeColor.

Sub FillRect( left As Long , top As Long , width As Long , height As Long )

IntersectClipRect Creates a clipping rectangle. All drawing will be clipped to the new clipping rectangle.

Sub IntersectClipRect( x As Long , y As Long , w As Long , h As Long )

Load Loads a previously saved canvas object from the specified file.

Sub Load( FileName As String ) MeasureParagraphHeight Returns the height of a formatted paragraph string with

the specified width.

Function MeasureParagraphHeight( text As String , width As Long ) As Long

MeasureText Returns the width and height of a text string when printed to the canvas with the current font settings.

Sub MeasureText( text As String , width As Long , height As Long )

Overlay Overlays the specified canvas object on top of the canvas object.

Sub Overlay( Canvas As Canvas ) PopClipRect Restores the previous clipping rectangle.

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.

AR2Std | 239

Page 240: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Clear

Description

Clears the canvas of all prior output

Return Type

None

Syntax

Sub Clear()

Parameters

None

Example

Dim cv As New Canvas cv.TextOut "Sales Report", 1440, 1000 'Add this page to the pages collection rpt.Pages.Insert rpt.Pages.Count, cv cv.Clear 'Create the second page

DrawEllipse

Description

DrawEllipse method draws an elliptical shape to the canvas object at the specified coordinates.

Return Type

None

Syntax

Sub DrawEllipse(left As Long, top As Long, width As Long, height As Long)

Parameters

Example

Canvas.DrawEllipse 1440, 1440, 1440, 2880

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 DescriptionLeft Long Left coordinate of the ellipse shape (Twips). Top Long Top coordinate of the ellipse shape (Twips) Width Long Width of the ellipse shape (Twips) Height Long Height of the ellipse shape (Twips)

AR2Std | 240

Page 241: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

DrawLine

Description

DrawLine method draws a line to the canvas at the specified coordinates. The line width and style depend on the PenWidth and PenStyle property settings.

Return Type

None

Syntax

Sub DrawLine(x1 As Long, y1 As Long, x2 As Long, y2 As Long)

Parameters

Example

Canvas.PenWidth = 2 Canvas.DrawLine 0, 1440, PrintWidth, 1440

DrawPicture

Description

Draws the specified picture to the canvas surface at the specified coordinates.

Return Type

None

Syntax

Sub DrawPicture(hPic As stdPicture, left As Long, top As Long, width As Long, height As Long)

Parameters

Example

Dim pic As StdPicture Set pic = LoadPicture App.Path & "\TopSecret.WMF" Canvas.DrawPicture pic, 0,0,Canvas.Width, Canvas.Height

DrawLine

Name Type Descriptionx1, y1 Long Coordinates of the line's starting point

(Twips). x2, y2 Long Coordinates of the line's ending point (Twips).

DrawPicture

Name Type DescriptionhPic StdPicture Picture object to be drawn to the canvas left, top Long Coordinates of the picture. width, height Long Dimensions of the picture.

DrawPictureLink

AR2Std | 241

Page 242: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

DrawPictureLink

Description

Draws the specified picture, with an embedded hyperlink, to the canvas surface at the coordinates indicated.

Return Type

None

Syntax

Sub DrawPictureLink(Picture As stdPicture, Left As Long, Top As Long, Width As Long, Height As Long, Hyperlink As String)

Parameters

Example

Private Sub ActiveReport_PageStart() Dim pic As StdPicture Dim str As String 'Set the picture to load for DrawPictureLink Set pic = LoadPicture(App.Path & "\ARLogo.jpg") 'Set the text to use with DrawTextLink str = "Link To DataDynamics Web Page" 'Draw image to canvas and attach a hyperlink Canvas.DrawPictureLink pic, 1 * 1440, 1 * 1440, _ 2 * 1440, 2 * 1440, "www.datadynamics.com" 'Set a font name and size to use on the canvas Canvas.Font.Name = "Arial" Canvas.Font.Size = 18 'Draw text to canvas and attach a hyperlink Canvas.DrawTextLink str, 1 * 1440, 4 * 1440, _ 3 * 1440, 4 * 1440, "www.datadynamics.com" End Sub

DrawRect

Description

DrawRect method draws a rectangular shape to the canvas object at the specified coordinates. The line width and style depend on the PenWidth and PenStyle property settings.

Return Type

None

Syntax

Sub DrawRect(left As Long, top As Long, width As Long, height As Long)

Name Type DescriptionPicture 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

AR2Std | 242

Page 243: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Parameters

Example

For i = 1440 to 3 * 1440 Step 300 •Canvas.DrawRect 100, I, PrintWidth 200, 300 Next i

DrawRoundRect

Description

DrawRoundRect method draws a round rectangular shape to the canvas at the specified coordinates. The line width and style depend on the current PenWidth and PenStyle property settings.

Return Type

None

Syntax

Sub DrawRoundRect(Left As Long, Top As Long, Width As Long, Height As Long, w As Long, h As Long)

Parameters

Example

Private Sub PageHeader_Format() ' Draw a round rectangle with Top Secret centered With Canvas .PenStyle = ddLSSolid .PenWidth = 2 .DrawRoundRect 100, 100, 1500, 300, 10, 10 .Alignment = ddTXCenter .DrawText "Top Secret", 100, 100, 1500, 300 End With End Sub

Name Type DescriptionLeft 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 DescriptionLeft 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)

DrawText

AR2Std | 243

Page 244: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

DrawText

Description

DrawText prints a text string to the canvas using the current font and color settings. It wraps the text to fit within the bounds of the specified coordinates.

Note: If the text is too large, it will be clipped to the specified region.

Return Type

None

Syntax

Sub DrawText(Text As String, x As Long, y As Long, Width As Long, Height As Long)

Parameters

Example

' Draw Confidential Message at 45 degree angle Canvas.TextAngle = 450 Canvas.Font.Name = "Arial" Canvas.Font.Size = 48 Canvas.DrawText("Confidential", _ 3*1440, 2*1440, 3*1440, 4*1440)

DrawTextLink

Description

DrawTextLink uses the canvas's current font and color settings to print a text string, with embedded hyperlink, to the canvas at the indicated coordinates. It wraps the text to fit within the bounds of the specified coordinates.

Note: If the text is too large, it will be clipped to the specified region.

Return Type

None

Syntax

Sub DrawTextLink(Text As String, x As Long, y As Long, Width As Long, Height As Long, Hyperlink As String)

Parameters

Name Type DescriptionText 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 DescriptionText 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)

AR2Std | 244

Page 245: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub ActiveReport_PageStart() Dim pic As StdPicture Dim str As String 'Set the picture to load for DrawPictureLink Set pic = LoadPicture(App.Path & "\ARLogo.jpg") 'Set the text to use with DrawTextLink str = "Link To DataDynamics Web Page" 'Draw image to canvas and attach a hyperlink Canvas.DrawPictureLink pic, 1 * 1440, 1 * 1440, _ 2 * 1440, 2 * 1440, "www.datadynamics.com" 'Set a font name and size to use on the canvas Canvas.Font.Name = "Arial" Canvas.Font.Size = 18 'Draw text to canvas and attach a hyperlink Canvas.DrawTextLink str, 1 * 1440, 4 * 1440, _ 3 * 1440, 4 * 1440, "www.datadynamics.com" End Sub

FillRect

Description

FillRect fills the rectangle at the specified coordinates with solid ForeColor.

Note: FillRect does not draw a border around the rectangle.

Return Type

None

Syntax

Sub FillRect(left As Long, top As Long, width As Long, height As Long)

Parameters

Example

rptSales.Pages(0).ForeColor = vbBlue rptSales.Pages(0).FillRect 1440, 1440, 2880, 720

IntersectClipRect

Hyperlink String String indicating the URL for the hyperlink

FillRect

Name Type DescriptionLeft 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)

IntersectClipRect

AR2Std | 245

Page 246: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Sets a clipping rectangle on the canvas at the specified coordinates. All drawing methods will be clipped to the new clipping region.

Note: •To remove the current clipping rectangle, Call the method with 1 value for all parameters. You should use the PushClipRect to save the current clipping rectangle before setting a new one.

Return Type

None

Syntax

Sub IntersectClipRect(x As Long, y As Long, w As Long, h As Long)

Parameters

Example

Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.DrawText "Clipping regon set to 1000,1000,5000,5000. The two lines (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800< cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.DrawText "Clipping regon set to 500,500,3000,3000. The two lines (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.PushClipRect cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.PopClipRect cnv.DrawText "Clipping region set back to 500,500,3000,3000. The two lines (H and V) should be crop to fit in this box.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = Nothing

Load

Description

Loads the contents of a canvas object from the specified file.

Name Type Descriptionx 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

AR2Std | 246

Page 247: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

None

Syntax

Sub Load(FileName As String)

Parameters

Example

Private Sub OverlayForm() Dim cv As New Canvas Dim pg As Canvas ' Load a saved canvas file cv.Load App.Path "\InvoiceForm.cnv" ' overlay it on all report pages For Each pg In rpt.Pages Pg.Overlay cv Next End Sub

MeasureParagraphHeight

Description

Returns the height a formatted paragraph string would have based off of a specified width.

Note: When using MeasureParagraphHeight, the canvas font needs to match the controls font.

Return Type

Long

Syntax

Function MeasureParagraph(Text As String, Width As Long) As Long

Parameters

Remarks

When using this function to size a field control or a label to its contents, you should account for the internal margins of the controls. The margin values are 40 horizontally and 30 vertically.

Example

Private Sub Detail_Format() Dim str As String

Name Type Descriptionfilename String A valid filename that contains a previously

saved canvas object

MeasureParagraphHeight

Name Type DescriptionText String The text string to be measured Width Long Specified the width of the paragraph text

string (in twips)

AR2Std | 247

Page 248: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

'Set string to use for the field str = "This is a string that will be used to measure the paragraph height" 'Set the canavs font the same as the field being 'used to make sure the measurements are correct Canvas.Font = Field1.Font 'Set field1's height based off of the measurement With Field1 .Height = Canvas.MeasureParagraphHeight(str, _ .Width - 40) + 30 End With Field1.Text = str End Sub

MeasureText

Description

Returns the width and height of a text string when printed on the canvas with the current font settings.

Return Type

None

Syntax

Sub MeasureText(Text As String, Width As Long, Height As Long)

Parameters

Example

Dim w As Long, h As Long rptSales.Pages(0).MeasureText "Confidential", w, h rptSales.Pages(0).DrawText "Confidential", 1440, 1440, w, h

Overlay

Description

Overlays (layers) the specified canvas object on top of the canvas object. You can use this method to layer a form template or letterhead on top of pages in your report.

Return Type

•None The two canvas objects will be merged.

Syntax

Sub Overlay(Canvas As Canvas)

MeasureText

Name Type DescriptionText String The text string to be measured Width Long Returns the width of the text string (in twips) Height Long Returns the minimum height of the text string

(in twips)

Overlay

AR2Std | 248

Page 249: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Parameters

Example

Private Sub OverlayForm() Dim cv As New Canvas Dim pg As Canvas ' Run the report to create the pages collection rptInvoice.Run ' Load a saved canvas file cv.Load App.Path & "\InvoiceForm.cnv" ' overlay it on all report pages For Each pg In rptInvoice.Pages Pg.Overlay cv Next End Sub

PopClipRect

Description

Restores the previous clipping rectangle. You should call the PushClipRect before creating a new clipping rectangle using IntersectClipRect. Then, call PopClipRect to restore the original clipping rectangle.

Return Type

None

Syntax

Sub PopClipRect()

Parameters

NoneSample

Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.DrawText "Clipping regon set to 1000,1000,5000,5000. _ The two lines (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.DrawText "Clipping regon set to 500,500,3000,3000. The two lines _ (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas

Name Type DescriptionCanvas Canvas A valid pointer to the overlay canvas object

PopClipRect

AR2Std | 249

Page 250: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.PushClipRect cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.PopClipRect cnv.DrawText "Clipping region set back to 500,500,3000,3000. The two _ lines (H and V) should be crop to fit in this box.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = Nothing

PushClipRect

Description

Saves the current clipping rectangle. You should call this method before creating a new clipping rectangle using the IntersectClipRect method. When setting a clipping rectangle, any items drawn on the canvas will only show up in the designated clipping region.

Return Type

None

Syntax

Sub PushClipRect()

Parameters

None

Example

Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.DrawText "Clipping regon set to 1000,1000,5000,5000. _ The two lines (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.DrawText "Clipping regon set to 500,500,3000,3000. The two lines _ (H and V) should be crop to fit in this.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = New DDActiveReportsViewer2Ctl.Canvas cnv.IntersectClipRect 1000, 1000, 5000, 5000 cnv.PushClipRect cnv.IntersectClipRect 500, 500, 3000, 3000 cnv.PopClipRect cnv.DrawText "Clipping region set back to 500,500,3000,3000. The two _ lines (H and V) should be crop to fit in this box.", 1500, 1500, 4500, 4500 cnv.DrawLine 0, 1800, cnv.Width, 1800 cnv.DrawLine 1800, 1000, 1800, cnv.Height cnv.DrawLine 1800, 0, 1800, cnv.Height mPages.Insert mPages.Count, cnv Set cnv = Nothing

PushClipRect

AR2Std | 250

Page 251: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Save

Description

Saves the canvas object to the specified file.

Return Type

•None The canvas object will be persisted to the specified file.

Syntax

Sub 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 use cv.Save App.Path & "\InvoiceForm.cnv" End Sub

TextOut

Description

TextOut method prints a text string to the canvas object at the specified coordinates. This method uses the current Canvas font and color settings. The printed string will not be wrapped or clipped.

Note: DrawText should be used instead of TextOut.

Return Type

None

Syntax

Sub TextOut(Text As String, x As Long, y As Long)

Parameters

Example

Dim cv As New Canvas

Save

Name Type Descriptionfilename 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).

AR2Std | 251

Page 252: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

cv.TextOut "Sales Report", 1440, 1000 'Add this page to the pages collection rpt.Pages.Insert rpt.Pages.Count, cv cv.Clear 'Create the second page 'Commit the changes rpt.Pages.Commit

Controls Controls Methods

BarCode Control Properties

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

Description

Add method adds a new control of the specified ProgID to the collection.

Controls

Controls Methods

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

AR2Std | 252

Page 253: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

Control object

Syntax

Function Add(ProgID As String) As Object

Parameters

Settings

Internal controls have the following ProgID names:

Example

Private Sub CreateNewReport() Dim rpt As New rptTemplate Dim ctl As Object ' Create report data source control With rpt.Sections("Detail").Controls Set ctl = .Add("DDActiveReports2.DAODataControl") ctl.Name = "dcRptData" ctl.DatabaseName = App.Path & "\MyDB.mdb" ctl.Recordsource = "SELECT * FROM Customers" ctl.Left = 4 * 1440 ctl.Top = 0 End With ' Create the rest of the controls ' Run the report End Sub

Count

Description

Name Type DescriptionProgID String The ProgID of the control to be added.

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

AR2Std | 253

Page 254: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Count method returns the number of controls in the collection. Return Type

Integer

Syntax

Function Count() As Integer

Parameters

None

Example

Private Sub Detail_BeforePrint() 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

Description

The Item method returns a reference to the control object at the specified index.

Return Type

Section object

Syntax

Function Item(Index As Variant) As Object

Parameters

Remove

Description

The Remove method removes the control at the specified index from the controls collection.

Return Type

None

Item

Name Type DescriptionIndex Variant The index of the control in the collection or

unique name of the control.

Remove

AR2Std | 254

Page 255: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Syntax

Sub Remove(index As Variant)

Parameters

RemoveAll

Description

The RemoveAll method removes all control objects within the section specified.

Return Type

Integer

Syntax

Sub RemoveAll()

Parameters

None

Example

Private Sub ActiveReport_ReportStart() Me.Detail.Controls.RemoveAll End Sub

BarCode Control Properties

Name Type DescriptionIndex Variant The index of the control in the collection or

unique name of the control.

RemoveAll

BarCode Control Properties

Property Data Type DescriptionAlignment 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

AR2Std | 255

Page 256: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Alignment

Description

Sets or returns the position the barcode's readable caption will have relative to the barcode's left, center and right edges.

Data Type

TextAlignment

Settings

Availability

Example

Private Sub ActiveReport_ReportStart() ActiveReport1.Barcode1.Alignment = ddTXCenter End Sub

BackColor

Description

Sets or returns the barcode's background color or fill color.

Data Type

OLE_COLOR

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

Value Mnemonic Description0 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

AR2Std | 256

Page 257: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

' Mark the outstanding sales in red background Private Sub Detail_Format() If fieldID = "1400" then Barcode1.BackColor = vbRed Else Barcode1.BackColor = vbBlue End If End Sub

BarWidth

Description

Sets or returns the width for the Barcode's narrow bars. Setting the width to 0 expands the barcode to fit the control and the width ration is 1 to 15 twips. So setting the BarWidth to 2 with have a value of 30 twips.

Data Type

Integer

Availability

Example

Private Sub ActiveReport_ReportStart() Barcode1.BarWidth = 10 End Sub

Caption

Description

Sets or returns the barcode's caption.

Note: The caption is limited to the specified style's character set symbology. If an unsupported character is used, it will not be displayed.

Data Type

String

Availability

Design time Read / Write Run time Read / Write

BarWidth

Design time Read / Write Run time Read / Write

Caption

AR2Std | 257

Page 258: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub Detail_Format() Barcode1.caption = fldItemName End Sub

CaptionPosition

Description

Sets or returns the type of vertical alignment the barcode's caption will have.

Data Type

BarCodeCaptionPosition

Settings

Availability

Example

Private Sub Detail_Format() Barcode1.Caption = fldItemName Barcode1.CaptionPosition = ddbcCaptionBelow End Sub

DataField

Description

Sets or returns the field from which a bound control will pull its data. When the DataField property is set to a field name contained within the DataSource, ActiveReports binds the field's data from each record to the control. It then loads the field's value into the DataValue property and formats it into the Text property based on the OutputFormat property.

When using XML, the DataField must be set to a valid XPath string.

Note: The base path set by the RecordSetPattern is used as the starting node. So if a control needs to use a higher level node, use "../" to move back a node.

Design time Read / Write Run time Read / Write

CaptionPosition

Value Mnemonic Description0 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

AR2Std | 258

Page 259: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

String

Availability

Example

Private Sub ActiveReport_DataInitialize() Fields.Add "ItemCode" Barcode1.DataField = "ItemCode" End Sub

Direction

Description

Sets or returns the barcode's direction, horizontally or vertically.

Data Type

BarCodeDirection

Settings

Availability

Example

Private Sub Detail_Format() Barcode1.Direction = ddbcTopToBottom End Sub

EnableCheckSum

Design time Read / Write Run time Read / Write

Direction

Value Mnemonic Description0 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

AR2Std | 259

Page 260: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Sets or returns if checksum value is used when rendering barcode. Setting EnableCheckSum to false will only affect codes with checksum values.

Data Type

Boolean

Availability

Example

Private Sub ActiveReport_ReportStart() Barcode1.EnableCheckSum = True Barcode2.EnableCheckSum = False End Sub

Font

Description

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

Data Type

stdFont

Availability

Example

Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor

Design time Read / Write Run time Read / Write

Font

Design time Read / Write Run time Read / Write

ForeColor

AR2Std | 260

Page 261: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

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

Data Type

OLE_COLOR

Availability

Example

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

Style

Description

Sets or returns the type of code, or symbology, the barcode control will use to generate the barcodes.

Data Type

BarCodeStyle

Settings

Design time Read / Write Run time Read / Write

Style

Value Mnemonic Description0 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

AR2Std | 261

Page 262: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

Private Sub ActiveReport_ReportStart() Barcode1.Style = ddbcUPC_A End Sub

Checkbox Properties

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

Checkbox Properties

Property Data Type DescriptionAlignment 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.

AR2Std | 262

Page 263: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Alignment

Description

Alignment property determines where the checkbox caption should be printed relative to the left, center and right edges of the text field area.

Data Type

TextAlignment

Settings

Availability

Example

rptMain.chkPassed.Align = ddTXRight

BackColor

Description

Sets or returns the background color or fill color for the objects.

Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

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

AR2Std | 263

Page 264: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

OLE_COLOR

Availability

Example

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

BackStyle

Description

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

Data Type

BackStyle

Availability

Example

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

Design time Read / Write Run time Read / Write

BackStyle

Design time Read / Write Run time Read / Write

Caption

AR2Std | 264

Page 265: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Caption

Description

Caption property sets or returns the text string to be printed with the checkbox.

Data Type

String

Availability

Example

rptMain.chkPassed.Caption = "Passed"

Font

Description

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

Data Type

stdFont

Availability

Example

Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor

Description

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

Design time Read / Write Run time Read / Write

Font

Design time Read / Write Run time Read / Write

ForeColor

AR2Std | 265

Page 266: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

the font color.

Data Type

OLE_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 font Canvas.ForeColor = vbBlue txtTotal.ForeColor = vbRed Canvas.Font.Name = "Arial" Canvas.Font.Size = 16 Canvas.DrawText "Confidential", 0, 0, 2*1440, 1*1440 End Sub

Style

Description

Sets or returns a style string for the specified field. The style string can be used to override a global style or set a particular style for the specified field.

Note: If an invalid CSS style string is used, the style string will be ignored.

DataType

String

Availability

Example

Private Sub Detail_Format() 'If the balance isPositive is false then the font 'is red and bold. If isPositive is true then the 'font is black and normal If isPositive = False Then txtBalance.Style = "font-family: SimSun; font- weight:bold; text-align: center; color: rgb(255,0,0)" ElseIf isPositive = True Then txtBalance.Style = "font-family: SimSun; font- weight: normal; text-align: center; color: rgb(0,0,0)" End If End Sub

Design time Read / Write Run time Read / Write

Style

Design time Read/Write Run time Read / Write

AR2Std | 266

Page 267: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Value

Description

Value property sets or returns whether the checkbox is checked or not checked.

Data Type

Boolean

Availability

Example

Private Sub Detail_Format() If txtGrade.DataValue > 60 Then chkPassed.Value = 1 End If End Sub

Field Control Properties

Value

Design time Read / Write Run time Read / Write

Field Control Properties

Property Data Type DescriptionAlignment 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.

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.

Font StdFont Sets or returns the font

AR2Std | 267

Page 268: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Alignment

Description

Alignment property determines where the Text value should be printed relative to the left, center and right edges of the text field area.

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

AR2Std | 268

Page 269: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

TextAlignment

Settings

Availability

Example

rptInvestments.fldName.Alignment = ddTXRight

BackColor

Description

Sets or returns the background color or fill color for the objects.

Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

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

Value Mnemonic Description0 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

BackStyle

AR2Std | 269

Page 270: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BackStyle

Description

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

Data Type

BackStyle

Availability

Example

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

CanGrow

Description

CanGrow property determines whether ActiveReports should increase the height of the field based on its value. When set to False, ActiveReports clips the text to fit within the control's predefined height. When set to True, ActiveReports increases the height of the controls and shifts all controls below it to account for the increase in height.

Note: The increase in height might cause the section height to increase. The section's CanGrow property should be set to True to avoid clipping the section.

Data Type

Boolean

Availability

Example

rptInvestments.fldName.CanGrow = True

Design time Read / Write Run time Read / Write

CanGrow

Design time Read / Write Run time Read / Write

AR2Std | 270

Page 271: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

rptInvestments.fldName.CanShrink = False

CanShrink

Description

CanShrink property determines whether ActiveReports should decrease the height of the control based on the value of the field. When set to False, the field will take the exact area defined by its preset coordinates. When set to True, ActiveReports will decrease the height of the field to exactly fit the contents and shift the control below it upward to account for the decrease in height.

Data Type

Boolean

Availability

Example

rptInvestments.fldName.CanGrow = True rptInvestments.fldName.CanShrink = False

ClassName Sets or returns the controls global style. The global styles are specified in the styles drop-down window.

Data Type

String

Availability

Example

Private Sub Detail_Format() fldID.ClassName = "Heading2" End Sub

DataField

Description

Sets or returns the database field a control will pull its data from. When the DataField property is set to a field contained within the DataSource, ActiveReports binds the field's data from each record to the control. The recordset data is first saved into the DataValue property. It then passes through any OutputFormats and

CanShrink

Design time Read / Write Run time Read / Write

ClassName

Design time Read / Write Run time Read / Write

DataField

AR2Std | 271

Page 272: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 expression by stating the property's with an "=". This allows fields to be set up to display calculated results. For example, a field control or a group section's datafield can be set to an expression such as "=UnitPrice * Qty" or "=Trim(CompanyName)" where UnitPrice, Qty and CompanyName are members of the RptFields collection.

Data Type

String

Availability

Example

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

DataValue

Description

DataValue property is populated at runtime with the value of the bound field as retrieved from the data source. You can set the DataValue of calculated fields at runtime. ActiveReports will format the value and place the result in the text property.

Data Type

Variant

Availability

Design time Read / Write Run time Read / Write

DataValue

Run time Read/Write

AR2Std | 272

Page 273: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub ghCountry_BeforePrint() ' Set the datavalue of the calculated field. ' The datavalue will be formatted based on outputFormat ' and the result will be in .text txtPctTotal.DataValue = txtSales.DataValue / _ txtGrandTotal.DataValue End Sub

Font

Description

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

Data Type

stdFont

Availability

Example

Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ForeColor

Description

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

Data Type

OLE_COLOR

Availability

Font

Design time Read / Write Run time Read / Write

ForeColor

Design time Read / Write Run time Read / Write

AR2Std | 273

Page 274: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

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

hyperLink

Description

Sets or returns a hyperlink for a field. Once a hyperlink is set, users can follow the specified link by clicking on the field at run time.

Note: The hyperlink can link to TOC entries, other reports, and any other properly formatted HTML links.

DataType

String

Availability

Example

Private Sub Detail_Format() fldLink.hyperLink = "www.datadynamics.com" fldLink.Text = "fldLink's Hyperlink is: " & _ fldLink.hyperLink End Sub

Multiline

Description

Determines whether the contents of the field should wrap across multiple lines. When set to False, the field text is limited to a single line regardless of the height or CanGrow properties.

Data Type

Boolean

Availability

hyperLink

Design time Read / Write Run time Read / Write

Multiline

Design time Read / Write Run time Read / Write

AR2Std | 274

Page 275: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

RptInvestments.fldName.MultiLine = True rptInvestments.fldName.CanGrow = True rptInvestments.fldName.CanShrink = False

OutputFormat

Description

OutputFormat sets or returns the mask string used to format the DataValue into the Text property. It uses the Visual Basic Format function settings.

Data Type

String

Availability

Example

rptInvestments.fldName.OutputFormat = "$###0.00"

Style

Description

Sets or returns a style string for the specified field. The style string can be used to override a global style or set a particular style for the specified field.

Note: If an invalid CSS style string is used, the style string will be ignored.

DataType

String

Availability

Example

Private Sub Detail_Format() 'If the balance isPositive is flse then the font 'is red and bold. If isPositive is true then the 'font is black and normal If isPositive = False Then txtBalance.Style = "font-family: SimSun; font- weight:bold; text-align: center; color:

OutputFormat

Design time Read / Write Run time Read / Write

Style

Design time Read/Write Run time Read / Write

AR2Std | 275

Page 276: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

rgb(255,0,0)" ElseIf isPositive = True Then txtBalance.Style = "font-family: SimSun; font- weight: normal; text-align: center; color: rgb(0,0,0)" End If End Sub

SummaryDistinctField

Description

SummaryDistinctField property sets or returns the name of the field used in a distinct summary function. The summary function will process DataField values based on the distinct value of this field.

Note: This property is used only when the SummaryFunc value is one of Distinct Summary Functions. When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type

String

Availability

SummaryDistinctValue

Description

SummaryDistinctValue allows processing distinct summary function where the distinct value is unbound. You can set the property for each record at run-time. The changes in the value will decide how the summarized data will be calculated.

Note: When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type

String

Availability

SummaryFunc

Description

Sets the type of the summary function used to process the DataField values. You can use this function to create sub totals, grand totals and other summary values.

SummaryDistinctField

Design time Read / Write Run time Read / Write

SummaryDistinctValue

Design time Read / Write Run time Read / Write

SummaryFunc

AR2Std | 276

Page 277: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Note: When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type

SummaryFunctions

Settings

Availability

Value Mnemonic Description0 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).

Design time Read / Write Run time Read / Write

SummaryGroup

AR2Std | 277

Page 278: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SummaryGroup

Description

SummaryGroup property sets or returns the name of the group header section that will reset the summarized field value. For example, setting a sum of price for an order group header, will reset the sum to zero for each order group. This property is valid when the SummaryType is set to 3-SubTotal.

Note: When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type

String

Availability

SummaryRunning

Description

SummaryRunning determines whether the summarization will be accumulated or reset for each level (detail, group or page). Setting this property ddSRGroup or ddSRAll will make ActiveReports print a running summary of the field at the group or report level.

Note: When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type

SummaryRunningType

Settings

Availability

SummaryType

Description

SummaryType determines the type of summarization on the field if any. ActiveReports can summarize the field as:

Design time Read / Write Run time Read / Write

SummaryRunning

Value Mnemonic Description0 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

AR2Std | 278

Page 279: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sub total (group level; reset for each group),

Grand total (report level; do not reset until all records are processed),

Page total (page level; reset for each page),

Or a page count, which is the total number of pages printed.

Note: If the summarized field is placed ahead of it summary level, (for example, placing a page total in the page header or a report grand total in the report header), the containing section and the following sections will not be printed until the summary value is resolved (calculated). When using the summary functions with a field, the CanGrow and CanShrink properties are disabled for the field.

Data Type

SummaryType

Settings

Availability

Text

Description

Sets or returns the text string to be displayed in the field.

Data Type

String

Availability

Example

Private Sub Detail_Format() If fldItem.Text = "" then fldItem.Text = "None" End If End Sub

Value Mnemonic Description0 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.

Design time Read / Write Run time Read / Write

Text

Design time Read / Write Run time Read / Write

AR2Std | 279

Page 280: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

VerticalAlignment

Description

VerticalAlignment property determines where the Text value should be printed relative to the top, middle and bottom edges of the text field area.

Data Type

VerticalTextAlignment

Settings

Availability

Example

rptRPW.fldArable.VerticalAlignment = ddTXMiddle

WordWrap

Description

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 caption is longer than the label, setting WordWrap to false will truncate the caption at the end of the label instead of the truncating the caption after the last full word.

Note: When setting WordWrap to true, Multiline must also be set to true. Setting WordWrap to false will negate the Multiline property.

DataType

Boolean

Availability

Example

VerticalAlignment

Value Mnemonic Description0 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 Run time Read / Write

WordWrap

Design time Read/Write Run time Read / Write

AR2Std | 280

Page 281: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub Detail_Format() Field1.WordWrap = False End Sub

ZOrder

Description

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

Return Type

None

Syntax

Sub Zorder(Position As Integer)

Parameters

Settings

Example

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

ZOrder

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

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

AR2Std | 281

Page 282: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Frames and Panes Frame Control Properties

Panes

Frame Control Properties

BackColor

Description

Sets or returns the background color or fill color of the objects.

Note: The BackColor property is effective only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

' Mark the outstanding sales in red background

Frames and Panes

Frame Control Properties

Property Data Type DescriptionBackColor 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

Design time Read/Write Run time Read / Write

AR2Std | 282

Page 283: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub Detail_Format() If frameMain.panes.count > 3 then frameMain.BackColor = vbRed Else frameMain.BackStyle = ddBKTransparent End If End Sub

CanGrow

Description

CanGrow property determines whether ActiveReports should increase the height of the frame based on its value. When set to False, ActiveReports clips the frame to fit within the control's predefined height. When set to True, ActiveReports increases the height of the controls and shift all controls below it to account for the increase in height.

Note: The increase in height might cause the section height to increase. The section's CanGrow property should be set to True to avoid clipping the section.

Data Type

Boolean

Availability

Example

Private Sub ActiveReport_ReportStart() frameMain.CanGrow = False frameMain.CanShrink = False End Sub

CanShrink

Description

CanShrink property determines whether ActiveReports should decrease the height of the control based on the frame's content. When set to False, the frame will take the exact area defined by its preset coordinates. When set to True, ActiveReports will decrease the height of the frame to exactly fit the contents and shift the control below it upward to account for the decrease in height.

Data Type

Boolean

Availability

CanGrow

Design time Read / Write Run time Read / Write

CanShrink

Design time Read / Write Run time Read / Write

AR2Std | 283

Page 284: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub ActiveReport_ReportStart() frameMain.CanGrow = False frameMain.CanShrink = False End Sub

CloseBorder

Description

Set or returns whether or not the bottom border line will be displayed if the frame spans across multiple pages.

Data Type

Boolean

Availability

Example

FrameMain.CloseBorder = False

Panes

Description

Returns a collection of the panes displayed on the frame.

Data Type

Panes

Availability

Example

Private Sub Detail_Format() FrameMain.Panes(0).BackColor = vbRed FrameMain.Panes(0).BackStyle = 1 End Sub

ZOrder

CloseBorder

Design time Read / Write Run time Read / Write

Panes

Run time Read / Write

ZOrder

AR2Std | 284

Page 285: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

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

Return Type

None

Syntax

Sub Zorder(Position As Integer)

Parameters

Settings

Example

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

Panes Pane Properties

Pane Methods

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

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

Panes

AR2Std | 285

Page 286: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Pane Properties

BackColor

Description

Sets or returns the background color or fill color of the objects.

Note: The BackColor property is effective only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

Private Sub Detail_Format() fAuto.Panes(0).BackColor = vbYellow fAuto.Panes(0).BackStyle = ddBKNormal End Sub

BackStyle

Description

Sets or returns whether the pane is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the transparent areas of the new objects. The line in the illustration below is behind both objects. It shows through the transparent object, but the normal object overlays it.

Pane Properties

Property Data Type DescriptionBackColor 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

AR2Std | 286

Page 287: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

BackStyle

Availability

Example

Private Sub Detail_Format() fAuto.Panes(0).BackColor = vbYellow fAuto.Panes(0).BackStyle = ddBKNormal End Sub

Border

Description

Set or returns the pane's border settings.

Data Type

Border

Availability

Example

Private Sub Detail_Format() fAuto.Panes(0).Border.BottomColor = vbRed fAuto.Panes(0).Border.BottomStyle = ddBLExtraThickSolid fAuto.Panes(0).Border.RightColor = vbRed fAuto.Panes(0).Border.RightStyle = ddBLThickSolid fAuto.Panes(0).Border.TopColor = vbBlue fAuto.Panes(0).Border.TopStyle = ddBLExtraThickSolid fAuto.Panes(0).Border.LeftColor = vbBlue fAuto.Panes(0).Border.LeftStyle = ddBLSolid fAuto.Panes(0).Border.Shadow = True End Sub

CloseBorder

Design time N/A Run time Read / Write

Border

Design time N/A Run time Read-Only

CloseBorder

AR2Std | 287

Page 288: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Set or returns whether or not the bottom border line will be displayed if the pane spans across multiple pages.

Data Type

Boolean

Availability

Example

Private Sub ActiveReport_ReportStart() FrameMain.CloseBorder = False FrameMain.Panes(0).CloseBorder = False End Sub

Controls

Description

Returns a collection of controls on the pane

Data Type

PaneControls

Availability

Pane Methods

Design time N/A Run time Read / Write

Controls

Design time N/A Run time Read / Write

Pane Methods

Method DescriptionAdd 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)

AR2Std | 288

Page 289: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Add

Description

Adds a new pane to the panes collection.

Return Type

None

Syntax

Sub 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

Description

Returns the number of panes in the collection.

Return Type

Integer

Syntax

Function Count() As Integer

Parameters

None

Example

Add

Name Type DescriptionParentName String The parent pane's name. Split SplitTypes Indicates the type of split to use NewPaneName String Name for the new pane

Value Mnemonic Description0 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

AR2Std | 289

Page 290: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

If FrameM.Panes.Count < 3 Then FrameM.Panes.Add "Pane0", ddRightSplit, "Pane" & _ FrameM.Panes.Count End If

Item

Description

Returns a reference to the pane object at the specified index.

Return Type

Pane

Syntax

Function Item(Index As Integer) As Pane

Parameters

Example

Private Sub Detail_Format() FrameMain.Panes.Item(0).BackColor = vbRed FrameMain.Panes.Item(0).BackStyle = ddBKNormal End Sub

Remove

Description

Removes a pane's object with the specified index.Return Type

None

Syntax

Sub Remove(Index)

Parameters

Example

If Ingredients = "" Then FrameMain.Panes.Remove 0 End If

Item

Name Type DescriptionIndex Integer Index of the pane to return

Remove

Name Type DescriptionIndex Integer Index of the pane to remove

AR2Std | 290

Page 291: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Image Properties

BackColor

Description

Sets or returns the background color or fill color for the objects.

Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

' Highlight the outstanding sales with a red background

Image Properties

Property Data Type DescriptionBackColor 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

Design time Read / Write Run time Read / Write

AR2Std | 291

Page 292: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub Detail_Format() If txtSales.DataValue > 10000 Then txtSales.BackStyle = ddBKNormal txtSales.BackColor = vbRed Else txtSales.BackStyle = ddBKTransparent End If End Sub

BackStyle

Description

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

Data Type

BackStyle

Availability

Example

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

ForeColor

Description

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

Data Type

OLE_COLOR

Availability

BackStyle

Design time Read / Write Run time Read / Write

ForeColor

Design time Read / Write

AR2Std | 292

Page 293: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

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

hyperLink

Description

Sets or returns a hyperlink for the image. Once a hyperlink is set, users can follow the specified link by clicking on the image at run time.

Note: The hyperlink can link to TOC entries, other reports, and any other properly formatted HTML links.

DataType

String

Availability

Example

Private Sub Detail_Format() Image1.Picture = _ LoadPicture(app.path & "\Logo.jpg") Image1.Hyperlink = _ "www.datadynamics.com" End Sub

LineColor

Description

LineColor property sets or returns the pen color used to draw the shape's border.

Data Type

OLE_COLOR

Availability

Run time Read / Write

hyperLink

Design time Read / Write Run time Read / Write

LineColor

Design time Read / Write Run time Read / Write

AR2Std | 293

Page 294: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

rptShows.imgPoster.LineWeight = 2 rptShows.imgPoster.LineStyle = ddLSSolid rptShows.imgPoster.LineColor = vbRed

LineStyle

Description

LineStyle property sets or returns the pen style used to draw the shape's border.

Data Type

LineStyle

Settings

Availability

Example

rptShows.imgPoster.LineWeight = 2 rptShows.imgPoster.LineStyle = ddLSSolid rptShows.imgPoster.LineColor = vbRed

LineWeight

Description

LineWeight property sets or returns the width of the image's border in line weight units (1lw=10 twips).

Data Type

Integer

Availability

LineStyle

Value Mnemonic Description0 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

AR2Std | 294

Page 295: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

rptShows.imgPoster.LineWeight = 2 rptShows.imgPoster.LineStyle = ddLSSolid rptShows.imgPoster.LineColor = vbRed

Picture

Description

Picture property sets or return a picture handle displayed in the image control.

Data Type

StdPicture

Availability

Example

rptShows.imgPoster.Picture = LoadPicture(app.path &"\Posters\LesMis.jpg")

PictureAlignment

Description

PictureAlignment property determines how the picture is displayed within the image drawing area.

Data Type

PictureAlignment

Settings

Availability

Picture

Design time Read / Write Run time Read / Write

PictureAlignment

Value Mnemonic Description0 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

AR2Std | 295

Page 296: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

rptShows.imgPoster.PictureAlignment = ddPACenter

SizeMode

Description

SizeMode property determines how the picture is sized to fit within the image area.

Data Type

SizeMode

Settings

Availability

Example

RptShows.imgPoster.SizeMode = ddSMZoom

ZOrder

Description

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

Return Type

None

Syntax

Sub Zorder(Position As Integer)

Parameters

Run time Read / Write

SizeMode

Value Mnemonic Description0 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

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

AR2Std | 296

Page 297: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Settings

Example

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

Label Control Properties

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

Label Control Properties

Property Data Type DescriptionAlignment 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

AR2Std | 297

Page 298: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Alignment

Description

Alignment property determines where the caption should be printed relative to the left, center and right edges of the label area.

Data Type

TextAlignment

Settings

Availability

Example

rptInvestments.lblName.Alignment = ddTXRight

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 controls. Changing the control's ZOrder allows controls to be positioned behind or in front of other controls.

Alignment

Value Mnemonic Description0 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

AR2Std | 298

Page 299: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Angle

Description

Angle property sets or returns the angle (slope) of the printed value (1 = 1/10 degree).

Data Type

Integer

Availability

Example

rptInvestments.lblIndex.Angle = 900

BackColor

Description

Sets or returns the background color or fill color for the objects.

Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

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

Design time Read / Write Run time Read / Write

BackColor

Design time Read / Write Run time Read / Write

BackStyle

AR2Std | 299

Page 300: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BackStyle

Description

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

Data Type

BackStyle

Availability

Example

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

Caption

Description

Sets or returns the text string to be printed.

Data Type

String

Availability

Example

Private Sub PageFooter_Format() If Not dcRptData.Recordset.EOF Then lblContinued.Caption = "Continued" Else

Design time Read / Write Run time Read / Write

Caption

Design time Read / Write Run time Read / Write

AR2Std | 300

Page 301: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

lblContinued.Caption = "" End If End Sub

ClassName Sets or returns the controls global style. The global styles are specified in the styles dropdown window.

Data Type

String

Availability

Example

Private Sub Detail_Format() lblID.ClassName = "Heading2" End Sub

Font

Description

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

Data Type

stdFont

Availability

Example

Private Sub Detail_Format() ' Set sales figures > $10000 to bold underline If txtSales.DataValue > 10000 Then txtSales.Font.Bold = True txtSales.Font.Underline = True Else txtSales.Font.Bold = False txtSales.Font.Underline = False End If End Sub

ClassName

Design time Read / Write Run time Read / Write

Font

Design time Read / Write Run time Read / Write

AR2Std | 301

Page 302: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ForeColor

Description

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

Data Type

OLE_COLOR

Availability

Example

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

hyperLink

Description

Sets or returns a hyperlink for the label. Once a hyperlink is set, users can follow the specified link by clicking on the label at run-time.

Note: The hyperlink can link to TOC entries, other reports, and any other properly formatted HTML links.

DataType

String

Availability

Example

Private Sub Detail_Format() lblLink.hyperLink = _ "ftp.datadynamics.com/activereports/samples" lblLink.Caption = "lblLink's Hyperlink is: " & _ lblLink.hyperLink End Sub

ForeColor

Design time Read / Write Run time Read / Write

hyperLink

Design time Read / Write Run time Read / Write

AR2Std | 302

Page 303: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Multiline

Description

Determines whether the contents of the label should wrap across multiple lines. When set to False, the label caption is limited to a single line regardless of its height.

Data Type

Boolean

Availability

Example

rptInvestments.lblDescription.MultiLine = True

Style

Description

Sets or returns a style string for the specified label. The style string can be used to override a global style or set a particular style for the specified label.

Note: If an invalid CSS style strings is used, the style string will be ignored.

DataType

String

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 normal If isPositive = False Then lblBalance.Style = "font-family: SimSun; font- weight:bold; text-align: center; color: rgb(255,0,0)" ElseIf isPositive = True Then lblBalance.Style = "font-family: SimSun; font- weight: normal; text-align: center; color: rgb(0,0,0)" End If End Sub

Multiline

Design time Read / Write Run time Read / Write

Style

Design time Read / Write Run time Read / Write

AR2Std | 303

Page 304: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

VerticalAlignment

Description

VerticalAlignment property determines where the caption should be printed relative to the top, middle and bottom edges of the label area.

Data Type

VerticalTextAlignment

Settings

Availability

Example

rptPets.lblType.VerticalAlignment = ddTXBottom

WordWrap

Description

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 caption is longer than the label, setting WordWrap to false will truncate the caption at the end of the label instead of the truncating the caption after the last full word.

Note: When setting WordWrap to true, Multiline must also be set to true. Setting WordWrap to false will negate the Multiline property.

DataType

Boolean

Availability

Example

VerticalAlignment

Value Mnemonic Description0 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

Design time Read/Write Run time Read / Write

AR2Std | 304

Page 305: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub Detail_Format() Label1.WordWrap = False End Sub

ZOrder

Description

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

Return Type

None

Syntax

Sub Zorder(Position As Integer)

Parameters

Settings

Example

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

ZOrder

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

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

AR2Std | 305

Page 306: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Line Properties

LineColor

Description

LineColor property sets or returns the pen color used to draw the line.

Data Type

OLE_COLOR

Availability

Example

rptBooks.lnLeft.LineColor = vbYellow rptBooks.lnLeft.LineStyle = ddLSDot

LineStyle

Description

LineStyle property sets or returns the pen style used to draw the line.

Data Type

LineStyle

Line Properties

Property Data Type DescriptionLineColor 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 Run time Read / Write

LineStyle

AR2Std | 306

Page 307: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Settings

Availability

Example

rptBooks.lnLeft.LineColor = vbYellow rptBooks.lnLeft.LineStyle = ddLSDot rptBooks.lnLeft.LineWeight = 3

LineWeight

Description

LineWeight property sets or returns the width of the line in line weight units (1lw=10 twips).

Data Type

Integer

Availability

Example

rptBooks.lnLeft.LineColor = vbYellow rptBooks.lnLeft.LineStyle = ddLSDot rptBooks.lnLeft.LineWeight = 3

X1

Description

Sets or returns the horizontal coordinate of the line's starting point. The coordinates are relative to the section's top-left corner.

Value Mnemonic Description0 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

X1

AR2Std | 307

Page 308: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

Single

Availability

Example

Private Sub Detail_Format() rptBooks.lnHz.X1 = 0 rptBooks.lnHz.X2 = Me.PrintWidth rptBooks.lnHz.Y1 = 500 rptBooks.lnHz.Y2 = 500 End Sub

X2

Description

Sets or returns the horizontal coordinate of the line's ending point. The coordinates are relative to the section's top-left corner.

Data Type

Single

Availability

Example

Private Sub Detail_Format() rptBooks.lnHz.X1 = 0 rptBooks.lnHz.X2 = Me.PrintWidth rptBooks.lnHz.Y1 = 500 rptBooks.lnHz.Y2 = 500 End Sub

Y1

Description

Sets or returns the vertical coordinate of the line's starting point. The coordinates are relative to the section's top-left corner.

Data Type

Design time Read / Write Run time Read / Write

X2

Design time Read / Write Run time Read / Write

Y1

AR2Std | 308

Page 309: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Single

Availability

Example

Private Sub Detail_Format() rptBooks.lnHz.X1 = 0 rptBooks.lnHz.X2 = Me.PrintWidth rptBooks.lnHz.Y1 = 500 rptBooks.lnHz.Y2 = 500 End Sub

Y2

Description

Sets or returns the vertical coordinate of the line's ending point. The coordinates are relative to the section's top-left corner.

Data Type

Single

Availability

Example

Private Sub Detail_Format() rptBooks.lnHz.X1 = 0 rptBooks.lnHz.X2 = Me.PrintWidth rptBooks.lnHz.Y1 = 500 rptBooks.lnHz.Y2 = 500 End Sub

ZOrder

Description

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

Return Type

None

Design time Read / Write Run time Read / Write

Y2

Design time Read / Write Run time Read / Write

ZOrder

AR2Std | 309

Page 310: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Syntax

Sub Zorder(Position As Integer)

Parameters

Settings

Example

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

OLE OLE Object Properties

OLE Object Methods

OLE Object Properties

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

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

OLE Object Properties

Property Data Type DescriptionBackColor OLE_COLOR Sets or returns the background color of the

AR2Std | 310

Page 311: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BackColor

Description

Sets or returns the background color or fill color for the objects.

Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

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

BackStyle

Description

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

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

Design time Read / Write Run time Read / Write

BackStyle

AR2Std | 311

Page 312: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

normal object.

Data Type

BackStyle

Availability

Example

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

Class

Description

Class property sets or returns the ProgID of the OLE object.

Data Type

String

Availability

Example

OLE1.Class = "Word.Document.8"

Object

Description

Object property returns a reference to the OLE object instance that is bound to the control. You can use this property to set the object's properties or call its methods.

Data Type

Object

Design time Read / Write Run time Read / Write

Class

Design time Read / Write Run time Read / Write

Object

AR2Std | 312

Page 313: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

Private Sub ActiveReport_ReportStart() lblCaption.Caption = OLE1.object.Name End Sub

PictureAlignment

Description

Sets or returns the type of positioning the OLE's object will have inside the OLE container.

Note: If the object is the same size as the container, the PictureAlignment will be ignored.

Data Type

PictureAlignment

Settings

Availability

Example

Private Sub ActiveReport_ReportStart() 'Centers the OLE object OLE1.PictureAlignment = ddPACenter ' Stretch the OLE object to fill the entire container OLE1.SizeMode = ddSMStretch End Sub

SizeMode

Description

Determines how the OLE object will be sized inside the OLE container.

Data Type

SizeMode

Run time Read

PictureAlignment

Value Mnemonic Description0 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

AR2Std | 313

Page 314: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Settings

Availability

Example

Private Sub ActiveReport_ReportStart() 'Centers the OLE object OLE1.PictureAlignment = ddPACenter 'Stretch the OLE object to fill the entire container OLE1.SizeMode = ddSMStretch End Sub

VerbCount

Description

Populates the verbs array and returns a verb count available for the OLE object. VerbCount must be called before accessing the other GetVerb methods.

Data Type

Long

Availability

Example

Private Sub CheckVerbs() Dim sVName As String Dim vCnt, i OLE1.CreateEmbedded "c:\test.rtf" vCnt = OLE1.VerbCount For i = 0 To vCnt - 1 OLE1.GetVerbName i, sVName Debug.Print "VerbName = " & sVName Debug.Print "VerbID = " & OLE1.GetVerbID(i) Next OLE1.DoVerb 0 End Sub

Value Mnemonic Description0 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

AR2Std | 314

Page 315: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ZOrder

Description

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

Return Type

None

Syntax

Sub Zorder(Position As Integer)

Parameters

Settings

Example

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

OLE Object Methods

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

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

AR2Std | 315

Page 316: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

CreateEmbedded

Description

Created an embedded OLE object from a source document.

Syntax

Sub CreateEmbedded(FileName As String)

Parameters

Remarks

To create the new OLE type object, the program associated with the class name must be correctly installed and registered with the operating system. For instance, you can not create the word.document if the operating system does not recognize the class type because it is not found in the registry.

Example

Private Sub ActiveReport_ReportStart() ' OLE1 is an existing OLE control in the report OLE1.Class = "Word.Document.8" OLE1.CreateEmbedded App.Path & "\TestDocument.Doc" End Sub

DoVerb

Description

Opens an OLE object so an operation, such as edit or replace, can be performed.

Syntax

Sub DoVerb(ID As Long)

Parameters

Method DescriptionCreateEmbedded 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 GetUserType(Type As Integer) As StringGetVerbID 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 DescriptionFileName String The name of the source document used as a

template to create the embedded object.

DoVerb

AR2Std | 316

Page 317: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub CheckVerbs() Dim sVName As String Dim vCnt, i> OLE1.CreateEmbedded "c:\test.rtf" vCnt = OLE1.VerbCount For i = 0 To vCnt - 1 OLE1.GetVerbName i, sVName Debug.Print "VerbName = " & sVName Debug.Print "VerbID = " & OLE1.GetVerbID(i) Next OLE1.DoVerb 0 End Sub

GetUserType

Description

Returns the name of the specified OLE object's user type.

Syntax

Sub GetUserType(Type As Integer)As String

Parameters

GetVerbID

Description

Returns the ID for the specified verb.

Note: VerbCount must be called before using GetVerbID.

Syntax

Function GetVerbID(Index As Long) As Long

Parameters

Example

Private Sub CheckVerbs()

Name Type DescriptionID Long The ID number for the verb to activate

GetUserType

Name Type DescriptionType Integer Integer value specifying the type to return the

name for.

GetVerbID

Name Type DescriptionIndex Long Integer value indicating the index number of

the verb.

AR2Std | 317

Page 318: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Dim sVName As String Dim vCnt, i OLE1.CreateEmbedded "c:\test.rtf" vCnt = OLE1.VerbCount For i = 0 To vCnt - 1 OLE1.GetVerbName i, sVName Debug.Print "VerbName = " & sVName Debug.Print "VerbID = " & OLE1.GetVerbID(i) Next OLE1.DoVerb 0 End Sub

GetVerbName

Description

Returns the name of the specified verb.

Note: VerbCount must be called before using GetVerbName.

Syntax

Sub GetVerbName(Index As Long, Name As String)

Parameters

Example

Private Sub CheckVerbs() Dim sVName As String Dim vCnt, i OLE1.CreateEmbedded "c:\test.rtf" vCnt = OLE1.VerbCount For i = 0 To vCnt - 1 OLE1.GetVerbName i, sVName Debug.Print "VerbName = " & sVName Debug.Print "VerbID = " & OLE1.GetVerbID(i) Next OLE1.DoVerb 0 End Sub

InsertObject

Description

Inserts an object into the OLE control.

Syntax

Sub InsertOjbect()

GetVerbName

Name Type DescriptionIndex Long Integer value indicating the index number of

the verb. Name String String value indicating the name of the verb.

InsertObject

PageBreak Control Properties

AR2Std | 318

Page 319: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

PageBreak Control Properties

Enabled

Description

Sets or returns whether or not the PageBreak control will be activated on the current page.

DataType

Boolean

Availability

Example

Private Sub PageHeader_Format() Static x As Long x = x + 1 'Disables the page break for all but the first page If x > 1 Then Me.PageBreak1.Enabled = False End If End Sub

RTF RTF Text Control Properties

RTF Text Control Methods

RTF Text Control Properties

Property Data Type DescriptionEnabled 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 DescriptionBackStyle 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

AR2Std | 319

Page 320: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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

AR2Std | 320

Page 321: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BackStyle

Description

Determines whether the control is rendered in transparent (opaque) or normal mode. Transparent mode allows previously drawn objects to show through the transparent areas of the new objects. The line in the illustration below is behind both objects. It shows through the transparent object, but the normal object overlays it.

Data Type

BackStyle

Availability

Example

' Sets the Richedit background to red Private Sub Detail_Format() If setColor = true then RichEdit1.BackStyle = ddBKNormal RichEdit1.BackColor = vbRed Else RichEdit1.BackStyle = ddBKTransparent End If End Sub

BulletIndent

Description

Returns or sets the amount of indent used in a RichEdit control when SelBullet is set to True.

Data Type

Integer

Availability

control's ZOrder allows controls to be positioned behind or in front of other controls.

BackStyle

Design time Read/Write Run time Read / Write

BulletIndent

Design time Read / Write Run time Read / Write

AR2Std | 321

Page 322: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

CanGrow

Description

Determines whether the rich edit print area grows as needed to contain the text. When the control grows, the controls directly below it will be pushed downwards.

Data Type

Boolean

Availability

Example

Me.rtfRecalls.CanGrow = False Me.rtfEcalls.CanShrink = False

CanShrink

Description

Determines whether the rich edit print area shrinks to fit the contents of the RichEdit control.

Data Type

Boolean

Availability

Example

Me.rtfRecalls.CanGrow = False Me.rtfEcalls.CanShrink = False

GetTab

Description

GetTab property returns the tab position setting at the specified index.

Data Type

CanGrow

Design time Read / Write Run time Read / Write

CanShrink

Design time Read / Write Run time Read / Write

GetTab

AR2Std | 322

Page 323: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Long

Availability

MaxLength

Description

Specifies the maximum number of characters a user can enter in the control. The default for MaxLength is 0, indicating that the text is limited only by available system resources. Any number greater than 0 indicates the maximum number of characters.

Data Type

Long

Availability

Example

' Set the RTF MaxLength and Load the letter txtLetter.MaxLength = 2000 txtLetter.Text = _ dcRptData.RecordSet.Fields("LetterText").Value

Multiline

Description

Determines whether the RichEdit prints multiple lines or single line. When set to False the control is limited to single lines.

Data Type

Boolean

Availability

Example

rtfLetter.Multiline = True

Design time N/A Run time Read-Only

MaxLength

Design time Read / Write Run time Read / Write

Multiline

Design time Read / Write Run time Read / Write

SelAlignment

AR2Std | 323

Page 324: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SelAlignment

Description

Returns or sets the selected text alignment. A value of 3 (rtfAlignmentNone) indicates that the selection spans paragraphs with different alignment settings.

Data Type

SelAlignmentConstantsselAlignmentConstants

Availability

Example

rtfLetter.SelAlignment = rtfLeft

SelBold

Description

Sets or returns the font bold style of the currently selected text. A null value indicates that the current selection has mixed bold styles.

Data Type

Variant

Availability

Example

rtfLetter.SelBold = True

SelBullet

Description

Sets or returns a value that specified whether the selected text has a bullet list style. A value of null indicates that the selection spans over text that has mixed bullet styles.

Data Type

Value Mnemonic Description0 rtfLeft Align left 1 rtfRight Align right 2 rtfCenter Align center 3 rtfAlignmentNone None

Design time N/A Run time Read / Write

SelBold

Design time N/A Run time Read / Write

SelBullet

AR2Std | 324

Page 325: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Variant

Availability

Example

rtfLetter.SelText = "Unit Price" & vbCRLF & "Cost" rtfLetter.SelBullet = True

SelCharOffset

Description

Sets or returns a value that specifies the offset of characters from the baseline:

A positive integer prints the selected text as superscript above the baseline;

A negative integer prints the text as subscript below the baseline;

0 value prints selected text on the baseline (normal)

A Null value indicates mixed character offset setting within the selection.

Data Type

Variant

Availability

Example

rtfLetter.SelText = "TM" rtfLetter.SelCharOffset = 10

SelColor

Description

Sets or returns a value indicating the text ForeColor of the current selection. You can use RGB values or system color values. Returns Null if the selection ForeColor is mixed.

Data Type

Variant

Availability

Design time N/A Run time Read / Write

SelCharOffset

Design time N/A Run time Read / Write

SelColor

Run time Read / Write

AR2Std | 325

Page 326: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

rtfLetter.SelColor = vbRed rtfLetter.SelText = "$2000.00" rtfLetter.SelColor = vbBlack

SelFontName

Description

Sets or returns the font used to print the current text selection. Returns Null if the selection font is mixed.

Data Type

Variant

Availability

Example

rtfLetter.SelFontName = "Arial" rtfLetter.SelFontSize = 10 rtfLetter.SelBold = True

SelFontSize

Description

Sets or returns an integer value specifying the font size of the current selection. Returns NULL if the selection contains mixed font sizes.

The units are in Twips (1pt=20 Twips).

Data Type

Variant

Availability

Example

rtfLetter.SelFontName = "Arial" rtfLetter.SelFontSize = 10 * 20 ' 10 pts rtfLetter.SelBold = True

SelFontName

Run time Read / Write

SelFontSize

Run time Read / Write

SelHangingIndent

AR2Std | 326

Page 327: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

SelHangingIndent

Description

Sets or returns the distance between the left margin of the first line in the selected paragraph and the left margin indent of the following lines.

Data Type

Long

Availability

Example

rtfLetter.SelIndent = 720 ' ½ inch in twips rtfLetter.SelHangingIndent = 1440 ' 1 inch in twips rtfLetter.SelRightIndent = 720

SelIndent

Description

Sets or returns the left margin of the selected paragraph.

Data Type

Long

Availability

Example

rtfLetter.SelIndent = 720 ' ½ inch in twips rtfLetter.SelHangingIndent = 1440 ' 1 inch in twips rtfLetter.SelRightIndent = 720

SelItalic

Description

Sets or returns the font Italic style of the currently selected text. A null value indicates that the current selection has mixed italic styles.

Data Type

Variant

Run time Read / Write

SelIndent

Run time Read / Write

SelItalic

AR2Std | 327

Page 328: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

rtfLetter.SelItalic = True

SelLength

Description

Sets or returns the length (number of characters) of the current selection.

Data Type

Positive Long or 0

Availability

Example

rtfLetter.SelStart = 10 rtfLetter.SelLength = Len(sMsg) rtfLetter.SelBold = True

SelProtected

Description

Determines whether the characters in the current selection are protected (cannot be modified by the end user). A Null value indicated mixed protection settings within the selection.

Data Type

Variant

Availability

Example

rtfLetter.SelLength = Len(sComapnyname) rtfLetter.SelProtected = True

SelRightIndent

Run time Read / Write

SelLength

Run time Read / Write

SelProtected

Run time Read / Write

SelRightIndent

AR2Std | 328

Page 329: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Sets or returns the distance from the right edge of the rich edit control and the right edge of the selected text.

Data Type

Long

Availability

Example

rtfLetter.SelIndent = 720 ' ½ inch in twips rtfLetter.SelHangingIndent = 1440 ' 1 inch in twips rtfLetter.SelRightIndent = 720

SelStart

Description

Sets or returns the beginning position of the current selection or the insertion point. Valid values are 0 to the length of text in the control.

Data Type

Long

Availability

Example

rtfLetter.SelStart = 10 rtfLetter.SelLength = Len(sMsg) rtfLetter.SelBold = True

SelStrikeThru

Description

Sets or returns the font strikethru style of the currently selected text. A Null value indicates that the current selection has mixed strikethru styles.

Data Type

Variant

Design time N/A Run time Read / Write

SelStart

Design time N/A Run time Read / Write

SelStrikeThru

AR2Std | 329

Page 330: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

rtfLetter.SelStrikeThru = True

SelTabCount

Description

Returns the number of tab stops within the current selection.

Data Type

Long

Availability

SelTabs

Description

Returns the absolute tab position at the specified index.

Data Type

Integer

Availability

Example

Dim arrTabs(5) As Integer arrTabs(0) = 5 arrTabs(1) = 10 arrTabs(2) = 15 arrTabs(3) = 20 arrTabs(4) = 25 arrTabs(5) = 30 rtfLetter.SelTabs = arrTabs

SelText

Description

Design time N/A Run time Read / Write

SelTabCount

Run time Read / Write

SelTabs

Run time Read / Write

SelText

AR2Std | 330

Page 331: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sets or returns the string of the current selected text. Returns an empty string if no text is selected.

Data Type

String

Availability

Example

rtfLetter.SelColor = vbRed rtfLetter.SelText = "$2000.00" rtfLetter.SelColor = vbBlack

SelTextBackColor

Description

Sets or returns the background color of the selected text. Returns Null when the selection background color is mixed.

Data Type

Variant

Availability

Example

rtf.SetTextBackcolor = vbRed rtf.SelText = "ActiveReports"

SelUnderline

Description

Sets or returns the font underline style of the currently selected text. A Null value indicates that the current selection has mixed underline styles.

Data Type

Variant

Availability

Example

Run time Read / Write

SelTextBackColor

Run time Read / Write

SelUnderline

Run time Read / Write

AR2Std | 331

Page 332: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

rtfLetter.SelUnderline = False

Tag

Description

Sets or returns a user defined value associated with the specified RTF control.

Data Type

String

Availability

Text

Description

Sets or returns the RichEdit control's contents as a text string.

Data Type

String

Availability

Example

Me.RichEdit1.Text = "RichEdit Text"

TextRTF

Description

Sets or returns the RTF contents of the RichEdit control as a text string.

Data Type

String

Availability

Tag

Design time Read / Write Run time Read / Write

Text

Design time Read / Write Run time Read / Write

TextRTF

Design time N/A Run time Read / Write

AR2Std | 332

Page 333: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

RichEdit1.TextRTF = "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}\viewkind4\uc1\pard\lang1033\f0\fs17 Rich Text\par }"

ZOrder

Description

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

Return Type

None

Syntax

Sub Zorder(Position As Integer)

Parameters

Settings

Example

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

ZOrder

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

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

AR2Std | 333

Page 334: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

RTF Text Control Methods

Clear

Description

Clear method deletes the current selection.

Return Type

None

Syntax

Sub Clear()

Parameters

None

Copy

Description

RTF Text Control Methods

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

AR2Std | 334

Page 335: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Copy method copies the current selection to the clipboard. The clipboard contents are set to RTF.

Return Type

None

Syntax

Sub Copy()

Parameters

None

Cut

Description

Cut method cuts (copies then deletes) the current selection to the clipboard. The clipboard contents are set to RTF.

Return Type

None

Syntax

Sub Cut()

Parameters

None

DeleteField

Description

DeleteField method deletes a merge field with the specified name at the specified position in the RTF stream.

A field named FieldName must exist at the specified position. If a field is not found the method will return False.

Return Type

Boolean

Syntax

Sub DeleteField(szFieldName As String, nPos As Long, bDeleteAll As Boolean) As Boolean

Parameters

Cut

DeleteField

Name Type DescriptionszFieldName 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

AR2Std | 335

Page 336: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Find

Description

Find method searches the RTF stream for the first occurrence of the text string within the specified region.Return Type

•Long Start position of the search string within the text stream, -1 if the string is not found.

Syntax

Function Find(szText As String, nStart As Long, nEnd As Long, fcType As FindConstants, pnEnd As Long) As Long

Parameters

InsertField

Description

InsertField method inserts a new merge field into the RTF stream at the specified position. You can use the ReplaceField method to merge field values into the RTF stream.Return Type

•Boolean True, if the insertion is successful.

Syntax

Function InsertField(szFieldName As String, nPos As Long)As Boolean

Parameters

Example

Private Sub ActiveReport_ReportStart() ' Set up the letter merge fields rtfLetter.InsertField("CustomerName", 0) rtfLetter.SetText = vbCRLF rtLetter.InsertField("Address", rtfLetter.SelStart) End Sub

Name Type DescriptionszText 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 DescriptionszFieldName String Name of the field nPos Long Field position within the text stream

LoadFile

AR2Std | 336

Page 337: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

LoadFile

Description

LoadFile method loads an ASCII or RTF formatted text file into the control.

Return Type

None

Syntax

Sub LoadFile(szFileName As String, isFileType As LoadSaveConstants)

Parameters

Example

Private Sub ActiveReport_ReportStart() ' Load formatted letter from file rtfLetter.Load App.Path & "\LetterTemplate.RTF", rtfRTF End Sub

Paste

Description

Paste method pastes contents of the clipboard into the RTF stream at the current position.

Return Type

None

Syntax

Sub Paste()

Parameters

None

ReplaceField

Description

ReplaceField merges the contents of the RTF stream with the field values specified. You can use this method to create mail merge RTF content in your report. The control will replace all occurrences of the field with the specified value.

Return Type

None

Syntax

Name Type DescriptionFileName String Name of the input file. FileType LoadSaveConstants File format (RTF or ASCII)

Paste

ReplaceField

AR2Std | 337

Page 338: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sub ReplaceField(bstrFiel As String, bstrValue As String)

Parameters

Example

Private Sub Detail_Format() ' Merge the letter fields in the RTF control rtfLetter.ReplaceField("CustomerName", txtCustomer.Text) End Sub

SaveFile

Description

SaveFile method saves the RTF text stream to the specified file name in ASCII or RTF format.

Return Type

None

Syntax

Sub SaveFile(szPathName As String, isFileType As LoadSaveConstants)

Parameters

Example

Private Sub Detail_Format() rtfLetter.ReplaceField "CustomerName", _ dcRptData.Recordset.Fields("CustomerName").Value ' Replace merge fields ' Save the result to a file rtfLetter.Save App.Path & "\" & _ txtCustomerName.Text & ".RTF", 0 End Sub

SelectField

Description

Selects a specified field in the RTF control.

Return Type

Name Type DescriptionbstrField String The name of the field to be replaced. bstrFieldValue String The value used to replace the field name.

SaveFile

Name Type DescriptionszPathName String Name of the output file. IsFileType LoadSaveConstants File format ASCII or RTF

SelectField

AR2Std | 338

Page 339: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Boolean

Syntax

Function SelectField(FieldName As String, Index As Long) As Boolean

Parameters

Shape Properties

BackColor

Description

Sets or returns the background color or fill color for the objects.

Note: The BackColor property is visible only when the BackStyle is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

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

Name Type DescriptionFieldName String Name of the field to select Index Long Index for the specified field.

Shape Control Properties

Property Data Type DescriptionBackColor 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

Design time Read / Write Run time Read / Write

AR2Std | 339

Page 340: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

End If End Sub

BackStyle

Description

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

Data Type

BackStyle

Availability

Example

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

LineColor

Description

LineColor property sets or returns the pen color used to draw the shape's border.

Data Type

OLE_COLOR

Availability

Example

BackStyle

Design time Read / Write Run time Read / Write

LineColor

Design time Read / Write Run time Read / Write

AR2Std | 340

Page 341: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub Detail_Format() Shape1.Shape = ddSHRoundRect Shape1.LineColor = vbGreen Shape1.LineStyle = ddLSDashDotDot Shape1.LineWeight = 4 End Sub

LineStyle

Description

LineStyle property sets or returns the pen style used to draw the shape's border.

Data Type

LineStyle

Settings

Availability

Example

Private Sub Detail_Format() Shape1.Shape = ddSHRoundRect Shape1.LineColor = vbGreen Shape1.LineStyle = ddLSDashDotDot Shape1.LineWeight = 4 End Sub

LineWeight

Description

LineWeight property sets or returns the width of the shape's border in line weight units 1lw = 10 twips.

Data Type

Integer

Availability

LineStyle

Value Mnemonic Description0 ddLSTransparent No line 1 ddLSSolid 2 ddLSDash 3 ddLSDot 4 ddLSDashDot 5 ddLDDashDotDot

Design time Read / Write Run time Read / Write

LineWeight

AR2Std | 341

Page 342: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub Detail_Format() Shape1.Shape = ddSHRoundRect Shape1.LineColor = vbGreen Shape1.LineStyle = ddLSDashDotDot Shape1.LineWeight = 4 End Sub

Shape

Description

Shape property determines the type of the shape to draw using the control.

Data Type

ShapeType

Settings

Availability

Example

Private Sub Detail_Format() Shape1.Shape = ddSHRoundRect Shape1.LineColor = vbGreen Shape1.LineStyle = ddLSDashDotDot Shape1.LineWeight = 4 End Sub

Subreport Properties

Design time Read / Write Run time Read / Write

Shape

Value Mnemonic Description0 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 DescriptionCanGrow 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

AR2Std | 342

Page 343: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

CanGrow

Description

Determines whether the subreport print area grows as needed. When the subreport grows, the controls directly below it will be pushed downwards.

Data Type

Boolean

Availability

Example

Private Sub ActiveReport_ReportStart() 'Set the subreport control's object to the sub report Set SubRpt.object = New rptOrders SubRpt.CanGrow = False SubRpt.CanShrink = False End Sub

CanShrink

Description

Determines whether the subreport's print area shrinks to fit its contents.

Data Type

Boolean

Availability

Example

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.

CanGrow

Design time Read / Write Run time Read / Write

CanShrink

Design time Read / Write Run time Read / Write

AR2Std | 343

Page 344: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub ActiveReport_ReportStart() 'Set the subreport control's object to the sub report Set SubRpt.object = New rptOrders SubRpt.CanGrow = False SubRpt.CanShrink = False End Sub

DataField

Description

When using shaped or hierarchical recordsets, DataField defines the source of data for the SubReport control to use. When the DataSource is set and the DataField property is set to a valid appended child group from the data source, ActiveReports binds the subreport to an appended child recordset.

When using XML, setting the DataField property to a valid node list will also allow the subreport to bind to the child node list.

Note: Setting the DataField property will only work with shaped and hierarchical recordsets, or a valid node list. Setting the DataField to a single field will not return any data.

Data Type

String

Availability

Example

Private Sub ActiveReport_DataInitialize() 'Connects the report's datacontrol to the database de.cnnNWind.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & GetVBPath() & "\NWIND.MDB;Persist Security Info=False" de.rsCustomers.Open Set dc.Recordset = de.rsCustomers Set srpt.object = New rptOrders 'Sets subreport control datasource to the report's 'datacontrol(dc) srpt.DataSource = "dc" 'Sets the SubReport control's datafield to an 'appended child recordset srpt.DataField = "Orders" End Sub

Object

Description

Sets or returns a reference to the ActiveReport object to be used as a subreport. The object should be set in the report start event.

Note: You must set this property to link your subreport to an instance of the child report.

Data Type

DataField

Design time Read / Write Run time Read / Write

Object

AR2Std | 344

Page 345: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Object

Availability

Example

Dim i_CID As String Private Sub ActiveReport_FetchData(EOF As Boolean) 'Gets the current records customer ID i_CID = me.DataControl1.Recordset!customerID End Sub Private Sub ActiveReport_ReportEnd() 'Set the subreport control's object to nothing Unload SubRpt.object Set SubRpt.object = Nothing End Sub Private Sub ActiveReport_ReportStart() 'Set the subreport control's object to the sub report Set SubRpt.object = New rptOrders End Sub Private Sub Detail_Format() 'Sets the subreport's recordset for the new customer ID SubRpt.object.DataControl1.Source = "Select * from orders where customerid = '" & i_CID & "'" End Sub

ReportName

Description

Sets or returns the name of the linked report object.

Data Type

String

Availability

Example

Private Sub ActiveReport_ReportStart() 'Set the subreport control's object to the sub report Set SubRpt.object = New rptOrders SubRpt.CanGrow = False SubRpt.CanShrink = False SubRpt.ReportName = "Customer Orders" End Sub

Run time Read / Write

ReportName

Design time Read / Write Run time Read / Write

ZOrder

AR2Std | 345

Page 346: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ZOrder

Description

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

Return Type

None

Syntax

Sub Zorder(Position As Integer)

Parameters

Settings

Example

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

Data Controls ADO

Name Type DescriptionPosition Integer Sets the position, front or back, for the control.

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

AR2Std | 346

Page 347: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

DAO

RDO

XML

ADO ADO Data Control Properties

ADO Data Control Methods

ADO Data Control Properties

ADO

ADO Data Control Properties

Property Data Type DescriptionCommandTimeOut 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

AR2Std | 347

Page 348: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

CommandTimeOut

Description

Sets or returns the period of time (in seconds) to wait for a command to execute before returning a timeout error.

Data Type

Long

Availability

Example

Private Sub CreateReport() Dim rpt As New rptTemplate Dim ctl As Object ' Create an ADO Data data source control With rpt.Sections("Detail").Controls Set ctl = .Add("DDActiveReports2.DataControl") End With ctl.Provider = "MSDASQL" ctl.ConnectionString = "driver={SQL Server};" & _ ctl.Source = "SELECT * FROM RoySched" ctl.ConnectionTimeOut = 20 ctl.CommandTimeout = 20 ctl.MaxRows = 20 ctl.LockType = 0 ' ReadOnly ' Create Additional Controls ' Run and Preview the report output rpt.Show End Sub

Connection

Description

Sets or returns the ADO connection object associated with the data control. The connection property allows you to share the ADO connection in your application with the report.

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

Connection

AR2Std | 348

Page 349: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

Object

Availability

Example

Dim rpt As New rptSales Set rpt.dc.Connection = cnnAppConnection RptSales.Show

ConnectionString

Description

Sets or returns the string of parameters used to open the connection. ADO uses the following connection parameters:

Data Type

String

Availability

Example

Private Sub CreateReport() Dim rpt As New rptTemplate Dim ctl As Object ' Create an ADO data source control With rpt.Sections("Detail") Set ctl = .CreateControl("DDActiveReports2.DataControl") End With ctl.Provider = "MSDASQL" ctl.ConnectionString = "driver={SQL Server};" & _

Run time Read / Write

ConnectionString

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

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

AR2Std | 349

Page 350: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

"Server=local;uid=sa;pwd=;database=pubs" ctl.Source = "SELECT * FROM RoySched" ctl.ConnectionTimeOut = 20 ctl.CommandTimeout = 20 ctl.MaxRows = 20 ctl.LockType = 0 ' ReadOnly ' Create Additional Controls ' Run and Preview the report output rpt.Show End Sub

ConnectionTimeOut

Description

Sets or returns the period of time (in seconds) to wait for a connection before terminating and returning an error.

Data Type

Long

Availability

Example

Private Sub CreateReport() Dim rpt As New rptTemplate Dim ctl As Object ' Create an ADO data source control With rpt.Sections("Detail").Controls Set ctl = .Add("DDActiveReports2.DataControl") End With ctl.Provider = "MSDASQL" ctl.ConnectionString = "driver={SQL Server};" & _ "Server=local;uid=sa;pwd=;database=pubs" ctl.Source = "SELECT * FROM RoySched" ctl.CommandTimeout = 20 ctl.MaxRows = 20 ctl.LockType = 0 ' ReadOnly ' Create Additional Controls ' Run and Preview the report output rpt.Show End Sub

CursorLocation

Description

Sets or returns the location of the cursor that ActiveReports should created when creating the recordset. Setting the CursorLocation to ddADOUseClient allows you to disconnect the recordset and use client-side features such as Sort and Filter properties that are made available by some OLEDB providers.

ConnectionTimeOut

Design time Read / Write Run time Read / Write

CursorLocation

AR2Std | 350

Page 351: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

ADOCursorLocation

Settings

Availability

Remarks

The CursorLocation is read/write when the recordset is closed and read-only when the recordset is open.

CursorType

Description

The CursorType property specifies the type of cursor that should be used when opening the recordset.

Data Type

ADOCursorType

Settings

Availability

Remarks

The CursorType property is read/write when the recordset is closed and read-only when the recordset is open.

DataSourceName

Description

Sets or returns the data source name for the connection.

Data Type

Value Mnemonic Description2 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 Description0 ddADOOpenForwardOnly Default - Creates a forward-only cursor. 1 ddADOOpenKeyset Keyset cursor 2 ddADOOpenDynamic Dynamic Cursor 3 ddADOOpenStatic Static cursor

Design time Read / Write Run time Read / Write**

DataSourceName

AR2Std | 351

Page 352: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

String

Availability

Example

Private Sub RunReport() Dim sDSN As String ' Modify the report DSN to a DSN name from the registry sDSN = LoadDSNFromReg() If sDSN <> "" Then Load rptSales rptSales.dcRptData.DataSourceName = sDSN rptSales.Show End If End Sub

DefaultDatabase

Description

Sets or returns the name of the default database to use from the provider.

Data Type

String

Availability

LockType

Description

Sets or returns the type of record locking to be used while reading from, or writing to, the data source.

Data Type

Long

Availability

Design time Read / Write Run time Read / Write

DefaultDatabase

Design time Read / Write Run time Read / Write

LockType

Design time Read / Write Run time Read / Write

MaxRows

AR2Std | 352

Page 353: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

MaxRows

Description

Sets or returns the number of records to return from the record set for processing in the detail section.

You can use this property to create Top n style reports. For example, you can create a sales query that returns sales results of all employees sorted in a descending order by the total sales amount. Set the MaxRows property to the number of top records you want to print.

Note: Default value of 0 means all records.

Data Type

Long

Availability

Example

Private Sub ActiveReport_ReportStart() ' Set the number of records returned by the query to 10 ' For Top 10 Report dcRptData.MaxRows = 10 End Sub

NRecords

Description

Returns the number of records in the current recordset.

Data Type

Long

Availability

Password

Description

Sets or returns the data source password.

Data Type

String

Design time Read / Write Run time Read / Write

NRecords

Design time N/A Run time Read-Only

Password

AR2Std | 353

Page 354: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

Private Sub ActiveReport_ReportStart() ' Set the user login properties before the report ' starts dcRptData.UserID = sUserID dcRptData.Password = sPassword End Sub

Provider

Description

Sets or returns the name of the OLEDB provider for the data source. The Provider property is read/write when the connection is closed and read-only when it is open.

Data Type

String

Availability

Example

Private Sub ActiveReport_ReportStart() ' Set the OLEDB provider name dcRptData.Provider = "MSDASQL" End Sub

Recordset

Description

Sets or returns a reference to the recordset object.

Data Type

Object

Availability

Example

Design time Read / Write Run time Read / Write

Provider

Design time Read / Write Run time Read / Write

RecordSet

Run time Read / Write

AR2Std | 354

Page 355: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub PrintOrder(lOrderID As Long) Dim rs As Recordset ' Print a specific order based on a parameter sSQL = "SELECT * FROM Invoice WHERE OrderID = " & _ Str(lOrderID) Set rs = dbOrderSystem.OpenRecordset(sSQL) Load rptOrders ' Set the recordset property to our VB recordset Set rptOrders.dcRptData.Recordset = rs ' Print the report rptOrders.PrintReport End Sub

Source

Description

Sets or returns the SQL source or table name for the recordset object.

Data Type

String

Availability

Example

srptProducts.dcRptData.Source = sSQL srptProducts.dcRptData.Refresh

UserID

Description

Sets the user id used to open the data source.

Data Type

String

Availability

Example

Private Sub ActiveReport_ReportStart() ' Set the user login properties before the report>

Source

Design time Read / Write Run time Read / Write

UserID

Design time Read / Write Run time Read / Write

AR2Std | 355

Page 356: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

' starts dcRptData.UserID = sUserID dcRptData.Password = sPassword End Sub

ADO Data Control Methods

Refresh

Description

Refresh method refreshes the data control's recordset. Use this method to update the recordset after modifying any of the connection or record source properties of your data control.

Return Value

•None the recordset object property will be updated to contain the new results.

Syntax

Sub Refresh()

Parameters

None

Example

srptProducts.dcRptData.Source = sSQL srptProducts.dcRptData.Refresh

DAO DAO Data Control Properties

DAO Data Control Methods

DAO Data Control Properties

ADO DB Data Control Methods

Method DescriptionRefresh Refreshes the data control's recordset.

Sub Refresh()

Refresh

DAO

DAO Data Control Properties

Property Data Type DescriptionConnect String Sets or returns the connection string

or type to the data source.

AR2Std | 356

Page 357: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Connect

Description

Connect property sets or returns the connection string or type of the data source. The connection string can be any of the ISAM file types supported by DAO, or set to ODBC;<ODBC connection string> for ODBC access.

Note: To access locked mdb files, you should set the connect property to "Access;<pwd>"

Data Type

String

Availability

Example

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

AR2Std | 357

Page 358: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

' Connect to SQL Server using ODBC dcRptData.Connect = "ODBC;DSN=LocalServer;UID=sa;PWD=;"

DatabaseName

Description

DatabaseName property sets or returns the database name or path based on the Connect property setting.

Data Type

String

Availability

Example

Private Sub ActiveReport1_ReportStart() ' Verify the location of the database dcRptData.DatabaseName = App.Path & "\appdb.mdb" End Sub

DefaultCursorType

Description

DefaultCursorType sets or returns the type of cursor driver used to open the data source. This property is valid when the data source is ODBCDirect. It is ignored when the type is JET.

Data Type

DAOCursorType

Settings

Availability

DefaultType

DatabaseName

Design time Read / Write Run time Read / Write

DefaultCursorType

Value Mnemonic Description0 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

AR2Std | 358

Page 359: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

DefaultType determines the type of data source to be opened You can use the JET engine or ODBCDirect, which bypasses the JET and accesses RDO directly.

Data Type

DAODefaultType

Settings

Availability

Exclusive

Description

Exclusive property determines whether the data source recordset should be opened in an exclusive single-user mode or shared multi-user mode. In most cases, you would accept the default False setting.

Data Type

Boolean

Availability

MaxRows

Description

Sets or returns the number of records to return from the record set for processing in the detail section. You can use this property to create Top n style reports. For example, you can create a sales query that returns sales results of all employees sorted in a descending order by the total sales amount. Set the MaxRows property to the number of top records you want to print.

Note: Default value of 0 means all records.

Data Type

Long

Availability

Value Mnemonic Description1 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

Design time Read / Write Run time Read / Write

AR2Std | 359

Page 360: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub ActiveReport_ReportStart() ' Set the MaxRows to the top n records dcRptData.MaxRecords = nMaxRecords End Sub

Options

Description

Options property specifies one or more of the recordset object characteristics. You can combine settings using the "OR" operator.

Data Type

Long

Availability

Password

Description

Password property sets or returns the password string associated with the user name used to open secure mdb files. ActiveReports sets the DbEngine.DefaultPassword to this property before attempting to open the mdb file.

Data Type

String

Availability

Example

Private Sub RunPayrollReport() frmGetPassword.Show vbModal If sPwd <> "" Then ' Load the report Load rptPayroll rptPayroll.dcRptData.SystemDB = App.Path & _ "\Payroll.mdw" ' Set the password for the secure database rptPayroll.dcRptData.UserName = sUser rptPayroll.dcRptData.Password = sPwd

Options

Design time Read / Write Run time Read / Write

Password

Design time Read / Write Run time Read / Write

AR2Std | 360

Page 361: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

' Preview the report, ' an error would occur if the password is invalid rptPayroll.Show End If End Sub

Recordset

Description

Recordset property sets or returns a reference to the open recordset object. You can use the recordset property to set your own created recordset object at run time.

Data Type

Object

Availability

Example

Private Sub PrintOrder(lOrderID As Long) Dim rs As Recordset ' Print a specific order based on a parameter sSQL = "SELECT * FROM Invoice WHERE OrderID = " & _ Str(lOrderID) Set rs = dbOrderSystem.OpenRecordset(sSQL) Load rptOrders ' Set the recordset property to our VB recordset Set rptOrders.dcRptData.Recordset = rs ' Print the report rptOrders.PrintReport End Sub

RecordsetType

Description

RecordsetType property determines the type of the open recordset.

Data Type

DAORecordsetType

Settings

Availability

Recordset

Run time Read / Write

RecordsetType

Value Mnemonic Description0 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

AR2Std | 361

Page 362: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

RecordSource

Description

RecordSource property sets or returns the SQL RecordSource, table name or querydef name for the data control.

Data Type

String

Availability

Example

' Modify the report record source based on user input sSQL = "SELECT * FROM Customers " sSQL = sSQL & "WHERE Region = '" & sState & "'" rptOrders.dcRptData.Recordsource = sSQL rptOrders.dcRptData.Refresh

SystemDB

Description

SystemDB property sets or returns the name of the security file (system.mdw) required to open secure database files. ActiveReports sets the DAO DbEngine.SystemDB property to the value of this property.

Data Type

String

Availability

Example

Private Sub RunPayrollReport() frmGetPassword.Show vbModal If sPwd <> "" Then ' Load the report Load rptPayroll ' Set the pathname to the security file rptPayroll.dcRptData.SystemDB = App.Path & _ "Payroll.mdw" ' Set the password for the secure database rptPayroll.dcRptData.UserName = sUser

RecordSource

Design time Read / Write Run time Read / Write

SystemDB

Design time Read / Write Run time Read / Write

AR2Std | 362

Page 363: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

rptPayroll.dcRptData.Password = sPwd ' Preview the report, ' an error would occur if the password is invalid rptPayroll.Show End If End Sub

UserName

Description

UserName sets or returns the user name used to open a secure database files. ActiveReports sets the DAO DbEngine.UserName property to the value of this property.

Data Type

String

Availability

Example

Private Sub RunPayrollReport() frmGetPassword.Show vbModal If sPwd <> "" Then ' Load the report Load rptPayroll ' Set the pathname to the security file rptPayroll.dcRptData.SystemDB = App.Path & _ "Payroll.mdw" ' Set the password for the secure database rptPayroll.dcRptData.UserName = sUser rptPayroll.dcRptData.Password = sPwd ' Preview the report, ' an error would occur if the password is invalid rptPayroll.Show End If End Sub

DAO Data Control Methods

Refresh

UserName

Design time Read / Write Run time Read / Write

DAO Data Control Methods

Method DescriptionRefresh Refreshes the data control's recordset.

Sub Refresh()

Refresh

AR2Std | 363

Page 364: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Refresh method refreshes the data control's recordset. Call this method after modifying any of the data control's connection and RecordSource properties.

Return Value

•None the recordset object property will be updated to contain the new results.

Syntax

Sub Refresh()

Parameters

None

Example

srptProducts.dcRptData.RecordSource = sSQL srptProducts.dcRptData.Refresh

RDO RDO Data Control Properties

RDO Data Control Methods

RDO Data Control Properties

RDO

RDO Data Control Properties

Property Data Type DescriptionConnect 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

AR2Std | 364

Page 365: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Connect

Description

Connect string sets the parameters for the RDO connection. Parameters are specified in the <parameter>=<value>; format. Valid parameters are:

Data Type

String

Availability

Example

' DSN-Less Connection dcRptData.Connection = "driver={SQL Server};" & _ "SERVER=bigsmile;UID=sa;PWD=pwd;database=pubs" ' DSN Connection dcRptData.LoginTimeout = 30 dcRptData.Connect = "DSN=Pubs;UID=sa;PWD=pwd;" ' Open a connection using a DSN and individual arguments ' instead of a connection string

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.

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

AR2Std | 365

Page 366: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

dcRptData.DataSourceName = "Pubs" dcRptData.UserName = "sa" dcRptData.Password = "pwd"

Connection

Description

Connection property sets or returns a reference to the connection object used by the RDO Data Control. You can use the property to modify connection settings at run time Or you can set it to your own connection from VB if your database connection is limited.

Data Type

Object

Availability

Example

Private Sub RunReport(rpt As Object) ' Assign our already open connection to save on connection rpt.Connection = cnnOrderEnter rpt.Show End Sub

CursorDriver

Description

Sets or returns the type of cursor to be created for the resultset.

Data Type

RDOCursorDriver

Settings

Availability

Connection

Run time Read / Write

CursorDriver

Value Mnemonic Description0 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

AR2Std | 366

Page 367: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

DataSourceName

Description

Sets or returns the ODBC registered data source name to connect to. This property can be left blank if you are setting the DSN in the Connect property.

Data Type

String

Availability

Example

Private Sub ActiveReport_ReportStart() Dim sDSN As String sDSN = GetDSNFromRegistry() dcRptData.DataSourceName = sDSN End Sub

Environment

Description

Returns a reference to the RDOEnvironment object used by the RDO Data Control.

Data Type

Object

Availability

ErrorThreshold

Description

Sets or returns the severity level that constitutes a fatal error.

Data Type

Long

Availability

Design time Read / Write Run time Read / Write

Environment

Run time Read / Write

ErrorTheshold

Design time Read / Write Run time Read / Write

KeysetSize

AR2Std | 367

Page 368: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

KeysetSize

Description

Sets or returns the number of records in the keyset buffer. The value should be greater than or equal to the RowsetSize property value.

Data Type

Long

Availability

LockType

Description

Sets or returns the type of concurrency handling and record locking. You do not need to change the default of read-only cursor locking since the report is only reading the data for output.

Data Type

RDOLockType

Settings

Availability

LoginTimeout

Description

Sets or returns the number of seconds to wait for establishing a connection before a timeout error.

Data Type

Long

Availability

Design time Read / Write Run time Read / Write

LockType

Value Mnemonic Description1 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

AR2Std | 368

Page 369: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

LogMessages

Description

Sets or returns the name of the ODBC-trace log file.

Data Type

String

Availability

MaxRows

Description

Sets the maximum number of rows to return from the remote server.

Data Type

Long

Availability

Options

Description

Sets or returns the resultset characteristics flags.

Data Type

Integer

Availability

Design time Read / Write Run time Read / Write

LogMessages

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

AR2Std | 369

Page 370: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Password

Description

Sets or returns the password associated with the user id used to connect to the data source.

Data Type

String

Availability

Example

Private Sub ActiveReport_ReportStart() ' Set the user name and password before ' openning the recordset dcRptData.UserName = gsUser dcRptData.Password = gdPassword End Sub

Prompt

Description

Determines how the ODBC driver should prompt for missing connection parameters.

Data Type

RDOPrompt

Settings

Design time Read / Write Run time Read / Write

Prompt

Value Mnemonic Description0 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,

AR2Std | 370

Page 371: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

QueryTimeout

Description

Number of seconds to wait before a query timeout error occurs.

Data Type

Long

Availability

Resultset

Description

Sets or returns a reference to the RDOResultset object of the connection.

Data Type

Object

Availability

Example

Private Sub RunReport() Load rptProducts ' Set the report resultset to our VB RDO Resultset Set rptProducts.dcRptData.Resultset = rs ' Preview the report rptProducts.Show End Sub

ResultsetType

except the driver disables the controls for any information not required to complete the connection.

Design time Read / Write Run time Read / Write

QueryTimeout

Design time Read / Write Run time Read / Write

Resultset

Run time Read / Write

ResultsetType

AR2Std | 371

Page 372: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Sets or returns the type of the open resultset: static or keyset.

Data Type

RDOResultSetType

Settings

Availability

RowsetSize

Description

RowsetSize returns the number of rows in a resultset.

Data Type

Long

Availability

SQL

Description

The SQL statement that defines the query executed by the control.

Data Type

String

Availability

Example

Private Sub PrintOrder(lOrderID As Long)

Value Mnemonic Description1 DdRDOOpenKeySet Creates a keyset resultset 3 DdRDOOpenStatic Creates a static resultset

Design time Read / Write Run time Read / Write

RowsetSize

Design time Read / Write Run time Read / Write

SQL

Design time Read / Write Run time Read / Write

AR2Std | 372

Page 373: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Dim sSQL As String Load rptOrder sSQL = "SELECT * FROM orders " sSQL = sSQL & "WHERE OrderID = " & Str(lOrderID) ' Modify the SQL rptOrder.dcRptData.SQL = sSQL rptOrder.Show End Sub

UserName

Description

The user name used in the connection.

Data Type

String

Availability

Example

Private Sub ActiveReport_ReportStart() ' Set the user name and password before ' openning the recordset dcRptData.UserName = gsUser dcRptData.Password = gdPassword End Sub

Version

Description

The version of the data source associated with the connection.

Data Type

String

Availability

RDO Data Control Methods

UserName

Design time Read / Write Run time Read / Write

Version

Design time N/A Run time Read / Write

RDO Data Control Methods

AR2Std | 373

Page 374: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Refresh

Description

Refreshes the data control's resultset.

Return Value

•None the resultset object property will be updated to contain the new results.

Syntax

Sub Refresh()

Parameters

None

Example

Private Sub Detail_Format() srptProducts.dcRptData.SQL = "SELECT * FROM Products" & _ " WHERE CategoryID = " & txtCategoryID.Text srptProducts.dcRptData.Refresh End Sub

XML XML Data Control Properties

XML Data Control Methods

XML Data Control Properties

Method DescriptionRefresh Refreshes the data control's recordset.

Sub Refresh()

Refresh

XML

XML Data Control Properties

Property Data Type DescriptionBOF 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

AR2Std | 374

Page 375: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BOF

Description

Returns whether or not the node is at the beginning of the nodelist.

Data Type

String

Availability

Example

If me.XMLDataControl.BOF and me.XMLDataControl.EOF then Exit sub End if

Count

Description

Returns the number of nodes selected by the XSLPattern specified in the RecordsetPattern property.

Data Type

String

Availability

Example

Private Sub ActiveReport_ReportStart() Dim recCount As Long recCount = XMLDataControl1.Count End Sub

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

Design time N/A Run time Read Only

AR2Std | 375

Page 376: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

CurrentPosition

Description

Returns the record number the XML database is currently using.

Note: The first record in the database is at position 0.

Data Type

String

Availability

Example

lblDetailItem.Caption = xmlDC.CurrentPosition

EOF

Description

Returns whether or not the node is at the end of the nodelist.

Data Type

String

Availability

Example

If me.XMLDataControl.BOF and me.XMLDataControl.EOF then Exit sub End if

FileURL

Description

Sets or returns the XML DataControl's URL or file name of the XML document to which the report is connected.

Data Type

CurrentPosition

Design time N/A Run time Read Only

EOF

Design time N/A Run time Read Only

FileURL

AR2Std | 376

Page 377: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

String

Availability

Example

Private Sub ActiveReport_DataInitialize() If connectLocal = False Then XMLDataControl1.FileURL = _ "http://www.datadynamics.com/samples/ratings.xml" Else XMLDataControl1.FileURL = App.Path & _ "\purchaseorder.xml" End If End Sub

NodeList

Description

Sets or returns a text stream containing the list of nodes that makes up the current XML recordset. The NodeList is based on the RecordSetPattern or can be set directly from an XML NodeList object.

Data Type

Variant

Availability

Example

Private Sub Detail_Format() Dim itemReport As rptOrderItems Set itemReport = New rptOrderItems 'Set the node list for the subreport based off the main 'reports XML DataControl itemReport.XMLDataControl1.NodeList = _ Me.XMLDataControl1.Field("Manifest/Item", True) SubReport1.object = itemReport End Sub

RecordSetPattern

Design time Read / Write Run time Read / Write

NodeList

Design time N/A Run time Read / Write

RecordSetPattern

AR2Std | 377

Page 378: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Sets or returns an XSL pattern to be used to retrieve the nodes (records) which the report will iterate through when the report is generated. The report uses each node selected in the RecordSetPattern to create a detail section.

When using XML data control theDataField property represents an XPath pattern whose base path is the current node in the NodeList that the recordset pattern selects.

For example, in the following XML document the XSL RecordSet pattern can be set to //ITEM to select all ITEM nodes in the XML document resulting in two records.

<ORDER ID="12"> <ITEM ID="ITEM1">ActiveReports</ITEM> <ITEM ID="ITEM2">ActiveBar</ITEM> </ORDER>

Note: XSL patterns are case sensitive and must use valid XSL syntax. XSL and XPath documentation can be found on MSDN at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmrefxpathsyntax.asp

Typical XSL patterns

Data Type

String

Availability

Example

Private Sub ActiveReport_DataInitialize() XMLDataControl1.ValidateOnParse = True XMLDataControl1.FileURL = App.Path & _ "\purchaseorder.RPX" XMLDataControl1.RecordsetPattern = "Manifest/Item" End Sub

ValidateOnParse

Description

Sets or returns whether or not the XML database should validate the XML structure against a linked XML schema while it is being parsed. If ValidateOnParse is false, only a properly formed XML databases can be used.

Data Type

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

ValidateOnParse

AR2Std | 378

Page 379: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

String

Availability

Example

Private Sub ActiveReport_DataInitialize() XMLDataControl1.ValidateOnParse = True XMLDataControl1.FileURL = App.Path & _ "\purchaseorder.XML" XMLDataControl1.RecordsetPattern = "Manifest/Item" End Sub

XML Data Control Methods

Field

Description

Returns the field specified from the XML database. When working with subreports, setting the asNodeList to true will allow for manual binding to the subreports XML DataControl.

Return Type

None

Syntax

Function Field(Name As String,[AsNodeList])

Parameters

Design time N/A Run time Read / Write

XML Data Control Methods

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

Name Type DescriptionName String Name of XML field

AR2Std | 379

Page 380: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub Detail_Format() Dim itemReport As rptOrderItems Set itemReport = New rptOrderItems itemReport.XMLDataControl1.NodeList = _ Me.XMLDataControl1.Field("Manifest/Item", True) SubReport1.object = itemReport End Sub

LoadXML

Description

Loads XML data by using the indicated XML string. The XMLString can be an entire XML document or a correctly formed XML document section.

Return Type

None

Syntax

Sub LoadXML(XMLString As Integer)

Parameters

Example

Private Sub ActiveReport_DataInitialize() XMLDataControl1.ValidateOnParse = True XMLDataControl1.RecordsetPattern = "//Customer" XMLDataControl1.LoadXML ("<Order>" & _ "<Customer>" & _ "<Name>John Doe</Name>" & _ Cardnum>131 131 131 131</Cardnum>" & _ "<Manifest>" & _ "<Item>" & _ "<ID>204</ID>" & _ "<Title>Advanced VB</Title>" & _ Quantity>1</Quantity>" & _ "<UnitPrice>$10.75</UnitPrice>" & _ "</Item>" & _ "</Manifest>" & _ "<Receipt>" & _ "<Subtotal>$23.75</Subtotal>" & _ "<Tax>$2.43</Tax>" & _ "</Receipt>" & _ "</Customer>" & _ "</Order>") End Sub

AsNodeList Boolean Determines if the field will be used as a NodeList.

LoadXML

Name Type DescriptionXMLString String String indicating the XML file to load

AR2Std | 380

Page 381: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

MoveNext

Description

Moves to the next node in the nodelist.

Return Type

None

Syntax

Sub MoveNext()

Parameters

None

Reset

Description

Renews the XML database with the original settings or renews the nodelist selection based on new settings. Resetting the nodelist returns the CurrentPosition to the first recordset entry.

Return Type

None

Syntax

Sub Reset()

Parameters

None

History History Properties

History Methods

History Properties

MoveNext

Reset

History

History Properties

Property Data Type DescriptionCount Integer Returns the number of entries in the history stack.Position Integer Returns the position of the current page in the history stack.

Count

AR2Std | 381

Page 382: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Count

Description

Returns the number of entries in the navigation history stack.

Data Type

Integer

Availability

Example

' Command button implementations of a custom toolbar Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position >= 0) btnForward.Enabled = (.Position < .Count) End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position >= 0) btnForward.Enabled = (.Position < .Count) End With End Sub

Position

Description

Returns the position of the current page in the navigation history stack.

Data Type

Integer

Availability

Example

' Command button implementations of a custom toolbar Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position >= 0) btnForward.Enabled = (.Position < .Count) End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position >= 0)

Run time Read

Position

Run time Read

AR2Std | 382

Page 383: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

btnForward.Enabled = (.Position < .Count) End With End Sub

History Methods

Back

Description

Displays the previous page in the navigation history stack.

Return Type

None

Syntax

Sub Back()

Parameters

None

Example

' Command button implementations of a custom toolbar Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position >= 0) btnForward.Enabled = (.Position < .Count) End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position >= 0) btnForward.Enabled = (.Position < .Count) End With End Sub

History Methods

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

AR2Std | 383

Page 384: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Forward

Description

Displays the next page in the navigation history stack.

Return Type

None

Syntax

Sub Forward()

Parameters

None

Example

' Command button implementations of a custom toolbar Private Sub btnBack() With arv.TOC.History .Back btnBack.Enabled = (.Position >= 0) btnForward.Enabled = (.Position < .Count) End With End Sub Private Sub btnForward() With arv.TOC.History .Forward btnBack.Enabled = (.Position >= 0) btnForward.Enabled = (.Position < .Count) End With End Sub

Item

Description

Returns the page number at the selected index in the navigation history stack.

Return Type

None

Syntax

Sub Item(Index As Integer, PageNumber As Long)

Parameters

Example

Dim cIndex As Integer Dim pIndex As Integer

Item

Name Type DescriptionIndex Integer Index of the navigation history entry. PageNumber Long The returned page number at the specified

index.

AR2Std | 384

Page 385: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub arv_TOCClick(ByVal Button As Integer, ByVal ItemIndex As Long, ByVal Flags As Long) pIndex = cIndex cIndex = cIndex + 1 End Sub Private Sub cmdOpenReport_Click() arv.ReportSource = New rptCustomers End Sub Private Sub cmdPrevTOC_Click() Dim pg As Long arv.TOC.History.Item pIndex, pg arv.TOC.GotoPage pg End Sub

Pages and PageSettings PageSettings Properties

Pages

PageSettings Properties

Pages and PageSettings

PageSettings Properties

Property Data Type DescriptionBottomMargin 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

AR2Std | 385

Page 386: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BottomMargin

Description

Sets or returns the space between the bottom of the physical page and the bottom of the printing area.

DataType

SingleDefault Value

1440 twips = 1 inch.

Availability

Example

Private Sub ActiveReport_ReportStart() 'Sets a 1 inch bottom margin Me.PageSettings.BottomMargin = 1440 'Sets a 1 inch top margin Me.PageSettings.TopMargin = 1440 ' ½ inch left margin Me.PageSettings.LeftMargin = 720 ' ½ inch right margin Me.PageSettings.RightMargin = 720 End Sub

Collate

Description

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

Design time Read / Write Run time Read / Write

Collate

AR2Std | 386

Page 387: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

When printing multiple copies of the report, this property determines whether all the pages of the report should be printed before another copy of the report.

Note: This property has no effect when printing a single copy of the report. The collate property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

DataType

PrtCollate

Settings

Availability

Example

Private Sub ActiveReport_ReportStart() 'Prints all copies of a each page before moving to the next page Me.PageSettings.Collate = COLLATE_FALSE End Sub

Duplex

Description

Sets or returns the type of duplex action to use when printing out double sided reports. This property depends on the selected printer device because some printers are unable to support duplex printing.

Note: The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type

prtDuplex

Settings

Value 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

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.

AR2Std | 387

Page 388: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

Private Sub ActiveReport_ReportStart() 'Sets a report up to be bound like a book 'Turn on MirrorMargins Me.PageSettings.MirrorMargins = True 'Sets gutter to .5 in to allow for binding Me.PageSettings.Gutter = 720 'Set duplex to print vertically on both sides Me.PageSettings.Duplex = ddDXVertical End Sub

Gutter

Description

Sets or returns the extra space between the page's edge and the page's margins. The gutter is used primarily for adding extra space for binding pages.

Note: When using mirror margins, the gutter will apply to the left side of odd pages and the right side of even pages.

DataType

Single

Availability

Example

Private Sub ActiveReport_ReportStart() 'Sets a report up to be bound like a book 'Turn on MirrorMargins Me.PageSettings.MirrorMargins = True 'Sets gutter to .5 in to allow for binding Me.PageSettings.Gutter = 720 'Set duplex to print vertically on both sides Me.PageSettings.Duplex = ddDXVertical End Sub

LeftMargin

Description

Design time Read / Write Run time Read / Write

Gutter

Design time Read / Write Run time Read / Write

LeftMargin

AR2Std | 388

Page 389: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sets or returns the space between the left edge of the physical page and the left edge of the printing area.

DataType

SingleDefault Value

1440 twips = 1 inch.

Availability

Example

Private Sub ActiveReport_ReportStart() 'Sets a 1 inch bottom margin Me.PageSettings.BottomMargin = 1440 'Sets a 1 inch top margin Me.PageSettings.TopMargin = 1440 ' ½ inch left margin Me.PageSettings.LeftMargin = 720 ' ½ inch right margin Me.PageSettings.RightMargin = 720 End Sub

MirrorMargins Sets or returns whether the left page's margins will be mirrored on the right page. Setting MirrorMargins to true forces inside margins for opposite pages to be the same width and outside margins for opposite pages to be the same width.

Note: MirrorMargins can be used to set up reports for book style formatting.

DataType

Boolean

Availability

Example

Private Sub ActiveReport_ReportStart() 'Sets a report up to be bound like a book 'Turn on MirrorMargins Me.PageSettings.MirrorMargins = True 'Sets gutter to .5 in to allow for binding Me.PageSettings.Gutter = 720 'Set duplex to print vertically on both sides Me.PageSettings.Duplex = ddDXVertical End Sub

Design time Read / Write Run time Read / Write

MirrorMargins

Design time Read / Write Run time Read / Write

Orientation

AR2Std | 389

Page 390: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Orientation

Description

Determines whether a report prints vertically or horizontally. It defaults to the current setting of the printer in Windows Control Panel.

Note: The Orientation property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type

PrtOrientation

Settings

Availability

Example

' ActiveReports defaults to the current printer settings ' to change the default you need to set the orientation ' property in the ReportStart event Private Sub ActiveReport_ReportStart() me.PageSettings.Orientation = ddOLandscape End Sub

PaperBin

Description

PaperBin sets or returns the paper bin number from which the paper is fed.

Data Type

Integer

Settings

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

PaperBin

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

AR2Std | 390

Page 391: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Note: PaperBin values may very with individual printers. Check printer documentation for appropriate PaperBin.

Availability

PaperHeight

Description

PaperHeight sets or returns the length of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection.

Note: •This property is used only when PaperSize is set to 256 Custom. The PaperHeight property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type

Single

Availability

Example

Private Sub ActiveReport_ReportStart() ' Specify a custom paper size Me.PageSettings.PaperSize = 256 ' Sets the paper's width to 2 inches Me.PageSettings.PaperWidth = 1440 * 2 ' Sets the paper's height to 4 inches Me.PageSettings.PaperHeight = 1440 * 4 End Sub

PaperSize

Description

PaperSize sets or returns the index in the PaperSizes collection of the currently selected standard paper size.

Note: The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Settings

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

PaperSize

Value Description

AR2Std | 391

Page 392: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Note: ActiveReports will use the custom size of PaperHeight and PaperWidth when this property is set to 256.

Note: Not all printers support the above PaperSizes. If the default printer does not support a specified size, the printer's default PaperSize will be used instead.

Data Type

Integer

Availability

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

AR2Std | 392

Page 393: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub InitPaperSizes() Dim I As Integer

• For I = 0 To rptSummary.Printer.PaperSizes.Count 1 lstPaperSizes.AddItem rptSummary.Printer.PaperSizes(I) Next I End Sub Private Sub lstPaperSizes_DblClick() ' Set the paper size to the selected size rptSumamry.PageSettings.PaperSize = lstPaperSizes.ListIndex End Sub

PaperWidth

Description

PaperWidth sets or returns the width of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection.

Note: • This property is used only when PaperSize is set to 256 Custom. The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type

Single

Availability

Example

Private Sub ActiveReport_ReportStart() ' Specify a custom paper size Me.PageSettings.PaperSize = 256 ' Sets the paper's width to 2 inches Me.PageSettings.PaperWidth = 1440 * 2 ' Sets the paper's height to 4 inches Me.PageSettings.PaperHeight = 1440 * 4 End Sub

RightMargin

Description

Sets or returns the space between the right edge of the physical page and the right edge of the printing area.

DataType

SingleDefault Value

PaperWidth

Design time N/A Run time Read / Write

RightMargin

AR2Std | 393

Page 394: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 margin Me.PageSettings.TopMargin = 1440 ' ½ inch left margin Me.PageSettings.LeftMargin = 720 ' ½ inch right margin Me.PageSettings.RightMargin = 720 End Sub

TopMargin

Description

Sets or returns the space between the top of the physical page and the top of the printing area.

DataType

SingleDefault Value

1440 twips = 1 inch.

Availability

Example

Private Sub ActiveReport_ReportStart() 'Sets a 1 inch bottom margin Me.PageSettings.BottomMargin = 1440 'Sets a 1 inch top margin Me.PageSettings.TopMargin = 1440 ' ½ inch left margin Me.PageSettings.LeftMargin = 720 ' ½ inch right margin Me.PageSettings.RightMargin = 720 End Sub

Pages

Design time Read / Write Run time Read / Write

TopMargin

Design time Read / Write Run time Read / Write

Pages

AR2Std | 394

Page 395: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Pages Properties

Pages Methods

Pages Properties

Note: Users should set this property prior to saving or loading a password-protected file.

Password

Description

Sets or returns a case-sensitive password for saving or loading protected reports.

Note: The password should be set prior to saving or loading a password-protected file.

Data Type

String

Availability

Example

Private Sub cmdLoadRDF_Click() ARViewer1.Pages.Password = "myPassword" ARViewer1.Pages.Load app.path & "\Password.RDF" End Sub Private Sub ActiveReport_ReportEnd() Me.Pages.Password = "myPassword"< Me.Pages.Save app.path & "\Password.RDF" End Sub

Pages Methods

Pages Properties

Property Data Type DescriptionPassword String Sets or returns a case-sensitive password for saving or loading protected

reports.

Password

Run time Read / Write

Pages Methods

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

AR2Std | 395

Page 396: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Add

Description

Adds a new blank canvas object to the collection. The new canvas object can be accessed at the index Count • 1.

Return Value

None

Syntax

Sub Add()

Parameters

•None The new canvas object is added to the end of the collection.

Example

' Run the report to create the pages collection rptInvoice.Run ' Add a new page to the report rptInvoice.Pages.Add With rptInvoice.Pages(rptInvoice.Pages.Count-1) ' Print additional information about the report ' to the last page End With ' Display the report with the additional page rptInvoice.Show

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

Commit

AR2Std | 396

Page 397: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Commit

Description

Commits the updates made to the a report's pages collection and causes any linked viewer control to refresh its pages cache. Whenever changes are made to the pages collection, such as adding or removing pages, the commit method should be called to refresh the pages collection with the new changes. Once the pages are committed, the report or viewer will contain the updated pages collection.

Return Value

None

Syntax

Sub Commit()

Parameters

None

Example

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

Count

Description

Returns the number of objects in the collection.

Return Value

Long

Syntax

Function Count() As Long

Parameters

None

Example

Count

AR2Std | 397

Page 398: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

•For I = 0 to rpt.Pages.Count 1

Rpt.Pages(I).Overlay cv Next I

GetPagesInRange

Description

Returns a Pages collection containing only the pages specified in the rangeString. The returned range can then be saved or exported.

Note: The returned pages will be Read-Only since it is based on another pages collection. So the pages can only be save or exported.

Return Type

Pages

Syntax

Function GetPagesInRange(rangeString As String) As Pages

Parameters

Example

Private Sub ActiveReport_ReportEnd() Dim myPDFExport As ActiveReportsPDFExport.ARExportPDF Dim myPageRange As Pages Set myPDFExport = New _ ActiveReportsPDFExport.ARExportPDF Set myPageRange = _ Me.Pages.GetPagesInRange("1,3,5,7,9") myPDFExport.FileName = "C:\PDFExportRanges.PDF" myPDFExport.Export myPageRange End Sub

Insert

Description

Adds the specified canvas object before the specified index in the collection.

Return Value

None

Syntax

Sub Insert(Index As Long, Canvas As Canvas)

Parameters

GetPagesInRange

Name Type DescriptionrangeString String String value indicating the range of pages to

be returned

Insert

Name Type Description

AR2Std | 398

Page 399: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

' Insert a FaxCover Page before the first page in the report rptInvoice.Pages.Insert 0, cvFaxCover

InsertNew

Description

Adds a new blank canvas object before the specified index in the collection.

Return Value

None

Syntax

Sub InsertNew(Index As Long)

Parameters

Example

' Insert a new page before the 5th page in the report rptInvoice.Pages.InsertNew 4

Item

Description

Returns a reference to the canvas object at the specified index.

Return Value

Canvas

Syntax

Function Item(Index As Long) As Canvas

Parameters

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 DescriptionIndex Long Index of the item to succeed the new object.

Item

Name Type DescriptionIndex Long Index of the requested canvas object.

AR2Std | 399

Page 400: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Load

Description

Retrieves previously saved Pages collection.

Return Value

None

Syntax

Sub Load(FileName As String)

Parameters

Example

rptInvoice.Pages.Load App.Path & "\SavedReport.rdf" rptInvoice.Show

Remove

Description

Removes the canvas object at the specified index in the collection.

Return Value

•None The specified item is removed from the collection.

Syntax

Sub Remove(Index As Long)

Parameters

Example

' Remove the first page of the report rptInvoice.Pages.Remove(rptInvoice.Pages(0)) rptInvoice.Pages.Commit

Load

Name Type DescriptionFileName String Full path of the file to be loaded

Remove

Name Type DescriptionIndex Long Index of the canvas object to be removed

from the collection.

RemoveAll

AR2Std | 400

Page 401: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

RemoveAll

Description

Removes all objects from the collection. Count returns 0.

Return Value

•None All objects are removed from the collection.

Syntax

Sub RemoveAll()

Parameters

None

Example

' Clear the pages collection rptInvoice.Pages.RemoveAll rptInvoice.Pages.Commit ' Run the report again rptInvoice.Run

Save

Description

Saves the report pages output to the specified file. Saved files can be loaded and viewed or printed using the viewer control.

Return Value

None

Syntax

Sub Save(FileName As String, [SaveOptions],[Vdata])

Parameters

Settings

Example

' Run the invoice report to create the pages collection rptInvoice.Run

Save

Name Type DescriptionFileName 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 the SaveOptions

Value Description1 Compresses all pages 2 Decompresses all pages and saves them 4 Save to byte array

AR2Std | 401

Page 402: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

' Save the output to file rptInvoice.Pages.Save App.Path & "\Invoice.rdf"

PaperSizes Methods

Count

Description

The count method returns the number of available standard paper sizes.

Return Type

Integer

Syntax

Function Count() As Integer

Parameters

None

Example

'Returns a list of PaperSize Names and Values 'supported by the assigned printer and adds them to a 'listbox control Private Sub cmdGetPaperSizes_Click() For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1 lstPaperSizes.AddItem "PaperSize Value = " & _ ActiveReport1.Printer.PaperSizes.Item(P) & _ " PaperSize Name = " & _ ActiveReport1.Printer.PaperSizes.Name(P) Next P End Sub

Item

Description

PaperSizes Methods

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

Item

AR2Std | 402

Page 403: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Item method returns a reference to the PaperSize string at the specified index.

Return Type

String

Syntax

Function Item(Index As Variant) As String

Parameters

Example

'Returns a list of PaperSize Names and Values 'supported by the assigned printer and adds them to a 'listbox control Private Sub cmdGetPaperSizes_Click() For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1 lstPaperSizes.AddItem "PaperSize Value = " & _ ActiveReport1.Printer.PaperSizes.Item(P) & _ " PaperSize Name = " & _ ActiveReport1.Printer.PaperSizes.Name(P) Next P End Sub

Name

Description

Sets or returns a description for the specified paper size.

Return Type

String

Syntax

Function Name(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 control Private Sub cmdGetPaperSizes_Click() For P = 0 To _ ActiveReport1.Printer.PaperSizes.Count - 1

Name Type DescriptionIndex Variant Index of the requested paper size.

Name

Name Type DescriptionIndex Variant Index for the requested paper size name.

AR2Std | 403

Page 404: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

lstPaperSizes.AddItem "PaperSize Value = " & _ ActiveReport1.Printer.PaperSizes.Item(P) & _ " PaperSize Name = " & _ ActiveReport1.Printer.PaperSizes.Name(P) Next P End Sub

Parameters Parameter Properties

Parameters Methods

Parameter Properties

DefaultValue

Description

Sets or returns a string expression containing the query parameter's default value. Setting a default value will automatically fill in the value if none is specified.

Syntax

SELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data Type

String

Availability

Example

Text1.Text = "select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995%># and OrderID><%OrderID|Order ID:|11000%>"

Parameters

Parameter Properties

Property Data Type DescriptionDefault 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

Key

AR2Std | 404

Page 405: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Key

Description

Sets or returns the query parameter's key or name. The key is used to identify the parameter.

Note: The Key is a required property.

Syntax

SELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data Type

String

Availability

Example

Text1.Text = "select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995%># and OrderID><%OrderID|Order ID:|11000%>" Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim myprop As PropNode Dim i As Integer If Cancelled = True Then Me.Cancel Exit Sub End If Form1.EventListBox.Clear For i = 0 To Me.Parameters.Count - 1 Set myprop = New PropNode myprop.Name = Me.Parameters(i).Key myprop.Value = Me.Parameters(i).Value Form1.EventListBox.Properties.Add myprop Next End Sub

Prompt

Description

Sets or returns the string expression to be used as a prompt for the query parameter. If no prompt is specified, the Key will be used to identify the parameter in the parameters dialog box.

Syntax

SELECT <fields> FROM <table> WHERE <value> = "<% [Key Required] | [Optional Caption | Optional Default Value] %>"

Data Type

String

Availability

Design time N/A Run time Read / Write

Prompt

AR2Std | 405

Page 406: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Text1.Text = "select * from orders where OrderDate>=#<%Order Date|Enter Order date|1/1/1995%># and OrderID><%OrderID|Order ID:|11000%>"

Tag

Description

Sets or returns custom data attached to the query parameter.

Data Type

Variant

Availability

Example

Me.Parameters(0).Tag = "date" Me.Parameters(1).Tag = "string"

Value

Description

Sets or Returns the string expression to be substituted in the query.

Data Type

String

Availability

Example

Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim myprop As PropNode Dim i As Integer If Cancelled = True Then Me.Cancel Exit Sub End If Form1.EventListBox.Clear

Design time N/A Run time Read / Write

Tag

Design time N/a Run time Read / Write

Value

Design time N/a Run time Read / Write

AR2Std | 406

Page 407: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

For i = 0 To Me.Parameters.Count - 1 Set myprop = New PropNode myprop.Name = Me.Parameters(i).Key myprop.Value = Me.Parameters(i).Value Form1.EventListBox.Properties.Add myprop Next End Sub

Parameters Methods

Count

Description

Returns the number of available parameters in the query string.

Return Type

Integer

Syntax

Function Count() As Integer

Parameters

None

Example

Private Sub btnSetQuery_Click() myReport.DAODataControl1.RecordSource = Text1.Text PropList1.Clear For cnt = 0 To myReport.Parameters.Count - 1 PropList1.AddObject myReport.Parameters(cnt) If cnt = 0 Then PropList1.SelectObjects myReport.Parameters(0) End If Next btnRunReport.Enabled = True End Sub

Item

Description

Parameters Methods

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

AR2Std | 407

Page 408: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Returns the query parameter for the specified index.

Return Type

ARParameter

Syntax

Function Item(Index As Variant) As ARParameter

Parameters

Example

Private Sub ActiveReport_PromptDialogClosed(ByVal Cancelled As Boolean) Dim i As Integer If Cancelled = True Then Me.Cancel Exit Sub End If 'If data parameter is empty set the default date If Me.Parameters.Item(0).Value = "" Then Me.Parameters.Item(0).Value = "1/1/95" End If 'if orderID parameter is empty set the default to zero If Me.Parameters.Item(1).Value = "" Then Me.Parameters.Item(1).Value = "0" End If End Sub

Printer Printer Properties

Printer Methods

Printer Properties

Name Type DescriptionIndex Variant Index for the requested parameter.

Printer

Printer Properties

Property Data Type DescriptionCollate 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.

AR2Std | 408

Page 409: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Collate

Description

When printing multiple copies of the report, this property determines whether all the pages of the report should be printed before another copy of the report.

Note: This property has no effect when printing a single copy of the report. The collate property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

DataType

PrtCollate

Settings

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

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.

AR2Std | 409

Page 410: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

Private Sub ActiveReport_ReportStart() 'Prints all copies of a each page before moving to the next page Me.PageSettings.Collate = COLLATE_FALSE End Sub

ColorMode

Description

ColorMode determines whether to force printing to a color printer in color or monochrome. This property is dependent on whether the selected printer driver supports color printing.

Data Type

Integer

Settings

Availability

Example

rptInvoice.Printer.ColorMode=2

Copies

Description

Sets or returns the number of report copies to print. This is a logical number of copies that ActiveReports manages. If the printer does not support automatic multiple copies, ActiveReports will attempt to generate the copies by sending the report pages twice to the selected device.

Data Type

Integer

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

ColorMode

Value Description1 Print in Monochrome 2 Print in Color

Design time N/A Run time Read / Write

Copies

AR2Std | 410

Page 411: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

rptInvoice.Printer.Copies = 2

DeviceCopies

Description

Sets or returns the physical printer driver copies. This property works only with printers that support multiple copy printing.

Data Type

Integer

Availability

Example

rptInvoice.Printer.DeviceCopies = 2

DeviceName

Description

Sets or returns the unique name of the currently selected printer device. A list of valid printer device names is enumerated in the Devices string array property.

Note: You can set the DeviceName property to an empty string "" to enable a virtual printer mode where all properties and print methods will not make any printer calls. This is useful when your reports are compiled as ASP Active Server DLLs. The report will be formatted according to the printer properties you set whether there is a printer connected or not.

Data Type

String

Availability

Example

Debug.Print rptInvoice.Printer.DeviceName

Design time N/A Run time Read / Write

DeviceCopies

Design time N/A Run time Read / Write

DeviceName

Design time N/A Run time Read / Write

Devices

AR2Std | 411

Page 412: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Devices

Description

A zero-based string array property that enumerates all the available printer devices.

You can use this property to display a list of the devices for the report print destination from which the user can select.

Data Type

Array of Strings

Availability

Example

' Fill a listbox with the available print devices

•For i = 0 to NDevices 1 lstDevices.AddItem Devices(i) Next i

DisplayProgressDialog

Description

Determines whether the print progress dialog should be displayed while the report is printing.

Data Type

•Boolean Default is True

Availability

Example

rptInvoice.PrintReport False rptInvoice.Printer.DisplayProgressDialog = False

DPI

Description

DPI returns the resolution of the currently selected printer device.

Design time N/A Run time Read-Only

DisplayProgressDialog

Design time N/A Run time Read / Write

DPI

AR2Std | 412

Page 413: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Note: DPI is the number of Dots Per Inch.

Data Type

Long

Availability

Duplex

Description

Sets or returns the type of duplex action to use when printing out double sided reports. This property depends on the selected printer device because some printers are unable to support duplex printing.

Note: The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type

prtDuplex

Settings

Availability

Example

Private Sub ActiveReport_ReportStart() 'Sets a report up to be bound like a book 'Turn on MirrorMargins Me.PageSettings.MirrorMargins = True 'Sets gutter to .5 in to allow for binding Me.PageSettings.Gutter = 720 'Set duplex to print vertically on both sides Me.PageSettings.Duplex = ddDXVertical End Sub

FileName

Design time N/A Run time Read

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

FileName

AR2Std | 413

Page 414: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Sets or returns file name used to print to a file. If empty, ActiveReports prints to the printer.

Data Type

String

Availability

Example

rptSales.Printer.FileName = "C:\temp\sales.prn" rptSales.PrintReport False

FromPage

Description

Sets the starting page in a print job.

Note: A. When a report runs to completion, it will set the FromPage to 1 and ToPage to number of pages in the report. B. If you set FromPage and ToPage to 0 , the print dialog will disable the pages radio button and select "All Pages". C. If you set FromPage -1 and ToPage to -1, the selection radio is selected which means, print currently visible page. When report is not visible, this will print the first page. D. On return from PrintDialog method or PrintReport method FromPage and ToPage are set to the user selected values in the dialog.

Data Type

Long

Availability

Example

rptSales.Printer.FromPage = 1 rptSales.Printer.ToPage = 1 rptSales.PrintReport

hDC

Description

Returns a handle (from Microsoft Windows) to the printer's device context. This property is valid only after a print job has been started. It allows you to control the device using Windows API functions.

Run time Read / Write

FromPage

Design time N/A Run time Read / Write

hDC

AR2Std | 414

Page 415: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

Long

Availability

MaxPage

Description

MaxPage is used to properly set the total page count in the progress dialog when doing custom printing. For example, you can merge multiple reports and print them in a single job. ActiveReports will not know the total number of pages coming into the job. You need to set MaxPage so that the progress dialog will display the "n of m pages" message properly.

When printing a single report automatically, you do not need to set MaxPage since ActiveReports will set it to the number of pages in the report.

Data Type

Long

Availability

Example

rptSummary.Printer.StartJob ' Merge the two reports together rptSummary.Printer.MaxPage = rptSummary.Pages.Count + _ rptSales.Pages.Count ' Print the summary report For Each pg In rptSummary.Pages rptSummary.Printer.PrintPage pg Next ' Print the sales detail report For Each pg In rptSales.Pages rptSummary.Printer.PrintPage pg Next ' Close the job rptSummary.Printer.EndJob

NDevices

Description

NDevices returns the number of available printer devices. The printer device names are enumerated in the Devices property.

Data Type

Long

Run time Read

MaxPage

Design time N/A Run time Read / Write

NDevices

AR2Std | 415

Page 416: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

' Fill a listbox with the available print devices

•For i = 0 to NDevices 1 lstDevices.AddItem Devices(i) Next i

NPorts

Description

NPorts property returns the number of printer ports available (the ports to which the current device is attached). For example, if the current printer is attached to both LPT1: and FILE:, then NPorts returns 2. Available ports are enumerated in the Ports property.

Data Type

Long

Availability

Example

' Fill a listbox with the available printer ports

•For i = 0 to NPorts 1 lstPorts.AddItem Ports(i) Next i

Orientation

Description

Determines whether a report prints vertically or horizontally. It defaults to the current setting of the printer in Windows Control Panel.

Note: The Orientation property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type

PrtOrientation

Settings

Design time N/A Run time Read-Only

NPorts

Design time N/A Run time Read-Only

Orientation

AR2Std | 416

Page 417: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

' ActiveReports defaults to the current printer settings ' to change the default you need to set the orientation ' property in the ReportStart event Private Sub ActiveReport_ReportStart() me.PageSettings.Orientation = ddOLandscape End Sub

PaperBinNames

Description

Returns a zero-based array of names of PaperBins supported by the current device.

Data Type

Variant (Array of Strings)

Availability

Example

' Fill a listbox (lstPaperBins and lstPaperBinNames) ' with paperbin codes and paperbin names Dim i As Integer With ActiveReport1.Printer For i = 0 To Ubound(.PaperBins) lstPaperBins.AddItem .PaperBins(i) Next For I = 0 To Ubound(.PaperBinNames) lstPaperBinNames.AddItem .PaperBinName(i) Next End With

PaperBins

Description

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

PaperBinNames

Design time N/A Run time Read

PaperBins

AR2Std | 417

Page 418: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Returns a zero-based array of PaperBin codes supported by the current device.

Note: Use this array to get the valid codes for the PaperBin property. Many printer drivers do not support the table of codes listed in PaperBin. Instead, they define their own codes, making the standard codes invalid as a setting to that property.

Data Type

Variant (Array of Integers)

Availability

Example

' Fill a listbox (lstPaperBins and lstPaperBinNames) ' with paperbin codes and paperbin names Dim i As Integer With ActiveReport1.Printer For i = 0 To Ubound(.PaperBins) lstPaperBins.AddItem .PaperBins(i) Next For I = 0 To Ubound(.PaperBinNames) lstPaperBinNames.AddItem .PaperBinName(i) Next End With

PaperHeight

Description

PaperHeight sets or returns the length of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection.

Note: •This property is used only when PaperSize is set to 256 Custom. The PaperHeight property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type

Single

Availability

Example

Private Sub ActiveReport_ReportStart() ' Specify a custom paper size Me.PageSettings.PaperSize = 256 ' Sets the paper's width to 2 inches Me.PageSettings.PaperWidth = 1440 * 2 ' Sets the paper's height to 4 inches

Design time N/A Run time Read

PaperHeight

Design time Read / Write Run time Read / Write

AR2Std | 418

Page 419: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Me.PageSettings.PaperHeight = 1440 * 4 End Sub

PaperSizes

Description

Returns a reference to the collection of paper sizes the currently selected printer supports.

Data Type

PaperSizes

Availability

Example

Private Sub InitPaperSizes() Dim I As Integer

• For I = 0 To rptSummary.Printer.PaperSizes.Count 1 lstPaperSizes.AddItem rptSummary.Printer.PaperSizes(I) Next I End Sub

PaperWidth

Description

PaperWidth sets or returns the width of the paper used to print the report. It is used to set custom paper sizes that might not be available in the PaperSizes collection.

Note: • This property is used only when PaperSize is set to 256 Custom. The Duplex property is common to both the Printer object and the PageSettings object. So the property that is set last will be used by the report.

Data Type

Single

Availability

Example

Private Sub ActiveReport_ReportStart() ' Specify a custom paper size Me.PageSettings.PaperSize = 256 ' Sets the paper's width to 2 inches

PaperSizes

Design time N/A Run time Read / Write

PaperWidth

Design time N/A Run time Read / Write

AR2Std | 419

Page 420: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Me.PageSettings.PaperWidth = 1440 * 2 ' Sets the paper's height to 4 inches Me.PageSettings.PaperHeight = 1440 * 4 End Sub

Port

Description

Sets or returns the current printer port.

Data Type

String

Availability

Example

rptSummary.Printer.Port = "LPT1"

Ports

Description

A zero-based string array property that enumerates all the available ports. You can use this property to display a list of ports to the user.

Data Type

Array - string

Availability

Example

Dim prt As New DDActiveReports2.Printer ' Fill a listbox with the available printer ports

•For i = 0 to prt.NPorts 1 lstPorts.AddItem prt.Ports(i) Next i

PrintQuality

Port

Design time N/A Run time Read / Write

Ports

Design time N/A Run time Read / Write

PrintQuality

AR2Std | 420

Page 421: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

PrintQuality specifies the printer resolution used when printing the report.

Data Type

PrtQuality

Settings

Availability

Example

rptInvoice.PrintQuality = ddPQHigh

Status

Description

Returns the current print job status.

Data Type

JobStatus

Settings

Availability

Example

lblStatus.Caption = rptInvoice.Printer.Status

ToPage

Description

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

Value Mnemonic Description0 ddJSIdle Idle 1 ddJSPrinting Printing 2 ddJSCompleted Completed 3 ddJSAborted Aborted

Design time N/A Run time Read Only

ToPage

AR2Std | 421

Page 422: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sets the number for the last page to print in the specified report.

Note: A. When a report runs to completion, it will set the FromPage to 1 and ToPage to number of pages in the report. B. If you set FromPage and ToPage to 0 , the PrintDialog will disable the pages radio button and select "All Pages". C. If you set FromPage-1 and ToPage to -1, the selection radio is selected which means, print currently visible page. When report is not visible, this will print the first page. D. On return from PrintDialog method or PrintReport method, FromPage and ToPage are set to the user selected values in the dialog.

Data Type

Long

Availability

Example

rptSales.Printer.FromPage = 1 rptSales.Printer.ToPage = 1 rptSales.PrintReport

TrackDefault

Description

Specifies whether changes to the printer options will be reflected in Windows default printer.

Data Type

•Boolean 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 printer rptSummary.Printer.TrackDefault = True ' This form displays custom printer settings and ' modifies the printer object frmPrintSetup.Show vbModal

Design time N/A Run time Read / Write

TrackDefault

Design time N/A Run time Read / Write

TwipsPerPixelX, TwipsPerPixelY

AR2Std | 422

Page 423: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

TwipsPerPixelX, TwipsPerPixelY

Description

TwipsPerPixelX and TwipsPerPixelY return the number of twips per pixel horizontally (TwipsPerPixelX) or vertically (TwipsPerPixelY).

Data Type

Single

Availability

Printer Methods

AbortJob

Description

Aborts the current print job.

Return Type

Design time N/A Run time Read

Printer Methods

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

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

AR2Std | 423

Page 424: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

None

Syntax

Sub AbortJob()

Parameters

None

EndJob

Description

EndJob ends a previously started print job. You must call StartJob before calling this method. Otherwise, ActiveReports will fire an error event.

Return Type

None

Syntax

Sub EndJob()

Parameters

None

Example

rptSummary.Printer.StartJob "Sales Report" For Each pg In rptSales.Pages rptSales.Printer.PrintPage pg Next> ' Close the job rptSummary.Printer.EndJob

EndPage

Description

EndPage ends a previously started page. You must call StartPage before calling this method. Otherwise, ActiveReports will fire an error event.

Return Type

None

Syntax

Sub EndPage()

Parameters

None

Example

EndJob

EndPage

AR2Std | 424

Page 425: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Dim rpt As New ActiveReport1 Set PageEventHandler = rpt rpt.Show PrintTiled rpt, 3, 3 End Sub Sub PrintTiled(rpt As ActiveReport, rowCount As Integer, colCount As Integer) Dim row, col Dim pagex, pagey, pagew, pageh As Integer Dim margx, margy Dim pageNum As Integer rpt.Printer.StartJob "One Page" rpt.Printer.StartPage pagew = (rpt.Printer.PaperWidth

• ActiveReport1.PageSettings.LeftMargin ActiveReport1.PageSettings.RightMargin) / colCount• • pageh = (rpt.Printer.PaperHeight ActiveReport1.PageSettings.TopMargin _

ActiveReport1.PageSettings.BottomMargin) / rowCount For row = 0 To rowCount - 1 pagey = (pageh + SPACE_BETWEEN_PAGES) * row For col = 0 To colCount - 1 pagex = (pagew + SPACE_BETWEEN_PAGES) * col pageNum = row * colCount + col If (pageNum < rpt.Pages.Count) Then rpt.Printer.PrintPage rpt.Pages(pageNum), pagex, pagey, pagew, pageh End If Next Next rpt.Printer.EndPage rpt.Printer.EndJob End Sub Private Sub PageEventHandler_PageEnd() Dim pageObject As Canvas Set pageObject = PageEventHandler.Canvas pageObject.ForeColor = vbBlack pageObject.BackStyle = ddBKTransparent pageObject.PenStyle = 1 pageObject.PenWidth = 1 pageObject.DrawRect 0, 0, pageObject.Width, pageObject.Height End Sub

Escape

Description

Escape method is used to send raw escape sequences to the printer. Escape sequences allow you to modify custom print setting while printing.

•Escape sequences start with ASCII character 27 Chr$(27) followed by an escape sequence of characters.

Return Type

None

Syntax

Sub Escape(Code As String)

Parameters

Escape

Name Type DescriptionCode String The escape sequence string to be sent to the

printer

AR2Std | 425

Page 426: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

PrintPage

Description

Print method renders the specified canvas object to the printer. PrintPage can also be used to scale the page's output by indicating a left, top, width, and height value for the output.

Return Type

None

Syntax

Sub PrintPage(Canvas As Canvas, [left],[top],[width],[height])

Parameters

Example

rptSummary.Printer.StartJob "Sales Report" For Each pg In rptSales.Pages rptSales.Printer.PrintPage pg Next ' Close the job rptSummary.Printer.EndJob

PrintDialog

Description

Displays Windows standard print dialog. User settings will effect the printer settings in ActiveReports. You can center the dialog by specifying the parent window handle.

PrintDialog returns False if the user cancels the dialog.

PrintPage

Name Type DescriptionCanvas 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

AR2Std | 426

Page 427: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

None

Syntax

Function PrintDialog(ParentWindow As Boolean)

Parameters

Example

Private Sub btnPrint() ' Display the printer dialog centered within ' the current form rpt.Printer.PrintDialog frmReports.hWnd End Sub

SetupDialog

Description

Displays Windows printer setup dialog centered within the specified window. Any user changes will be reflected in the Windows default printer settings and ActiveReports printer object.

SetupDialog returns False if the user cancels the setup dialog.

Name Type DescriptionParentWindow Long Parent window handle to center the dialog

within the specified window.

SetupDialog

AR2Std | 427

Page 428: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

None

Syntax

Function SetupDialog(ParentWindow As Boolean)

Parameters

Example

Private Sub btnPrinterSetup() rpt.Printer.SetupDialog frmReports.hWnd End Sub

StartJob

Description

Starts a new printing job.

Return Type

None

Syntax

Sub StartJob(DocumentName As String)

Parameters

Name Type DescriptionParentWindow Long Parent window handle to center the dialog

within the specified window.

StartJob

Name Type Description

AR2Std | 428

Page 429: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

rptSummary.Printer.StartJob "Sales Report" For Each pg In rptSales.Pages rptSales.Printer.PrintPage pg Next ' Close the job rptSummary.Printer.EndJob

StartPage

Description

Starts a new page inside a print job. This is used to output multiple scaled canvas objects on the same page.

Return Type

None

Syntax

Dim rpt As New ActiveReport1 Set PageEventHandler = rpt rpt.Show PrintTiled rpt, 3, 3 End Sub Sub PrintTiled(rpt As ActiveReport, rowCount As Integer, colCount As Integer) Dim row, col Dim pagex, pagey, pagew, pageh As Integer Dim margx, margy Dim pageNum As Integer rpt.Printer.StartJob "One Page" rpt.Printer.StartPage pagew = (rpt.Printer.PaperWidth

• ActiveReport1.PageSettings.LeftMargin ActiveReport1.PageSettings.RightMargin) / colCount• • pageh = (rpt.Printer.PaperHeight ActiveReport1.PageSettings.TopMargin _

ActiveReport1.PageSettings.BottomMargin) / rowCount For row = 0 To rowCount - 1 pagey = (pageh + SPACE_BETWEEN_PAGES) * row For col = 0 To colCount - 1 pagex = (pagew + SPACE_BETWEEN_PAGES) * col pageNum = row * colCount + col If (pageNum < rpt.Pages.Count) Then rpt.Printer.PrintPage rpt.Pages(pageNum), pagex, pagey, pagew, pageh End If Next Next rpt.Printer.EndPage rpt.Printer.EndJob End Sub Private Sub PageEventHandler_PageEnd() Dim pageObject As Canvas Set pageObject = PageEventHandler.Canvas pageObject.ForeColor = vbBlack pageObject.BackStyle = ddBKTransparent

DocumentName String The name of the job as it would appear in the spooler's list of jobs.

StartPage

AR2Std | 429

Page 430: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

pageObject.PenStyle = 1 pageObject.PenWidth = 1 pageObject.DrawRect 0, 0, pageObject.Width, pageObject.Height End Sub

RptFields RptFields Properties

RptFields Methods

RptField Properties

Name

Description

Sets or returns the name of the field. It should be unique within the collection and is used as a key of the field in the collection.

Data Type

String

Availability

Example

Private Sub ActiveReport_DataInitialize() Fields.Add "OrderID" Debug.Print Fields("OrderID").Name End Sub

Tag

Description

Sets or returns a user defined value associated with the field object.

Data Type

RptFields

RptFields Properties

Property Data Type DescriptionName 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

AR2Std | 430

Page 431: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Variant

Availability

Value

Description

Sets or returns the current value of the field object.

Data Type

Variant

Availability

Example

Private Sub ActiveReport_FetchData(eof As Boolean) If rs.EOF Then Exit Sub Fields("Amount").Value = rs!Qty Eof = False End If End Sub

RptFields Methods

Add

Description

Adds a new custom field to the report's fields collection.

Run time Read / Write

Value

Run time Read / Write

RptFields Methods

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

AR2Std | 431

Page 432: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

RptField object

Syntax

Function Add(Name As String) As Object

Parameters

Example

Private Sub ActiveReport_DataInitialize() Fields.Add "Amount" End Sub

Count

Description

Returns the number of fields in the collection.

Return Type

Integer

Syntax

Function Count() As Integer

Parameters

None

Example

•For I = 0 To Fields.Count 1

Debug.Print Fields(I).Value Next

Item

Description

Returns the field object at the specified index. Item is the default method of the RptFields collection.

Return Type

Object

Syntax

Name Type DescriptionName String New field name, used as a key in the

collection.

Count

Item

AR2Std | 432

Page 433: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Function Item(Index As Object)

Parameters

Remove

Description

Removes the field at the specified index from the collection.

Return Type

None

Syntax

Sub Remove(Index)

Parameters

RemoveAll

Description

Removes all elements from the collection.

Return Type

None

Syntax

Sub RemoveAll()

Parameters

None

Sections Section Properties

Section Methods

Section Events

Name Type DescriptionIndex Variant The index of the entry to be retrieved. Can be

the ordinal index or the key of the field in the collection.

Remove

Name Type DescriptionIndex 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

AR2Std | 433

Page 434: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Section Properties

Property Data Type DescriptionBackColor 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 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

AR2Std | 434

Page 435: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BackColor

Description

Sets or returns the background color of a section. The setting will be reflected when the BackStyle property is set to ddBKNormal.

Data Type

OLE_COLOR

Availability

Example

rptAuthors.Detail.BackColor = vbBlue rptAuthors.Detail.BackStyle = ddBKNormal

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

AR2Std | 435

Page 436: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

BackStyle

Description

Sets or returns whether the section has a transparent or normal background.

Data Type

BackStyle

Settings

Availability

Example

rptAuthors.Detail.BackColor = vbBlue rptAuthors.Detail.BackStyle = ddBKNormal

CanGrow

Description

CanGrow determines whether the section height will be expanded if any of its contained controls grow beyond its area. If this property is set to False, the section contents will be clipped to the height of the section.

Data Type

Boolean

Availability

Example

rptAuthors.Detail.CanGrow = False rptAuthors.Detail.CanShrink = False

Value Mnemonic Description0 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

CanGrow

Design time Read / Write Run time Read / Write

CanShrink

AR2Std | 436

Page 437: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

CanShrink

Description

CanShrink determines whether the section height will be adjusted to fit its contents. When this property set to False the section will not shrink beyond the minimum value defined by its Height property.

Note: This property does not apply to PageHeader and PageFooter sections.

Data Type

Boolean

Availability

Example

rptAuthors.Detail.CanGrow = False rptAuthors.Detail.CanShrink = False

ColumnCount

Description

ColumnCount property sets or returns the number of newspaper columns in the report. This property can be used to print labels or phonebook style listings. The width of each column equals the PrintWidth of the report divided by the number of columns.

ColumnCount applies to Detail sections only. You can use the ColumnLayout property to force associated group headers and footers to follow the same column format as their detail section.

Data Type

Integer

Availability

Example

rptMenu.Detail.ColumnCount = 3 rptMenu.Detail.ColumnDirection = ddCDAcrossDown

ColumnDirection

Description

Design time Read / Write Run time Read / Write

ColumnCount

Design time Read / Write Run time Read / Write

ColumnDirection

AR2Std | 437

Page 438: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ColumnDirection property determines how ActiveReports should print the detail section in a multi-column report.

Data Type

ColumnDirections

Settings

Availability

Example

rptMenu.Detail.ColumnCount = 3 rptMenu.Detail.ColumnDirection = ddCDAcrossDown

ColumnLayout

Description

ColumnLayout property determines whether a group header section should use the same column layout of its detail section. When this property is True, the number of columns in a detail section will be reflected in the associated group headers and footers.

Note: This property applies to GroupHeader and GroupFooter sections only.

Data Type

Boolean

Availability

Example

rptShipments.GHLocation.ColumnLayout = False

Value Mnemonic Description0 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

ColumnLayout

Design time Read / Write Run time Read / Write

AR2Std | 438

Page 439: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

ColumnSpacing

Description

Sets or returns the space between columns in multicolumn report (in twips).

Data Type

Single

Availability

Example

rptAuthors.Detail.ColumnSpacing = .5 * 1440

Controls

Description

Returns a reference to the controls collection placed in the section

Data Type

Controls

Availability

Example

Private Sub Detail_BeforePrint() Dim ctrl As Control Dim sec As Section Set sec = ActiveReport1.Sections("Detail") For Y = 0 To sec.Controls.Count - 1 If TypeOf sec.Controls(Y) Is DDActiveReports2.Field Then If sec.Controls(Y).DataValue = 0 Then sec.Controls(Y).Visible = False Else sec.Controls(Y).Visible = True End If End If Next Y End Sub

DataField

ColumnSpacing

Design time Read / Write Run time Read / Write

Controls

Run time Read-Only

DataField

AR2Std | 439

Page 440: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

DataField applies to GroupHeader sections. It defines the binding field for a group within the detail body. This value is set to the name of any field in the Data Source or the name of a custom field added into the Fields collection. When this property is set, ActiveReports will create a new group each time the value of the bound field changes in the detail data records.

Note : ActiveReports will not sort the data automatically. The data source should be sorted to reflect the desired grouping of detail records.

When using XML the DataField must be set to a valid XPath string.

Note: The base path set by the RecordSetPattern is used as the starting node So if a control needs to use a higher level node, use "../" to move back a node.

Data Type

String

Availability

Example

RptLoans.ghClient.DataField = "CustomerID"

GroupValue

Description

This property applies to GroupHeader sections only. It is used to define custom grouping of detail records. You can use this value when you need to group your detail records on a calculated value that is not part of the detail fields in the data source. You would update this value in the Format event of the Detail section. ActiveReports reads the detail record, binds the fields in the Detail section, and then fires a Format event.

ActiveReports checks if 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 Service Pack 3. To bind a group to a custom value you can add a field to the Fields collection and bind the group to that field by setting the DataField property to its name.

Data Type

Variant

Availability

Example

Private Sub Detail_Format() ' Set the unbound group breaking value ghCountry.GroupValue = dcRptData.Recordset.Fields("Country").Value End Sub

Design time Read / Write Run time Read / Write

GroupValue

Design time Read / Write Run time Read / Write

AR2Std | 440

Page 441: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

GrpKeepTogether

Description

GrpKeepTogether determines whether group header and footer sections will print as a single block on the same page. The property defaults to ddGrpNone, which allows the group, block to be split across pages.

When you set this property to ddGrpAll, ActiveReports attempts to print the complete block on the same page without any page-breaks. When a complete block does not fit on a single page, it will be split across two or more pages.

The third option prevents any widowed group header sections. The group header will always print with at least one detail section.

Note: This property applies to GroupHeader sections only.

Data Type

GrpKeepTogether

Settings

Availability

Example

rptAuthors.GHCategory.GrpKeepTogether = True

Height

Description

Sets or returns the section's height in twips.

Note: A section's height can only be changed in the section's Format event, the ReportStart event, or before the report is run. Changing the height will not automatically reposition the controls inside the section.

Data Type

Single

Availability

GrpKeepTogether

Value Mnemonic Description0 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

Design time Read / Write Run time Read / Write

AR2Std | 441

Page 442: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

RptMain.GHEmployee.Height = 2*1440

IsRepeating

Description

Returns true if the section is repeated from last page.

Data Type

Boolean

Availability

Example

Private Sub ghCustomer_Format() If ghCustomer.IsRepeating Then lblContinued.Caption = "Continued" Else lblContinued.Caption = "" End If End Sub

KeepTogether

Description

KeepTogether property determines whether a section should print in its entirety on the same page. When you set this property to True, the section will print on the same page without any page breaks. A False setting allows the section to be split across two or more pages.

Note: This property applies to GroupHeader, GroupFooter and Detail sections only.

Data Type

Boolean

Availability

Example

rptInvoice.Detail.KeepTogether = False

Name

IsRepeating

Run time Read

KeepTogether

Design time Read / Write Run time Read / Write

Name

AR2Std | 442

Page 443: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

Sets or returns the unique identifying name of the section.

Data Type

String

Availability

NewColumn

Description

NewColumn determines whether ActiveReports should insert a column-break before and/or after printing the section.

Note: This property does not apply to ReportHeader, ReportFooter, PageHeader or PageFooter sections.

Data Type

NewPageConstants

Settings

Availability

Example

Private Sub Detail_Format() Static RNumber As Long RNumber = RNumber + 1 If RNumber = 6 Then 'If there are 6 records in the column 'it will add a new column and reset the counter Detail.NewColumn = ddNPAfter RNumber = 0 Else Detail.NewColumn = ddNPNone 'This turns off the Add New column End If End Sub

NewPage

Design time Read / Write Run time Read

NewColumn

Value Mnemonic Description0 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

NewPage

AR2Std | 443

Page 444: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

NewPage determines whether ActiveReports should insert a page-break before and/or after printing the section.

Note: This property does not apply to PageHeader or PageFooter sections.

Data Type

NewPageConstants

Settings

Availability

Example

Private Sub Detail_Format() Static RNumber As Long RNumber = RNumber + 1 If RNumber = 6 Then 'If there are 6 records on the page 'it will add a new page and reset the counter Detail.NewPage = ddNPAfter RNumber = 0 Else Detail.NewPage = ddNPNone 'This turns off the Add New page End If End Sub

PrintAtBottom

Description

Sets or returns whether or not the GroupFooter or ReportFooter should be printed at the bottom of the page.

Note: If PrintAtBottom is set to true and the report has a PageFooter, the GroupFooter or ReportFooter will be printed above the PageFooter.

Note: Setting more than one section to print at the bottom will cause the subsequent footer sections to be printed on separate pages.

Data Type

Boolean

Availability

Value Mnemonic Description0 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

Design time Read / Write Run time Read / Write

AR2Std | 444

Page 445: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub GroupFooter1_Format() 'Prints GroupFooter at the bottom of the page GroupFooter1.PrintAtBottom = True End Sub

Repeat

Description

Repeat property determines whether a GroupHeader section should be printed again before its associated detail section when the detail section is broken across multiple pages or columns.

Data Type

RepeatStyle

Settings

Availability

Example

rptSales.GHDepartments.Repeat = ddRepeatAll

Script

Description

Sets or returns an ActiveScript string for the report to use when making modifications to the report at runtime. The scripts run immediately after their matching ActiveReports' events and take precedence over the code inside the project.

If reports with scripts are saved to XML, the scripts are incorporated into the XML file. Changes to scripts in the XML file can be made and then loaded back into a report project to show the changes. This allows reports to be modified without requiring the project to be recompiled.

The report's section script property allows access to the following scripting events.

Repeat

Value Mnemonic Description0 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

AR2Std | 445

Page 446: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sub OnFormat() end sub Sub OnBeforePrint() end sub Sub 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 Type

String

Availability

Example

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

Type

Description

Type property returns the type of the section.

Data Type

SectionType

Settings

Design time Read /Write Run time Read / Write

Type

Value Mnemonic Description0 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

AR2Std | 446

Page 447: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Availability

Example

Private Sub ActiveReport_ReportStart() Dim ctl As Object For x = 0 To Me.Sections.Count - 1 If Me.Sections(x).Type = 2 Then Set ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label") ctl.Caption = "Page Header" ctl.Top = 0 ctl.Left = 0 ctl.Height = 500 ctl.Width = 2000 ctl.BackStyle = vbNormal ctl.BackColor = vbBlue ElseIf Me.Sections(x).Type = 6 Then Set ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label") ctl.Caption = "Detail Section" ctl.Top = 0 ctl.Left = 0 ctl.Height = 500 ctl.Width = 2000 ctl.BackColor = vbRed ctl.BackStyle = vbNormal ElseIf Me.Sections(x).Type = 3 Then Set ctl = Me.Sections(x).Controls.Add("DDActiveReports2.Label") ctl.Caption = "Page Footer" ctl.Top = 0 ctl.Left = 0 ctl.Height = 500 ctl.Width = 2000 ctl.BackColor = vbGreen ctl.BackStyle = vbNormal End If Next End Sub

UnderlayNext

Description

UnderlayNext property determines whether the section should print underneath the following section. The following section will start printing starting from the top coordinate of the under-laid section instead of the bottom coordinate.

Note: This property applies to GroupHeader sections only.

Data Type

Boolean

Availability

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

Design time Read / Write

AR2Std | 447

Page 448: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

RptStyles.GHImported.UnderlayNext = True

Visible

Description

Visible property determines whether the section is to be printed or not.

Data Type

Boolean

Availability

Example

If doSummary = True then rptInvolice.Detail.Visible = False End if

Section Methods

Add

Description

Creates a new section of a specified type (detail, group header, etc.) and adds it to the report.

Run time Read / Write

Visible

Design time Read / Write Run time Read / Write

Section Methods

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

AR2Std | 448

Page 449: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

This method can be used at design time (when creating add-ins that dynamically create reports) or run time (when creating or modifying a report).

Note: When adding a ReportHeader, PageHeader, or GroupHeader, the section's footer must also be added.

Return Type

Section object

Syntax

Sub Add(Name As String, insertionIndex As Long, Type As SectionType, height As Long)

Parameters

Example

Dim ar As rptTemplate Set ar = New rptTemplate ' Add A Group Header Section ar.Sections.Add "ghCustomer", 1, ddSTGroupHeader, 370 ' And always add a matching group footer ar.sections.Add "gfCustomer", 3, ddSTGroupFooter, 370 ' Bind the section Ar.Sections("ghCustomer").DataSource = "dcRptData" Ar.Sections("ghCustomer").DataField = "CustomerName"

Count

Description

Count method returns the number of section object in the Sections collection.

Return Type

Integer

Syntax

Function Count() As Integer

Parameters

None

Item

Description

Item method returns a reference to the section object at the specified index.

Name Type DescriptionName 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

AR2Std | 449

Page 450: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

Section object

Syntax

Function Item(i ndex As Variant) As Object

Parameters

Refresh

Description

Updates the section when using a designer control (Professional Version only).

Return Type

none

Syntax

Sub Refresh()

Parameters

None

Remove

Description

Remove method removes the section at the specified index from the Sections collection.

Return Type

None

Syntax

Sub Remove(index As Variant)

Parameters

Section Events

Name Type DescriptionIndex Variant The index of the section in the collection or

unique name of the section.

Refresh

Remove

Name Type DescriptionIndex Variant The index of the section in the collection or

unique name of the section.

Section Events

AR2Std | 450

Page 451: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

AfterPrint

Description

This event fires after the section is rendered to the canvas.

Although Detail AfterPrint originally started off as a very important event prior to Version 1 Service Pack 3, it is rarely used in any of the newer builds of ActiveReports. When you are placing code in the section events, chances are you are going to be placing your code in the Format or BeforePrint events. This event is still useful for drawing on the canvas after text has already been rendered to the canvas.

Syntax

Sub AfterPrint()

Example

Private Sub Detail_AfterPrint() ActiveReport1.Canvas.DrawText "Private", 4 * 1440, _ 4 * 1440, 4 * 1440, 4 * 1440 End Sub

BeforePrint

Description

This event fires before the section is rendered to the canvas.

The growing and shrinking of the section and all controls contained in a section have already taken place by the time this event fires. Use this section to resize any controls if needed.

Since all controls and section growth have already taken place by the time this event fires, this event may be used to get an accurate height of the section or any controls in it. You may resize any controls in this event, but you cannot resize the section itself.

Syntax

Sub BeforePrint()

Example

Private Sub ghCountry_BeforePrint() txtPctTotal.DataValue = txtSales.DataValue / txtGrandTotal.DataValue

Event DescriptionAfterPrint This event fires after the section is rendered to the

canvas.

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

AR2Std | 451

Page 452: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

End Sub

Format

Description

This event fires after the data is loaded and bound to the controls contained in a section, but before the section is rendered to the canvas.

The format event is the only event where the section's height may be changed. This section may be used to set or change the properties of any controls, or load subreport controls with subreports.

If the CanGrow or CanShrink property of any control contained within a section, or the section itself, is set to true, all of the growing and shrinking of controls contained in this section, and the section itself, takes place in this event. Because of this, information about a control or section's height cannot be obtained in this event.

Syntax

Sub Format()

Example

Private Sub Detail_Format() ' If sales value is > 10000 Then color the field red If txtSales.DataValue > 10000 Then TxtSales.ForeColor = vbRed End If End Sub

TOC TOC Properties

TOC Methods

TOCEntry Properties

TOC Properties

Count

Description

Format

TOC

TOC Properties

Property Data Type DescriptionCount 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

AR2Std | 452

Page 453: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Count property returns the number of TOC entries.

Data Type

Long

Availability

CurrentPage

Description

Sets or returns the current page in the viewer. Works in both the built-in viewer and the Viewer control. You can use this property to navigate through the viewer pages and display the current page number.

Data Type

Long

Availability

Example

' Implement a First, Previous, Next, and Last Page ' command buttons and ' update a current page number label. ' Create a form with a viewer control named arv, ' 4 command buttons array named btnMove(0..4) ' Label named lblPage Private Sub btnMove_Click(Index As Integer) Select Case Index Case 0 ' First Page If arv.Pages.Count > 0 Then arv.TOC.CurrentPage = 0 Case 1 ' Previous Page If arv.TOC.CurrentPage > 0 Then arv.TOC.CurrentPage = arv.TOC.CurrentPage-1 End If Case 2 ' Next Page If arv.TOC.CurrentPage < arv.Pages.Count-1 Then arv.TOC.CurrentPage = arv.TOC.CurrentPage + 1 End If Case 3 ' Last Page If arv.Pages.Count > 0 Then arv.TOC.CurentPage = arv.Pages.Count-1 End If End Select End Sub

History

Run time Read

CurrentPage

Run time Read

History

AR2Std | 453

Page 454: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Description

History property returns a reference to the navigation history object.

Data Type

History

Availability

Example

' Command button implementations of a custom toolbar Private Sub btnBack() arv.TOC.History.Back End Sub Private Sub btnForward() arv.TOC.History.Forward End Sub

SelectedItem

Description

Returns the selected item in a table of contents tree. This property is read-only and available at run time.

Data Type

Long

Availability

TOC Methods

Run time Read

SelectedItem

Run time Read

TOC Methods

Method DescriptionAdd 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)

AR2Std | 454

Page 455: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Add

Description

Add method adds a new node to the table of contents. The entry text is a directory path-like string, which determines the parent-child relationship within the content tree. For example, inserting the string "Vendor 1" and later adding "Vendor 1\Product 1" makes the later entry a child of the "Vendor 1" entry. The "\" is used as a parent child separator. The text entered after the "\" will be displayed in an expandable node in the TOC window. When new items are added to the table of contents, the report uses the top of the section used to add the item as its reference point. For example, if an item was added in the GroupFooter, clicking on the table of contents item will take you to the top of the item's GroupFooter.

Note: You can use "\\" to insert a back-slash literal character.

Return Type

None

Syntax

Sub Add(text As String)

Parameters

Example

Private Sub ghCategory_AfterPrint() TOC.Add txtCategory.Text End Sub Private Sub Detail_BeforePrint() ' Add a TOC entry for each printed product ' within its category TOC.Add txtProduct.Text & "\" & txtCategory.Text End Sub

GotoPage

Description

Displays the specified page in the report preview window.

Return Type

None

Syntax

Sub GotoPage(PageNumber As Long)

Parameters

RemoveAll Removes all entries from the table of contents.

Sub RemoveAll()

Add

Name Type DescriptionText String Text string identifying the table of contents

entry.

GotoPage

AR2Std | 455

Page 456: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

' Implementation of custom First Page, Last Page buttons Private Sub btnFirstPage() ' Goto First Page arv.TOC.GotoPage 0 End Sub Private Sub btnLastPage() ' Goto Last Page arv.TOC.GotoPage arv.Pages.Count - 1 End Sub

Item

Description

Returns the table of content entry at the specified index.

Return Type

String

Syntax

Function 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).Name Me.Caption = Me.Caption & " Page " & arv.TOC(ItemIndex).pageNumber + 1 End Sub

Navigate

Description

Navigate method displays the page containing the requested entry.

Return Type

None

Syntax

Sub Navigate(tocEntry As String)

Name Type DescriptionPageNumber Long The page number to be displayed in the

viewer

Item

Name Type DescriptionIndex Long The index of the entry to be retrieved.

Navigate

AR2Std | 456

Page 457: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Parameters

Example

Private Sub GotoProduct() ' Display a form to get category and product names frmGotoProduct.Show vbModal arv.TOC.Navigate sCategory & "\" & sProductName End Sub

PageNumber

Description

Returns the pages number associated with the specified table of contents entry. You can use this property to build a Table of Contents from all entries in the TOC object. You can output the table of contents into a canvas object and insert it at the beginning of your report.

Note: This method has been replaced with Toc.Item(index).PageNumber. This method is for backwards compatibility with ActiveReports 1.0.

Return Type

String

Syntax

Function PageNumber(index As Long)

Parameters

Remove

Description

Removes the specified entry from the table of contents.

Return Type

None

Syntax

Sub Remove(tocEntry As String)

Parameters

Name Type DescriptiontocEntry String The table of contents entry string.

PageNumber

Name Type DescriptionIndex Variant The index of the entry to be retrieved.

Remove

Name Type DescriptiontocEntry String The table of contents entry string.

AR2Std | 457

Page 458: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

RemoveAll

Description

Clears all entries from the table of contents.

Return Type

None

Syntax

Sub RemoveAll()

Parameters

None

TOCEntry Properties

Name

Description

Sets or returns the name for the specified item in the TOC.

Data Type

String

Availability

Example

Private Sub ActiveReport_TOCSelChange(ByVal ItemIndex As Long) Me.Caption = TOC.Item(ItemIndex).Name End Sub

PageNumber

Description

RemoveAll

TOCEntry Properties

Property Data Type DescriptionName 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

AR2Std | 458

Page 459: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sets or returns the page number for the specified item in the TOC.

Note: The page numbers begin with 0.

Data Type

Long

Availability

Example

Private Sub ActiveReport_TOCSelChange(ByVal ItemIndex As Long) Me.Caption = "Page " & TOC.Item(ItemIndex).pageNumber End Sub

PageOffSet

Description

Sets or returns the TOC entry's top position in twips. The PageOffSet measures the distance between the TOC entry and the page's top margin.

Data Type

Integer

Availability

Tools and Toolbar DDToolbar Properties

DDToolbar Methods

DDTools Methods

DDTool Properties

DDTool Methods

DDToolbar Properties

Run time Read / Write

PageOffSet

Run time Read / Write

Tools and Toolbar

DDToolbar Properties

Property Data Type DescriptionDisplayTooltips Boolean Determines whether to display screen tooltips

when the mouse hovers over a tool.Font StdFont Specified the Font properties of the tool.

AR2Std | 459

Page 460: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

DisplayTooltips

Description

Determines whether to display screen tooltips when the mouse hovers over a tool.

Data Type

Boolean

Availability

Example

arv.Toolbar.DiaplayTooltips = True

Font

Description

Defines the font properties used to display the tools.

Data Type

StdFont

Availability

Example

Private Sub ActiveReport_ReportStart() arv.Toolbar.Font.Name = "Tahoma" arv.Toolbar.Font.Size = "10" End Sub

Tools

Description

Returns a collection of the tools that are displayed on the toolbar. The tools collection contains 14 standard built-in tools that cannot be removed.

Tools DDTools A collection of the tool objects that displayed in the toolbar.

DisplayTooltips

Design time Read / Write Run time Read / Write

Font

Design time Read / Write Run time Read / Write

Tools

AR2Std | 460

Page 461: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Data Type

DDTools

Availability

Example

Private Sub btnViewReport_Click() Load frmRptViewer frmRptViewer.arv.TOCVisible = True frmRptViewer.arv.ToolBar.Tools.Add "Printer Setup" frmRptViewer.Show End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

DDToolbar Methods

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 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 DescriptionRefresh Causes the toolbar to repaint itself to reflect changes in the

tools collection.

Sub Refresh()

Refresh

AR2Std | 461

Page 462: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Refresh

Description

Causes the toolbar to repaint itself to reflect changes in the tools collection.

Return Type

None

Syntax

Sub Refresh()

Parameters

•None The toolbar will reflect the changes in its tools collection.

DDTools Methods

Add

Description

Adds a new tool to the tools collection while giving access to the tool's properties.

Note: Remember to set the ID property of a tool after adding or inserting it into the toolbar. The ToolbarClick event will not fire if the tool does not have its ID set. It is also important to make sure the ID property is not the same as one of the other toolbar items.

Below is a list of predefined tool IDs:

DDTools Methods

Method DescriptionAdd 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 IDTable Of Contents 40008 Print 32773 Find 32774 Single Page 40014 Multiple Page 40013 Zoom Out 40006 Zoom In 32775 Zoom 32771

AR2Std | 462

Page 463: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Return Type

None

Syntax

Sub Add(Caption As String)

Parameters

Example

Private Sub btnAddTools_Click() ' arv is the name of an ActiveReports Viewer control With arv.Toolbar.Tools .Addex("Printer Setup").AddIcon("Printer.ico") ' Must set the ID property

• .Item(.Count 1).ID = 999 End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

AddEx

Description

Adds a new tool to the tools collection.

Note: Remember to set the ID property of a tool after adding or inserting it into the toolbar. The ToolbarClick event will not fire if the tool does not have its ID set.

Return Type

None

Syntax

Sub Add(Caption As String)

Parameters

Example

Previous Page 40004 Next Page 40005 Page Edit 32772 History Backward 32776 History Forward 40010

Name Type DescriptionCaption String The tool caption string.

AddEx

Name Type DescriptionCaption String The tool caption string.

AR2Std | 463

Page 464: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Private Sub btnAddTools_Click() ' arv is the name of an ActiveReports Viewer control With arv.Toolbar.Tools .Add "Printer Setup" ' Must set the ID property

• .Item(.Count 1).ID = 999 End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

Count

Description

Returns the number of tools in the collection.

Return Type

Long

Syntax

Function Count() As Long

Parameters

None

Example

Private Sub btnAddTools_Click() ' arv is the name of an ActiveReports Viewer control With arv.Toolbar.Tools .Add "Printer Setup" ' Must set the ID property

• .Item(.Count 1).ID = 999 End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

Insert

Description

Inserts a new tools into the tools collection at the specified index.

Return Type

None

Syntax

Count

Insert

AR2Std | 464

Page 465: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sub Insert(Index As Integer, Caption As String)

Parameters

Example

Private Sub AddPrinterSetup() ' Inserts a new Printer Setup tool ' after the Print Tool arv.Toolbar.Tools.Insert 2, "Printer Setup" arv.Toolbar.Tools(3).ID = 999 End Sub

Item

Description

Returns a reference to the tool object at the specified index.

Return Type

DDTool

Syntax

Function Item(Index As Integer) As DDTool

Parameters

Example

Private Sub btnAddTools_Click() ' arv is the name of an ActiveReports Viewer control With arv.Toolbar.Tools .Add "Printer Setup" ' Must set the ID property .Item(.Count-1).ID = 999 End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

DDTool Properties

Name Type DescriptionIndex 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

Name Type DescriptionIndex Integer Index of the tool to return

DDTool Properties

AR2Std | 465

Page 466: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Caption

Description

Sets or returns caption string of the tool, command button or checkbox.

Data Type

String

Availability

Example

Private Sub btnAddTools_Click() arv.ToolBar.Tools.Add "Printer Setup" End Sub Private Sub arv_ToolbarClick(ByVal tool As DDActiveReportsViewer2Ctl.DDTool) If tool.Caption = "Printer Setup" Then arv.Printer.SetupDialog End If End Sub

Checked

Description

Determines the checked state of a checked button tool. This property applies to custom checked button tool added using Add or Insert.

Data Type

Boolean

Property Data Type DescriptionCaption 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

Design time Read / Write Run time Read / Write

Checked

AR2Std | 466

Page 467: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

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 With End Sub

Enabled

Description

Determines whether a tool is enabled (True) or disabled (False).

Data Type

Boolean

Availability

Example

' Disable the Print Button arv.Toolbar.Tools(2).Enabled = False

ID

Description

Returns the tool id in the tools collection. Tools ID number in between 5100 and 5200 are reserved for the built-in tools. You can change the behavior of built-in tools by changing the ID property and handling the ToolbarClick event.

Data Type

Long

Availability

Design time Read / Write Run time Read / Write

Enabled

Design time Read / Write Run time Read / Write

ID

Design time Read / Write Run time Read / Write

AR2Std | 467

Page 468: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private CancelJob As Boolean Private Const CONST_PRINTTOOLID As Long = 999 Private Sub ActiveReport_ReportStart() Dim bReturn As Boolean Dim cnt As Integer ' This overrides the print tool For cnt = 0 To Me.Toolbar.Tools.Count-1 If "&Print..." = Me.Toolbar.Tools(cnt).Caption Then Me.Toolbar.Tools(cnt).ID = CONST_PRINTTOOLID End If Next cnt End Sub ' This catches the print tool and shows a custom printdialog, and prints manually Private Sub ActiveReport_ToolbarClick(ByVal tool As DDActiveReports2.DDTool) Dim bReturn As Boolean If CONST_PRINTTOOLID = tool.ID Then ' They clicked the "&Print..." button bReturn = Me.Printer.PrintDialog(Me.hWnd) If bReturn Then Me.PrintReport False ElseIf Not bReturn Then CancelJob = True End If End If End Sub ' This enables the Print tool after the report finishes processing. Private Sub ActiveReport_ReportEnd() Dim cnt As Long For cnt = 0 To Me.Toolbar.Tools.Count-1 If "&Print..." = Me.Toolbar.Tools(cnt).Caption Then Me.Toolbar.Tools(cnt).Enabled = True End If Next cnt End Sub

Style

Description

Sets or returns the type of button to use. Setting the style to 0 will show the button with just an Icon. Setting the style to 1 will show the button with an icon and caption.

Data Type

Integer

Settings

Availability

Style

Value Description 0 Show just the icon. 1 Show both the icon and the caption.

Design time Read / Write

AR2Std | 468

Page 469: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

arv.ToolBar.Tools.Insert 4, "O&pen" arv.ToolBar.Tools.Item(4).AddIcon LoadPicture(App.Path & "\openfold.ico") arv.ToolBar.Tools.Item(4).Tooltip = "Open RDF File" arv.ToolBar.Tools.Item(4).Style = 1

Tooltip

Description

Sets or returns the tooltip help text to be displayed when the mouse hovers over the tool.

Data Type

String

Availability

Example

' Add an Export to RTF button arv.Toolbar.Tools.Add "RTF" arv.Toolbar.Tools(arv.Toolbar.Tools.Count-1).Tooltip = _ "Export Report to RTF"

Type

Description

Sets or returns the specified tool's type.

Data Type

Integer

Availability

Settings

Run time Read / Write

Tooltip

Design time Read / Write Run time Read / Write

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

AR2Std | 469

Page 470: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Example

Private Sub AddTools() With arv.Toolbar .Tools.Add "Display Tooltips" ' Checked Button .Tools(.Tools.Count-1).Type = 1 .Tools(.Tools.Count-1).Checked = .DisplayTooltips End With End Sub

Visible

Description

Determines whether the tool is visible on the toolbar or not.

Data Type

Boolean

Availability

Example

arv.Toolbar.Tools(2).Visible = False

DDTool Methods

AddIcon

Description

Attaches an icon to the indicated or added tool.

Return Type

None

Syntax

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

Method DescriptionAddIcon Attaches an Icon to the indicated tool.

Sub AddIcon(Picture As StdPicture)

AddIcon

AR2Std | 470

Page 471: AR2Std - DynaSCAPE Software · ActiveReports 2.0 Architectural Overview 29 Chapter 1 - Installation 31 Installation Steps 31 Sample Reports 32 Client Distribution 32 Chapter 2 - Using

Sub AddIcon(Picture As StdPicture)

Parameters

Example

Private Sub addButtonsToARV() 'Insert the Save button in the sixth 'position and assign it an icon and 'disable it arv.ToolBar.Tools.Insert 5, "&Save" arv.ToolBar.Tools.Item(5).AddIcon LoadPicture("tfsave.ico") arv.ToolBar.Tools.Item(5).Tooltip = "Save Report to RDF" arv.ToolBar.Tools.Item(5).Enabled = False End Sub

Name Type DescriptionPicture StdPicture Path or reference to the icon file.

AR2Std | 471