Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Not Refreshing for Viewer Object

Status
Not open for further replies.

asimasm

Programmer
Nov 27, 2000
62
AU
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.
 
Are you actually closing frmMain? I can't duplicate that behavior, but if I leave frmMain open, it behaves as you describe. The following worked for me. Try adding this at the end of your Click event:

If frmMain.Visible Then
frmMain.CRViewer1.RefreshEx True
Else
frmMain.CRViewer1.ReportSource = mRep
frmMain.CRViewer1.ViewReport
frmMain.Show
End If

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top