dessoft - reports, how to do it

13
© 2010 DesSoft Reports Version: 1.0.0

Upload: dessoft-control-and-instrumentation-engineering-software

Post on 24-May-2015

66 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: DesSoft - Reports, How to do it

© 2010 DesSoft

Reports

Version: 1.0.0

Page 2: DesSoft - Reports, How to do it

All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, ormechanical, including photocopying, recording, taping, or information storage and retrieval systems - without thewritten permission of the publisher.

Products that are referred to in this document may be either trademarks and/or registered trademarks of therespective owners. The publisher and the author make no claim to these trademarks.

While every precaution has been taken in the preparation of this document, the publisher and the author assume noresponsibility for errors or omissions, or for damages resulting from the use of information contained in this documentor from the use of programs and source code that may accompany it. In no event shall the publisher and the author beliable for any loss of profit or any other commercial damage caused or alleged to have been caused directly orindirectly by this document.

Printed: February 2010 in Eldoraigne, South Africa

Reports

© 2010 DesSoft

Publisher Special thanks to:

All the people who contributed to this document.DesSoft

Page 3: DesSoft - Reports, How to do it

3Contents

© 2010 DesSoft

Table of Contents

Foreword 0

Section I VB Scripting 6

Section II Exercise 12

Index 0

Page 4: DesSoft - Reports, How to do it
Page 5: DesSoft - Reports, How to do it

Reports

DesSoft - Engineering Design Documentation Software

Section

I

Page 6: DesSoft - Reports, How to do it

6 Reports

© 2010 DesSoft

1 VB ScriptingVB Scripting is used in reports to dynamically display data in a specific way if it satisfies acertain criteria defined in the VB Script.

VB Scripts can either be defined per band (Detail Band, Page Header etc) or for the report asa whole.

VB Script is NOT case sensitive.

Example 1

In this example we will use the Instrument Index report.We will change the background color of the Detail Band to RED everywhere the Datasheetvalue is null. In other words, whenever an instrument doesn't have a datasheet, the data ofthat instrument will be highlighted in RED.This script will be entered in the Detail Band due to the fact that the data is calculated/retrieved in the Detail Band.

The script will look like this:

if isnull(Datasheet) thenDetail.BackColor=vbRed

elseDetail.BackColor=vbWhite

end if

The result will look like this:

Example 2

In this example we will use the Instrument Costs report.There are 2 things we would like the report to do:

1. We want the report to color the Unit Cost column red whenever the cost of an instrument isR150,00 or more.

2. Further more we want the report to display "TBA" (To Be Advised) in the Manufacturer,Model and Unit Cost columns whenever any of these have not been determined. The "TBA

Page 7: DesSoft - Reports, How to do it

7VB Scripting

© 2010 DesSoft

" text must be in blue and centered in the field. If the Manufacturer, Model and Unit Costcolumns contain data, then the text must be in black and aligned to the left, except for theUnit Cost column which must always be centered.

The script for number 1 above, will be entered in the Detail Band and will look like this:

If Cost>=150 thenCostCtl.BackColor=vbRed

elseCostCtl.BackColor=vbWhite

end if

"CostCtl" is the Design Name of the textbox that will display the Cost.

The script for number 2 above, will be entered in the Detail Band and will look like this:

If isnull(Manufacturer) thenManufacturerCtl.text="TBA"ManufacturerCtl.ForeColor=vbBlueManufacturerCtl.Align="CenterMiddle"

elseManufacturerCtl.text=ManufacturerManufacturerCtl.ForeColor=vbBlackManufacturerCtl.Align="LeftMiddle"

end if

"ManufacturerCtl" is the Design Name of the textbox that will display theManufacturer.

If isnull(Model) thenModelCtl.text="TBA"ModelCtl.ForeColor=vbBlueModelCtl.Align="CenterMiddle"

elseModelCtl.text=ModelModelCtl.ForeColor=vbBlackModelCtl.Align="LeftMiddle"

end if

"ModelCtl" is the Design Name of the textbox that will display the Model.

If isnull(Cost) thenCostCtl.text="TBA"CostCtl.ForeColor=vbBlue

elseCostCtl.text=CostCostCtl.ForeColor=vbBlack

end if

"CostCtl" is the Design Name of the textbox that will display the Cost.

The result will look like this:

Page 8: DesSoft - Reports, How to do it

8 Reports

© 2010 DesSoft

Page 9: DesSoft - Reports, How to do it

9VB Scripting

© 2010 DesSoft

Page 10: DesSoft - Reports, How to do it
Page 11: DesSoft - Reports, How to do it

Reports

DesSoft - Engineering Design Documentation Software

Section

II

Page 12: DesSoft - Reports, How to do it

12 Reports

© 2010 DesSoft

2 Exercise

Build the Card Layout report found in your Project Folder by using the Card Layout query inthe Query module.Call your report "Advanced Card Layout".

Achieve the following through VB Scripting:

1. Record the TOTAL amount of channels per I/O type on the report.2. Record the amount of AVAILABLE channels per I/O type on the report.3. Record the percentage of SPARE channels per I/O type on the report.4. Record the total amount of each type of I/O card on the report.5. Every channel that is spare, must display "SPARE" in RED.6. Revise the report according to the one in your Project Folder.

Page 13: DesSoft - Reports, How to do it

13Exercise

© 2010 DesSoft