CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    44

    Create Dynamic Report

    Mr. Babu,

    How can I manipulate the query from VB depending on the input entered by the user. In this case I can make one report only and modify the query and pass it to the report.
    Otherwise for each user input I will have call a different report.
    If possible do send me an example.

    Thanks,

    Satish

  2. #2
    Join Date
    May 2003
    Posts
    163
    Have you try to pass parameters to your report?

  3. #3
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    44
    I have tried parameters and it works, but I would like to chang the sql
    i.e. select * from ..... where empno= variable

    regards,
    Satish

  4. #4
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651
    This may be more trouble than it's worth...

    You could change your report so that VB does all the database queries and passes a recordset to your report.


    Example 1:
    Code:
    Dim CrApp1 As New CRPEAuto.Application
    Dim CrRep As CRPEAuto.Report
    Dim CrDB As CRPEAuto.Database
    Dim CrTables As CRPEAuto.DatabaseTables
    Dim CrTable As CRPEAuto.DatabaseTable
    
    'open report
        Set CrRep = CrApp1.OpenReport("C:\Report.rpt")
    
        'set the database object to the reports database
        Set CrDB = CrRep.Database
    
        'Set the databasetables object
        Set CrTables = CrDB.Tables
    
        'set the databasetable object to the first table in the report
        Set CrTable = CrTables(1)
    
        'sets ADO recordset as the data for the first table
        CrTable.SetPrivateData 3, rsData
    
        'preview the report with the ADO recordset as the data
        CrRep.Preview


    Example 2 (uses RDC, which I like better):
    Code:
    Dim Report As New CrystalReport1
         
        Report.Database.SetDataSource rsData, 3, 1
        
        CRViewer1.ReportSource = Report
        CRViewer1.ViewReport
    In Example 2, CrystalReport1 is the dsr file created by clicking 'Project', 'Add Crystal Report 8.5' in the VB IDE. CRViewer1 is the Crystal Report Viewer component.


    Both of these examples were created using CR 8.5 and VB 6.
    I'd rather be wakeboarding...

  5. #5
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    44
    This is in reference to your reply.

    In Example 2, CrystalReport1 is the dsr file created by clicking 'Project', 'Add Crystal Report 8.5' in the VB IDE.

    When I click Project, I cannot see "Add Crystal Report 8.5".
    How do I get it.

    Regards,
    Satish

  6. #6
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    44
    I am not getting CRPEAuto method. What reference has to be made.

    what does crpeauto stand for?

  7. #7
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651
    My References for the 'CRPEAuto' Method says 'Crystal Report Engine 8 Object Library'

    As for the 'Add Crystal Report 8.5', do you have Crystal Reports Developer Edition installed on your development machine? If so, what version? I think RDC was made avaiable in either version 8 or 8.5 and higher.

    You can try to do a search on Crystal's website:
    http://support.businessobjects.com/search/advsearch.asp
    I'd rather be wakeboarding...

  8. #8
    Join Date
    Jun 2002
    Location
    Kuwait
    Posts
    44
    how do I get the reference to "'Crystal Report Engine 8 Object Library'" in my computer.

  9. #9
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651
    I'm using version 8.5 Developer Edition. When I installed it, it placed all the necessary dlls on my comuter for me.

    Click 'Project', 'References', and check 'Crystal Report Engine 8 Object Library'
    I'd rather be wakeboarding...

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

Featured