catalina36
Programmer
How do you get the Report Viewer to show changes that you programmatically make to Text Objects via VB at run-time? When I run the following code, the changes I make to the recordset are shown in the Report Viewer as expected, but the changes to the Text Object are not shown. In case it matters I’m using VB 6.0 and Crystal Reports 8.0.
Can anybody help a newbie to CR?
‘********* Here’s the code ***********
Dim Report As New CrystalReport1
Dim db As DAO.Database
Dim rs As DAO.Recordset
Private Sub cmdChangeData_Click()
‘Toggle data between IL and CT
Static intSwitch As Integer
If intSwitch Then
Set rs = db.OpenRecordset("SELECT * FROM Customer WHERE Region = 'Il'", dbOpenSnapshot)
Report.Text5.SetText "Region: Il"
Else
Set rs = db.OpenRecordset("SELECT * FROM Customer WHERE Region = 'Ct'", dbOpenSnapshot)
Report.Text5.SetText "Region: Ct"
End If
intSwitch = 1 - intSwitch
On Error GoTo ErrorHandler
Report.Database.SetDataSource rs
CRViewer1.Refresh
Exit Sub
ErrorHandler:
MsgBox "You have an error on Refresh"
Resume Next
End Sub
Private Sub Form_Load()
Set db = DBEngine.Workspaces(0).OpenDatabase("C:\Program Files\Seagate Software\Crystal Reports\Samples\Databases\xtreme.mdb", False)
Set rs = db.OpenRecordset("SELECT * FROM Customer WHERE Region = 'Ct'", dbOpenSnapshot)
Report.Database.SetDataSource rs
Screen.MousePointer = vbHourglass
Report.Text5.SetText "Region: Ct"
CRViewer1.Zoom 1
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
Can anybody help a newbie to CR?
‘********* Here’s the code ***********
Dim Report As New CrystalReport1
Dim db As DAO.Database
Dim rs As DAO.Recordset
Private Sub cmdChangeData_Click()
‘Toggle data between IL and CT
Static intSwitch As Integer
If intSwitch Then
Set rs = db.OpenRecordset("SELECT * FROM Customer WHERE Region = 'Il'", dbOpenSnapshot)
Report.Text5.SetText "Region: Il"
Else
Set rs = db.OpenRecordset("SELECT * FROM Customer WHERE Region = 'Ct'", dbOpenSnapshot)
Report.Text5.SetText "Region: Ct"
End If
intSwitch = 1 - intSwitch
On Error GoTo ErrorHandler
Report.Database.SetDataSource rs
CRViewer1.Refresh
Exit Sub
ErrorHandler:
MsgBox "You have an error on Refresh"
Resume Next
End Sub
Private Sub Form_Load()
Set db = DBEngine.Workspaces(0).OpenDatabase("C:\Program Files\Seagate Software\Crystal Reports\Samples\Databases\xtreme.mdb", False)
Set rs = db.OpenRecordset("SELECT * FROM Customer WHERE Region = 'Ct'", dbOpenSnapshot)
Report.Database.SetDataSource rs
Screen.MousePointer = vbHourglass
Report.Text5.SetText "Region: Ct"
CRViewer1.Zoom 1
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub