I am creating a vb application for viewing crystal report.
I want to change the page layout of the report at runtime from the application,ie, the user of the application will have the liberty to change the report layout.
is it possible?
I don't know exactly what you want to do but it's possible using the Report Designer Component (RDC).
In VB6, go to Project, Reference and choose:
Crystal Report 8 ActiveX Designer Run Time Library
There are samples on the CrystalDecision web site.
You can create fields on the fly, groups, headers, change sorting, ... allmost all the things you can do in the design environment of Crystal Report, you can do it at runtime.
It looks like this:
(DECLARATION)
Public crxApplication As New CRAXDRT.Application
Public crxReport As CRAXDRT.Report
Public crxDatabase As CRAXDRT.Database
Public crxDatabaseTables As CRAXDRT.DatabaseTables
Public crxDatabaseTable As CRAXDRT.DatabaseTable
Public crxParamDefs As CRAXDRT.ParameterFieldDefinitions
Public crxParamDef As CRAXDRT.ParameterFieldDefinition
Public crxDatabaseField As CRAXDRT.DatabaseFieldDefinition
Public crxDatabaseField1 As CRAXDRT.DatabaseFieldDefinition
Public crxDatabaseField2 As CRAXDRT.DatabaseFieldDefinition
Public crxDatabaseField3 As CRAXDRT.DatabaseFieldDefinition
Public crxField As CRAXDRT.FieldObject
Public crxSection As CRAXDRT.Section
Public crxFieldObject As CRAXDRT.FieldObject
(SET THE DATABASES AND FIELDS)
Set crxReport = crxApplication.OpenReport("C:\blabla.rpt"
Set crxDatabase = crxReport.Database
Set crxDatabaseTables = crxDatabase.Tables
Set crxDatabaseTable = crxDatabaseTables.Item(1)
Call crxDatabaseTable.SetPrivateData(3, cdoSet)
Set crxDatabaseField1 = crxDatabaseTables.Item(1).Fields.Item(4)
Set crxDatabaseField2 = crxDatabaseTables.Item(1).Fields.Item(2)
Set crxDatabaseField3 = crxDatabaseTables.Item(1).Fields.Item(3)
crxReport.DiscardSavedData
(SET PARAMETERS)
Set crxParamDefs = crxReport.ParameterFields
For Each crxParamDef In crxParamDefs
With crxParamDef
Select Case .ParameterFieldName
Case "Employee"
.AddCurrentRange xStartEmpl, xEndEmpl, crRangeIncludeLowerBound
End Select
End With
Next
(ADD GROUP, FIELD,
crxReport.AddGroup 0, crxDatabaseField1, crGCAnyValue, crAscendingOrder
Set crxSection = crxReport.Sections.Item("GH"
Set crxField = crxSection.AddFieldObject("{@Resource}", 100, 0)
Set crxSection = crxReport.Sections.Item("GF"
Set crxDatabaseField = crxDatabaseTables.Item(1).Fields.Item(9)
Set crxFieldObject = crxSection.AddSummaryFieldObject(crxDatabaseField, crSTSum, 9040, 100)
Set crxDatabaseField = crxDatabaseTables.Item(1).Fields.Item(10)
Set crxFieldObject = crxSection.AddSummaryFieldObject(crxDatabaseField, crSTSum, 10315, 100)
(SORT YOUR DATA)
crxReport.RecordSortFields.Add crxDatabaseField1, crAscendingOrder
crxReport.RecordSortFields.Add crxDatabaseField3, crDescendingOrder
I am using VB6 with Crystal Report 7.0. I created a query in the access database file. Based on the query i generated a instant report by using crystal report selecting the option 'SQL' as data source. In future i have to pass the parameter to query and existing crystal report design has to use. Please guide in this regard.
NS Since this reply is unrelated to the thread, please start a new thread. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
Hi,
I understand the RDC gives you a great deal of runtime flexibility (including formatting). But our VB app uses .OCX with CR 8.5 Is it possible to enable the user to change the format using OCX?
Depends on the type of changes you want to make. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.