PDA

Click to See Complete Forum and Search --> : Urgent !!! data directly from datagrid to crystal report


masqazi
Sep 1st, 2005, 02:45 AM
i want to create a report in crsytal report, which should show data present in grid of a vb form, (not from the data base as we do usually).... how to do this???

Hack
Sep 1st, 2005, 05:46 AM
How does the data get into the grid?

masqazi
Sep 3rd, 2005, 01:04 AM
I will explain it further..

data is in database, we get it into a recordset and then put into the grid...the only important thing is that we apply a complicated formula to modifiy the data in recordset before populating the grid..and the formula can change depending of several factors....

our exact requirement is to just print the contents of the grid as a report.

anguswalker
Sep 4th, 2005, 03:13 PM
According to their website you can use the .SetPrivateData method to pass a ADO recordset to the crystal report. This is the code they give (the crucial bit is in red):
'General Declarations
Dim crpApplication As CRPEAuto.Application
Dim crpReport As CRPEAuto.Report
Dim crpDatabase As CRPEAuto.Database
Dim crpTables As CRPEAuto.DatabaseTables
Dim crpTable As CRPEAuto.DatabaseTable
Dim adoRs As ADODB.Recordset

Private Sub Form_Load()
Set crpApplication = CreateObject("crystal.crpe.application")
End Sub

Private Sub Command1_Click()

'Now that the report has been created, we can set the report
'object to it (open the report)

Set crpReport = crpApplication.OpenReport(App.Path & "\test.rpt")

'We need to set the database, database tables and database table
'to get to the method that we need: SetPrivateData

Set crpDatabase = crpReport.Database
Set crpTables = crpDatabase.Tables
Set crpTable = crpTables.Item(1)

'SetPrivateData sets the report data to the recordset in memory
'assuming the adoRS has been populated somewhere in the application

Call crpTable.SetPrivateData(3, adoRs)
crpReport.Preview

End Sub

masqazi
Sep 6th, 2005, 06:21 AM
thanks a lot !

do we need some references, dll , etc to use crpe...further can u put some ore light on crpe.