?
Solved

Crystal Report V 8.5

Posted on 2003-03-07
28
Medium Priority
?
903 Views
Last Modified: 2012-06-27
I have created a report using Crystal Report V 8.5. The main problem which I am facing is to invoke the report which I have created from Visual Basic using the command button. For example in Crystal Report V 4.5 you could invoke the report which u have created from VB using the command button with the following coding crystal.action = true. In crystal report v 4.5 there is a control called crystal report control which U have to select from the component section. However In my case its kinda different. How do I solve this problem.

Your help is kindly appreciated.

Regards
Eugene
0
Comment
Question by:eugene007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 13
  • 2
28 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 8089380
What code are you using?  What references have you included?

mlmcc
0
 

Author Comment

by:eugene007
ID: 8093120
The examples dont seem to work.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:vikram_c90
ID: 8093242
Hi eugene!! U need to perform the following steps and then write the paste the code which I am giving below. It will work:

Goto menu Project->References and add the following references:

1)Crystal Report 8.5 ActiveX designer run time library.

Goto menu Project->Components and add the following component:

1) Crystal Report Viewer Control

Place an instance of the Crystal Report Viewer control on your form, from the Control ToolBox. Place a command Button and in its Click event paste the following code. Please make neccessary changes, such as replace the report file name with ur file name and change the selection formulas as per ur reports requirement.

Private Sub cmd_Go_Click()
'On Error GoTo errh:
    Dim myApp As New CRAXDRT.Application
    Dim myRpt As New CRAXDRT.Report
    Set myRpt = myApp.OpenReport(App.Path & "\CMR PRINTING.rpt")
     myRpt.RecordSelectionFormula = "{T_GOODS_RECEIPT_HEAD.GRH_COMP_CD} = '" & cmbCompCode.Text & _
    "' AND {T_GOODS_RECEIPT_HEAD.GRH_PROJ_CD} = '" & cmbProjCode.Text & _
    "' AND {T_GOODS_RECEIPT_HEAD.GRH_SEQ_NO} = " & IIf((cmbRcptNo.Text = ""), 0, cmbRcptNo.ItemData(cmbRcptNo.ListIndex))
 '  "' AND {T_RA_BLOCK_QTY.RBQ_RA_NO} = " & IIf((txtRANO = ""), 0, txtRANO)
   ' myRpt.RecordSelectionFormula = "{T_GOODS_RECEIPT_HEAD.GRH_PROJ_CD} = '" & txtProjCd & "'"
  '  myRpt.RecordSelectionFormula = "{inward_control.batch_no} = '" & batchNo & "'"
   
    CRViewer1.ReportSource = myRpt
    CRViewer1.EnableCloseButton = True
    'CRViewer1.Height = 7000
    'CRViewer1.Width = 10380
    'With CRViewer1
    '.Top = 0
    '.Left = 0
    'End With
    CRViewer1.ViewReport
    CRViewer1.EnableExportButton = True

errh:
    If Not err.Number = 0 Then
        MsgBox "Error! cmd_Go_Click " & vbCrLf & vbCrLf & "Error No. : " & err.Number & vbCrLf & err.Description
End If
End Sub

Hope it helps to solve ur problem
0
 

Author Comment

by:eugene007
ID: 8093863
Ive tried this method, but It seems that an illegal operation dialog box error appears.

Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strConnect As String

Dim CRXApplication As New CRAXDRT.Application
Dim CRXReport As CRAXDRT.Report
Dim CRXDatabase As CRAXDRT.Database

Private Sub Command1_Click()

   Set conn = New ADODB.Connection
   Set rs = New ADODB.Recordset

   strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & "C:\InternetCaffe\CyberCafe.mdb;Mode=Read"
   conn.Open strConnect
   rs.Open "SELECT * FROM Account_Master", conn, adOpenKeyset, adLockBatchOptimistic

   Set CRXReport = CRXApplication.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)
   Set CRXDatabase = CRXReport.Database
   CRXDatabase.SetDataSource rs, 3, 1
   CRXReport.PrintOut

End Sub


Private Sub Command2_Click()

    Set conn = New ADODB.Connection
    Set rs = New ADODB.Recordset

    strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & "C:\InternetCaffe\CyberCafe.mdb;Mode=Read"
    conn.Open strConnect
    rs.Open "SELECT * FROM Account_Master", conn, adOpenKeyset, adLockBatchOptimistic

    Set CRXReport = CRXApplication.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)
    CRXDatabase.SetDataSource rs, 3, 1

    CRViewer1.ReportSource = CRXReport
    CRViewer1.ViewReport

End Sub

well one thing about this code is that I am able to filter the data which I want it to be displayed in my report. But in my case my coding does not seem to work.
0
 

Author Comment

by:eugene007
ID: 8093867
Set CRXReport = CRXApplication.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)

seems that my error accures starting this potion of the code.
0
 

Author Comment

by:eugene007
ID: 8093879
Set CRXReport = CRXApplication.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)

seems that my error accures starting this potion of the code.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8094000
I would eliminate this line.  I don't think you need it

Set CRXDatabase = CRXReport.Database

Try something like

CRXReport.Database.SetDataSource rs, 3, 1

it might be
CRXReport.SetDataSource rs, 3, 1

mlmcc
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 140 total points
ID: 8094016
Here is the code I use.  The report is already using the correct data source.

Option Explicit
    Dim crApp As CRAXDRT.Application
    Dim crRpt As CRAXDRT.Report

Public Sub crPreview_Report( )
'
'   Check if report is already in use
'
    If IsObject(crRpt) Then
       Set crRpt = Nothing
    End If

'
'   Open report
'
    Set crApp = New CRAXDRT.Application

    Set crRpt = crApp.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)

'
'   Set flags for CRViewer
'
    crRpt.MorePrintEngineErrorMessages = False
    crRpt.EnableParameterPrompting = False
    crRpt.DiscardSavedData
   
'
' Set the viewer's report source to the Report object
'
    Me.rptCRViewer.ReportSource = crRpt
    Me.rptCRViewer.ViewReport
    Me.Show

End Sub

Public Sub crPrint_Report( )

'
'   Check if report is already in use
'
        If IsObject(crRpt) Then
           Set crRpt = Nothing
        End If

'
'   Open report
'
        Set crApp = New CRAXDRT.Application
        Set crRpt = crApp.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)

'
'   Set flags for CRViewer
'
        crRpt.MorePrintEngineErrorMessages = False
        crRpt.EnableParameterPrompting = False
        crRpt.DiscardSavedData

'
'   Print Report
'
       crRpt.PrintOut False
       Unload Me

End Sub

mlmcc
0
 

Author Comment

by:eugene007
ID: 8096378
rptCRViewer Is this the name of the Report Viewer control?.

Regards
Eugene
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8096524
Yes.

mlmcc
0
 

Author Comment

by:eugene007
ID: 8096766
VB6 Cause an Invalid Page Fault In
Module CRAXDRT.DLL at 0167:41d9ec38

VB6 Caused and Invalid Page Fault In
Module <unknown> at 0084:0000000b

VB6 Caused an Invalid Page Fault In
Module KERNAL32.DLL at 0167:bff8ac13

VB6 Caused an Invalid Page Fault In
Module MFC42.DLL at 0167:5f4042ca

VB6 Caused an Invalid Page Fault In
Module SSSCC.DLL at 0167:60567702

I received the following errors. It was displayed in my
Illegal Operations dialog box.

Regards
Eugene
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8096916
Are you working on the machine with VB and CR8.5 installed?

mlmcc
0
 

Author Comment

by:eugene007
ID: 8096956
yes I am using VB6 and CR8.5
0
 

Author Comment

by:eugene007
ID: 8096963
always at this part the illegal operation dialog box apprears.

Set crRpt = crApp.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)
0
 

Author Comment

by:eugene007
ID: 8096964
always at this part the illegal operation dialog box apprears.

Set crRpt = crApp.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)
0
 

Expert Comment

by:vikram_c90
ID: 8097496
HI eugene, I dont think that the error that you are getting is due to any problem VB or CR8.5. Can you one thing. Can u try running your form and report on another machine whih also has VB and Cr8.5? This will atleast help us to know, whether it is a system problem. As far as the code is concerned (which I have give u) it works perfectly fine. I have developed 86 reports in the last 2 months and have called each one of them thro a VB form using the same code. Also maybe u could try mailing me ur form and report and the mdb file, so that I can check it up over here on my machine.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8097632
Can you open the report from CR8.5?

Have you included the correct references for CR8.5 in your VB application?
  CRAXRDRT.DLL - Crystal Reports 8.5 Designer Runtime Library

Did you uninstall CR4 before installing CR8.5?

mlmcc
0
 

Author Comment

by:eugene007
ID: 8097786
well yes I can open CR8.5.

I have uninstall CR 4.5 after installing my CR 8.5.

I will test the program on another machine n let u know the result. As for the file, do u have an email whereby I could email them to u.

Your help is kindly appreciated.

Regards
Eugene
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8097949
Try uninstalling CR8.5 and reinstalling it.

mlmcc
0
 

Author Comment

by:eugene007
ID: 8101922
I did. n still it does not work. could it be that my crystal report has some errors on it. cause during installation several components could not be registered on my machinese. I had to select ignore option to continue installation.

Example:

PluginManager.dll
inforstor.dll
EnterpriseFramework.dll
InforFileRepository.dll
EnDiagnostics.dll


Could this be the cause of my problem?
0
 

Author Comment

by:eugene007
ID: 8102524
anyway could I email u the vb files and crystal report file so that u guys could test and identify the problem.

Regards
Eugene
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8103247
Won't do much good since we also need the database.

What editioin of CR do you have?

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8106934
Just remembered that sometimes when you uninstall some versions of CR they don't fully uninstall.

Take a look at

http://support.crystaldecisions.com/library/kbase/articles/c2002756.asp

http://support.crystaldecisions.com/library/kbase/articles/c2008547.asp

mlmcc

0
 

Author Comment

by:eugene007
ID: 8108725
Guess what I installed and uninstalled for 5 times, and now it works.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8108937
As I said, sometimes the uninstall leaves something behind that corrupts or interferes with the later version.

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8110631
Glad to help

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12479782
done

mlmcc
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question