Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Crystal Report crashes in VB

Crystal Report crashes in VB

Crystal Report crashes in VB

I had created a crystal report using a sub-report. The report, on its own,
runs very well without any problem and gives me the correct data.
But I have to call it through Visual Basic (version 6.0) and when I do that, my VB application crashes with a Dr.Watson error that says "An exception occurred

When i went through my code through the code debugger, I found that it was crashing at the place where I am putting
CRViewer1.ReportSource = m_Report

Where m_Report is an instance of my CRAXDRT.Report Object.

I have reproduced the code below for clarity:


Dim m_App                   As New CRAXDRT.Application
Dim m_Report                As New CRAXDRT.Report
Dim CRViewer1               As New Report

Private Sub Command1_Click()
   Dim SQL As String
   Dim strConnect As String
   Set m_Report = m_App.NewReport
   Set m_Report = m_App.OpenReport("d:\Management_Diary_Detailed.rpt", 1)

   ' Create and bind the ADO Recordset object
   Set m_Connection = New ADODB.Connection
   Set adoRS = New ADODB.Recordset

   ' Open the connection
   strConnect = "driver={SQL
   m_Connection.Open strConnect
   SQL = "Execute spManagementDiary_Detailed '30-Apr-2001', 2"
   adoRS.Open SQL, m_Connection, adOpenDynamic, adLockBatchOptimistic
   m_Report.Database.SetDataSource adoRS
   CRViewer1.ReportSource = m_Report
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Set m_Report = Nothing
End Sub

Since its been stopping my project from finishing, I would be glad if you could tell me where I am going wrong or if there is a problem with the DLL.

RE: Crystal Report crashes in VB

With a subreport, active data and a stored procedure you have lots of room for errors.  It might help to eliminate some pieces and get a simpler report to work, and then add to it.

Can you launch a report from this code if it doesn't have a subreport?

If the report is to use a recordset, it must be created using the active data driver.  

Also, change the line to read:

m_Report.Database.SetDataSource adoRS, 3

I believe that the last numeric argument is required.

Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close