Results 1 to 5 of 5

Thread: Urgent !!! data directly from datagrid to crystal report

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    62

    Urgent !!! data directly from datagrid to crystal report

    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???

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Urgent !!! data directly from datagrid to crystal report

    How does the data get into the grid?

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    62

    Re: Urgent !!! data directly from datagrid to crystal report

    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.

  4. #4
    Hyperactive Member
    Join Date
    May 2005
    Posts
    324

    Re: Urgent !!! data directly from datagrid to crystal report

    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):
    VB Code:
    1. 'General Declarations
    2. Dim crpApplication As CRPEAuto.Application
    3. Dim crpReport As CRPEAuto.Report
    4. Dim crpDatabase As CRPEAuto.Database
    5. Dim crpTables As CRPEAuto.DatabaseTables
    6. Dim crpTable As CRPEAuto.DatabaseTable
    7. Dim adoRs As ADODB.Recordset
    8.  
    9. Private Sub Form_Load()
    10. Set crpApplication = CreateObject("crystal.crpe.application")
    11. End Sub
    12.  
    13. Private Sub Command1_Click()
    14.  
    15. 'Now that the report has been created, we can set the report
    16. 'object to it (open the report)
    17.  
    18. Set crpReport = crpApplication.OpenReport(App.Path & "\test.rpt")
    19.  
    20. 'We need to set the database, database tables and database table
    21. 'to get to the method that we need: SetPrivateData
    22.  
    23. Set crpDatabase = crpReport.Database
    24. Set crpTables = crpDatabase.Tables
    25. Set crpTable = crpTables.Item(1)
    26.  
    27. 'SetPrivateData sets the report data to the recordset in memory
    28. 'assuming the adoRS has been populated somewhere in the application
    29.  
    30. [COLOR=Red]Call crpTable.SetPrivateData(3, adoRs) [/COLOR]
    31. crpReport.Preview
    32.  
    33. End Sub

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    62

    Re: Urgent !!! data directly from datagrid to crystal report

    thanks a lot !

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width