Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 918
  • Last Modified:

Crystal Report V 8.5

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
eugene007
Asked:
eugene007
  • 13
  • 13
  • 2
1 Solution
 
mlmccCommented:
What code are you using?  What references have you included?

mlmcc
0
 
eugene007Author Commented:
The examples dont seem to work.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
vikram_c90Commented:
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
 
eugene007Author Commented:
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
 
eugene007Author Commented:
Set CRXReport = CRXApplication.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)

seems that my error accures starting this potion of the code.
0
 
eugene007Author Commented:
Set CRXReport = CRXApplication.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)

seems that my error accures starting this potion of the code.
0
 
mlmccCommented:
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
 
mlmccCommented:
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
 
eugene007Author Commented:
rptCRViewer Is this the name of the Report Viewer control?.

Regards
Eugene
0
 
mlmccCommented:
Yes.

mlmcc
0
 
eugene007Author Commented:
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
 
mlmccCommented:
Are you working on the machine with VB and CR8.5 installed?

mlmcc
0
 
eugene007Author Commented:
yes I am using VB6 and CR8.5
0
 
eugene007Author Commented:
always at this part the illegal operation dialog box apprears.

Set crRpt = crApp.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)
0
 
eugene007Author Commented:
always at this part the illegal operation dialog box apprears.

Set crRpt = crApp.OpenReport("C:\InternetCaffe\EarningsReport.rpt", 1)
0
 
vikram_c90Commented:
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
 
mlmccCommented:
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
 
eugene007Author Commented:
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
 
mlmccCommented:
Try uninstalling CR8.5 and reinstalling it.

mlmcc
0
 
eugene007Author Commented:
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
 
eugene007Author Commented:
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
 
mlmccCommented:
Won't do much good since we also need the database.

What editioin of CR do you have?

mlmcc
0
 
mlmccCommented:
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
 
eugene007Author Commented:
Guess what I installed and uninstalled for 5 times, and now it works.
0
 
mlmccCommented:
As I said, sometimes the uninstall leaves something behind that corrupts or interferes with the later version.

mlmcc
0
 
mlmccCommented:
Glad to help

mlmcc
0
 
mlmccCommented:
done

mlmcc
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 13
  • 13
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now