Results 1 to 18 of 18

Thread: How to setup a crosstab crystal report?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    How to setup a crosstab crystal report?

    Hi there..

    I have a problem here while setting up a crosstab report using crystal report. I'm currently using: VB6, ADO, MSSQL 2000, Crystal Reports v8.5 with TTX file as data source. I had using this method recently (this was quote from RobDog888's post )

    VB Code:
    1. Option Explicit
    2. 'Add reference to Crystal Reports x.x ActiveX Designer RunTime Library
    3. 'Add reference to Crystal Reports Viewer Control
    4. 'Add reference to Microsoft ActiveX Data Objects 2.x Library
    5. 'oCnn = current open ADO connection object
    6. Private Sub Command1_Click()
    7.  
    8.     Dim oApp As CRAXDRT.Application
    9.     Dim oReport As CRAXDRT.Report
    10.     Dim oRs As ADODB.Recordset
    11.     Dim sSQL As String
    12.  
    13.     sSQL = "SELECT * FROM Table1"
    14.     Set oRs = New ADODB.Recordset
    15.     Set oRs = oCnn.Execute(sSQL)
    16.     Set oApp = New CRAXDRT.Application
    17.     Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1)
    18.     oReport.Database.SetDataSource oRs, 3, 1
    19.     crvMyCRViewer.ReportSource = oReport
    20.     crvMyCRViewer.ViewReport
    21.  
    22. End Sub

    Then I came into problem when trying to setup a crosstab report. How do I setup a crosstab report using method as described above? Actually I didn't want to go for too much change for my code if possible.

    Is it possible using oReport.Database.SetDataSource for two or more recordset? Because as we know that we need at least 3 tables as data source to create a crosstab report, doesn't it? CMIIW

    Any help would be greatly appreciated. Thank you.
    Last edited by smartcanix; Jan 17th, 2008 at 10:44 AM.

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

    Re: How to setup a crosstab crystal report?

    Moved to Reporting

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    well... any idea?

  4. #4
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: How to setup a crosstab crystal report?

    If Iam not misleading you, why can't you simply make the rs in such a way to link more than one table and pass it to .SetDatasource. Or still better make a view/query in db itself and pass a simple * query to the view/query and extract the records.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    Thanks VBFnewcomer for the respond.

    Can we just passing 1 rs using .SetDataSource for creating a crosstab report in Crystal Report v8.5? Because as I know from the CR's crosstab example, we need at least 3 tables for setting up a crosstab report, in which first table for row data, second table for column data, and the third for the crosstab value itself. I need more info about this, thanks.

    Beside that, actually when I call a crosstab report using .ViewReport, it may crash my application, what's wrong with that?

    Any help would be appreciated.

  6. #6
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: How to setup a crosstab crystal report?

    Pls see my post #4
    Because as I know from the CR's crosstab example, we need at least 3 tables for setting up a crosstab report
    I don't think so. You can create a CT even from one table if you desire. CT helps in comparing & analysing the data. More info of CT should be available in the Help of CR.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    Well, so we can just linked the field we needed into just one recordset to set up a CT. I got it and going to try it, but the only problem now is:

    Beside that, actually when I call a crosstab report using .ViewReport, it may crash my application, what's wrong with that?
    Please help me with this one simple problem. Thanks.

  8. #8
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: How to setup a crosstab crystal report?

    Beside that, actually when I call a crosstab report using .ViewReport, it may crash my application, what's wrong with that?
    Try posting your relevant codes, so that somebody might help you.....Also post the Error message you get before the so called Crash!
    Last edited by VBFnewcomer; Feb 8th, 2008 at 02:29 AM.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    VB Code:
    1. Option Explicit
    2. 'Add reference to Crystal Reports x.x ActiveX Designer RunTime Library
    3. 'Add reference to Crystal Reports Viewer Control
    4. 'Add reference to Microsoft ActiveX Data Objects 2.x Library
    5. 'oCnn = current open ADO connection object
    6. Private Sub Command1_Click()
    7.  
    8.     Dim oApp As CRAXDRT.Application
    9.     Dim oReport As CRAXDRT.Report
    10.     Dim oRs As ADODB.Recordset
    11.     Dim sSQL As String
    12.  
    13.     sSQL = "SELECT * FROM Table1"
    14.     Set oRs = New ADODB.Recordset
    15.     Set oRs = oCnn.Execute(sSQL)
    16.     Set oApp = New CRAXDRT.Application
    17.     Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1)
    18.     oReport.Database.SetDataSource oRs, 3, 1
    19.     crvMyCRViewer.ReportSource = oReport
    20.     crvMyCRViewer.ViewReport
    21.  
    22. End Sub

    Nothing special from my code, that sample show my method. The crash occurs exactly at Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1) statement if MyReport.rpt was a crosstab report file. But it opened successfully if it was a standard report without crosstab.

    And no error message shows up, my application just crash with the standard dialog from microsoft to send or don't send report to microsoft. no useful information about what's wrong with the report file. I've try this with several report file, everytime I've added a crosstab into a report, it wouldn't show and just crash my app.

    Any help would be appreciated. Thanks.

  10. #10
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: How to setup a crosstab crystal report?

    standard dialog from microsoft to send or don't send report to microsoft
    just make sure this is the error msgbox which comes out. It might be file not found (have break point at Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1) and run in break mode using F8) Iam not able to duplicate your problem
    The query is also wrong. To get the correct query string, in the report click Database->Show SQL Query...

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    no, I'm sure the file exists there. too bad that you can't reproduce my problem. even i'm using F8 to step through line by line, whenever I execute that line of code "Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1)", my application will crash. For more information, I've been trying this on both Vista and XP.

    BTW, if you don't mind, can you please give me a link which show me how to open CR8.5 crosstab report using VB6 ?

    Thank you.

  12. #12
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Exclamation Re: How to setup a crosstab crystal report?

    I'm sure the file exists there
    just for my sake place
    Code:
      If Len(Dir(App.Path & "\MyReport.rpt")) > 0 Then
        MsgBox "Got the file"
      Else
        MsgBox "No luck dude. See there is no file"
      End If
    before
    Code:
        Set oReport = oApp.OpenReport(App.Path & "\MyReport.rpt", 1)
    Just one more thing (actually two)
    1. Are you sure you added (using Projects->components..) the Crystal Reports Viewer Control (very important)
    2.oApp.OpenReport(App.Path & "\MyReport.rpt", 1) is the 1 necessary? can't you just leave it out

    if you don't mind, can you please give me a link which show me how to open CR8.5 crosstab report using VB6
    are we not on this sub all along?

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    If Len(Dir(App.Path & "\MyReport.rpt")) > 0 Then
    MsgBox "Got the file"
    Else
    MsgBox "No luck dude. See there is no file"
    End If
    Added, Got the file.


    Are you sure you added (using Projects->components..) the Crystal Reports Viewer Control (very important)
    Yes, added already. if not, I think I will stuck on crvMyCRViewer.ReportSource = oReport


    oApp.OpenReport(App.Path & "\MyReport.rpt", 1) is the 1 necessary? can't you just leave it out
    Sure, but it give me the same result, application crash.


    if you don't mind, can you please give me a link which show me how to open CR8.5 crosstab report using VB6
    are we not on this sub all along?
    I mean a link with sample code. maybe we can work it out using another method for this problem.


    I think there's nothing wrong with file not exist, broken system files, or anything else, beside I can't call .OpenReport a file with crosstab structure inside the report file.

  14. #14
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: How to setup a crosstab crystal report?

    try to PM shakthi5385 he's a kinda good at CRs. He might join us here to solve the problem

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    Okay will try to PM him. Hope he will join us.

    BTW, it's nice to have you to help me these days. Thanks.

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    Quote Originally Posted by VBFnewcomer
    try to PM shakthi5385 he's a kinda good at CRs. He might join us here to solve the problem
    PM'ed shakti5385 instead of shakthi5385, just because user with ID shakthi5385 can't be found.

    Hoping that I didn't PM wrong person.

  17. #17
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: How to setup a crosstab crystal report?

    yeah he is the one sorry my mistake

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Nov 2007
    Posts
    98

    Re: How to setup a crosstab crystal report?

    no prob. let's see if he'll come to join us here.

    anyone else also welcome here.

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