Problem With creation repot on run time

04-18-2004, 03:45 AM
Hi there.

I'm developing a project in VB6,in which I must create a report on run time based on a data that exists only at run time in a table format(Access). I have chosen active data driver and CDO(Crystsl Data Objec) and the related "P2smon.dll" file exitsts in my system32 folder. I have done all necessary including defining requird objects, filling a 2 dimensional array with run time data and pass the rowset object of CDO as an active data source to related functions. I have used two functions of the referred ".dll" file:"CreateFieldDefFile" and "CreateReportOnRunTimeDS" which the first one works properly generates a text file of fields names and types defined in CDO object formerly.
but the second one must generate a simple blank report based of this text file in which we must see just the name of the fields, before pass the rowset object to report. The problem is that this function just creates an emty repor, I mean without the name of fields in it, but when I open this file with Seagat Crystal Report 6, and I click on "Insert Fields" tab, a little window opens showing the same fields that we want, in other words, the referred fields names have not added to report in run time. What can I do?

Thank You In Advance

04-19-2004, 06:58 AM
OK, can you post the code you are using for this? The CreateFieldDefFile method only works with the P2smon.dll..but it appears that is what you are working with (ADO). So, in your report you want to only display the field names available? Am I understanding this correctly? If so, you do want to use the ttx file definition method.

04-24-2004, 12:54 AM
Thank you for your attentin,

No, I don' want to display just the field names in my report. As I undestood from crystal technical document, for creation a report on run time, I must firstly create an empty report(just its field names at the top of it) and then fill it with run time data by passing this data by a recordset or rowset object as an active data source to the report object. But because my data that is similar to an Access table has not a constant template(I mean this table doesn't have fixed fields number, and actually this table doesn't exists on my harddisk, just it is displayed after some manipulations in my program on manitor and I want to print this table, so as I saied both fields names,fields number and records data exist only in run time) I can't design my report firstly by segate crystal report and then fill it with data in run time. So firstly I use "Create FieldDefFile" to generate a ".ttx" file based on fields names and their types,then "CreateReportOnRunTimeDS" to generate a report wih just fields names at the top of it, and then fill it with data. The solution of crystal report for such an application in which neither fields names and fields types, nor data exist out of run time is using CDO "Crysal Data Object" and defining a rowset object. Below you can find print code of my program, Please read it and because I'm so mch late in the time schedule of this project, I would be grateful if you kindly answer soon.
Option Base 0
Dim app As CRPEAuto.Application
Dim rep As CRPEAuto.Report
Dim db As dao.Database
Dim tbls As CRPEAuto.DatabaseTables
Dim tbl As CRPEAuto.DatabaseTable
Dim daoset As dao.Recordset
Public cdoset As Object
Dim rows(2, 4) As Variant
Dim fd As CRPEAuto.FieldDefinitions
Dim repdb As CRPEAuto.Database

Private Sub Command1_Click()

Set cdoset = CreateObject("crystaldataobject.crystalcomobject")

cdoset.addfield "Company", vbString
cdoset.addfield "Country", vbString
cdoset.addfield "Tel", vbLong
cdoset.addfield "Address", vbString
cdoset.addfield "Boss", vbString

rows(0, 0) = "Microsoft"
rows(0, 1) = "USA"
rows(0, 2) = 53453
rows(0, 3) = "dfskjdf"
rows(0, 4) = "gjgjh"

rows(1, 0) = "Intel"
rows(1, 1) = "USA"
rows(1, 2) = 8745374
rows(1, 3) = "wegeghjeg"
rows(1, 4) = "jghhj"

rows(2, 0) = "Appel"
rows(2, 1) = "USA"
rows(2, 2) = 543564
rows(2, 3) = "fjdeklfjekj"
rows(2, 4) = "jhjh"

cdoset.Addrows rows

Set app = CreateObject("crystal.crpe.application")

i = CreateFieldDefFile(cdoset, "c:\temp\3.ttx", True)
i = CreateReportOnRuntimeDS(cdoset, "c:\temp\report3.rpt", "c:\temp\3.ttx", True, True)

Set rep = app.OpenReport("c:\temp\report3.rpt")

Set repdb = rep.Database
Set tbls = repdb.Tables
Set tbl = tbls.Item(1)

tbl.SetPrivateData 3, cdoset

End Sub
Ofcourse I have declared the reffered two functions in my module.

04-24-2004, 07:03 AM
Well, before I get into this, what is the error that you get? If you are receiving an error along the lines of "your developer license requires Crystal API calls, etc" this means you have to contact Crystal Licensing support and get an upgraded license. The CreateFieldDefFile and CreateReportOnRuntime commands are direct Crystal Print Engine API calls. These required specified licenses.

This is why you don't typically see this in VB applications (you do, and I have used it, but the RDC is best for using Crystal Reports in VB), please let me know the exact errors you are getting.

04-25-2004, 11:40 PM
Actually I don't get any error during compilation. Th problem is,as I saied before, that "CreateReportOnRunTimeDS" doesn't work properly. I don't get any error message, like what you saied, or any other one, and I have a Serial Number for my "seagate crystal report 6" which I have entered when I installed it. The referred function, must produce an empty report, with just the name of the fields on top of it, in the path that I have passed to this function in my code "C:\temp\report3.rpt". In my case for example a report like this one:

Company Country Tel Address Boss


Then with "setprivatedata" method, as is seen in my code, it will fill in runtime, as below:
Company Country Tel Address Boss Microsoft USA 53435 dfskjdf gjgjh
Intel USA 8745374 wegeghjeg jghhj
Appel USA 543564 fjdeklfjekj jhjh

The problem is that this funcion(CreateReportOn.....) produce a completely empty report named "report3.rpt" in the specified path, I mean without the name of the fields at the top of it, but when I open this empty report with "seagate crystal report 6" (out of run time) and click on "Insert Fields" tab, a little window opens and shows the name of fields in it,this means that this report has produced based on the specified "3.ttx" file in my source code,but just the "Add" operation for adding of the fields to the report has not been done with "CreateReportOnRunTimeDS" , which is the only problem of this project. The other function "CreateFieldDefFile" works quite well.

04-26-2004, 07:03 AM
OK, I would recommend upgrading to a new version of Crystal Reports. The CreateReportOnRunTimeDS has a lot of known issues in earlier versions of Crystal Reports, you should do some research at regarding this.

Is your API declaration correct?, see below:

Private Declare Function CreateReportOnRuntimeDS Lib "p2smon.dll" ( _
lpUnk As Object, ByVal ReportFile As String, ByVal fieldDefFile _
As String, ByVal bOverWriteFile As Long, ByVal bLaunchDesigner _
As Long) As Long

Public Sub OpenInCR()
Dim lRetVal As Integer
Dim sReport As String

'now pass in the dataSource, report name, report definition and int-based params

sReport = App.Path & "\myReport.rpt"
lRetVal = CreateReportOnRuntimeDS(DataSource, sReport , sReport & ".def", 1, 1)

If Not lRetVal Then
MsgBox "Crystal Reports was unable to create a new report "
End If

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum