Hi I am facing a problem with RDC componenet of CR9. I have created one Visual Basic form where i created a CRAXDRT report object ONCE and then on pressing a button on the form my code sets the Viewer control on the 2nd form and opens the report. I change the selection formula whenevr the button is presed. But strangely first time the report shows data correctly and when i close the report form and then give different selection formula the report shows empty. But when i press refresh button of Viewer control the report shows the correct data. I cant seem to figure out wts wrong. Here is my Code
Form1 Code:
Option Explicit
Public mRep As CRAXDRT.Report
Private Sub Form_Load()
Dim mApp As CRAXDRT.Application
Set mApp = CreateObject("CrystalRuntime.Application")
Set mRep = mApp.OpenReport("C:\ReportFile.rpt")
End Sub
Private Sub Command1_Click()
Dim str1 As String
str1 = InputBox("Enter Criteria")
'Here i enter Criteria For report
mRep.RecordSelectionFormula = "{rptView.mId} = " & str1
frmMain.CRViewer1.ReportSource = mRep
frmMain.CRViewer1.ViewReport
frmMain.Show
End Sub
On frmMain there is no code but contains CRViewer Control named CRViewer1.
when i close 2nd form (frmMain) and pass it a different selection formula then the viewer control displays empty report. And when i refresh it by pressing the refresh button i get the correct results.
I should get the correct results witout pressing refresh button. Can any body help me in this regard. I have got really stuck in this. On more thing i dont want to create Report object again and again that is why i have set it in the Form_Load event and declared it as Public.
Form1 Code:
Option Explicit
Public mRep As CRAXDRT.Report
Private Sub Form_Load()
Dim mApp As CRAXDRT.Application
Set mApp = CreateObject("CrystalRuntime.Application")
Set mRep = mApp.OpenReport("C:\ReportFile.rpt")
End Sub
Private Sub Command1_Click()
Dim str1 As String
str1 = InputBox("Enter Criteria")
'Here i enter Criteria For report
mRep.RecordSelectionFormula = "{rptView.mId} = " & str1
frmMain.CRViewer1.ReportSource = mRep
frmMain.CRViewer1.ViewReport
frmMain.Show
End Sub
On frmMain there is no code but contains CRViewer Control named CRViewer1.
when i close 2nd form (frmMain) and pass it a different selection formula then the viewer control displays empty report. And when i refresh it by pressing the refresh button i get the correct results.
I should get the correct results witout pressing refresh button. Can any body help me in this regard. I have got really stuck in this. On more thing i dont want to create Report object again and again that is why i have set it in the Form_Load event and declared it as Public.