Resizing crystal report viewer
Hi,
I have a CRViewer control in an array on an SSTab control with 4 tabs - each tab has a CRViewer. I have 4 predesigned .rpt files.
When I load the reports I loop thru the CRViewer control array loading each of the 4 report files. The reports load without a problem.
However, when I resize the form all the CRViewer controls contain the first report - the report loaded on CRViewer(0) on tab 1 of the SSTab control.
Here's the code used to load the reports and resize the form.
VB Code:
Private Sub cmdView_Report_Click()
sstbReports.Tab = 0
DisplayPresPrev Trim$(txtyear), CStr(cmbSIC.ItemData
(cmbSIC.ListIndex))
End Sub
Private Sub DisplayPresPrev(ByVal sThis_Year As String, ByVal
sSic_Code As String)
Dim i As Integer
On Error GoTo errCRX
Set m_Application = New CRAXDRT.Application
Set m_Report = Nothing
m_Application.LogOnServerEx "pdsodbc.dll", "EconAct", "EAS003",
"richard", "branson", "ODBC"
For i = 0 To 3
Set m_Report = m_Application.OpenReport("D:\Program
Files\Microsoft Visual Studio\VB98
\Reports\rptPresPrev" & CStr(i+1) & ".rpt",1)
Set CRXParamDefs = m_Report.ParameterFields
For Each CRXParamDef In CRXParamDefs
Select Case CRXParamDef.ParameterFieldName
Case "@this_Year"
CRXParamDef.SetCurrentValue Trim$(sThis_Year)
Case "@sic_Code"
CRXParamDef.SetCurrentValue Trim$(sSic_Code)
End Select
Next
If sstbReports.Enabled = False Then
sstbReports.Enabled = True
End If
CRViewer(i).ReportSource = m_Report
m_Report.EnableParameterPrompting = False
CRViewer(i).ViewReport
CRViewer(i).Zoom 1
Set m_Report = Nothing
Next
Set m_Application = Nothing
Exit Sub
errCRX:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub
Private Sub Form_Resize()
On Error Resume Next
Dim j As Integer
If Me.WindowState = 1 Then Exit Sub
If Me.Height < 7290 Then Me.Height = 7290
If Me.Width < 9495 Then Me.Width = 9495
sstbReports.Left = 0
sstbReports.Top = 1560
sstbReports.Height = ScaleHeight - frameReports.Height - 120
sstbReports.Width = ScaleWidth - 5
For j = 0 To 3
CRViewer(j).Left = 120
CRViewer(j).Top = 700
CRViewer(j).Height = sstbReports.Height - 460 -
sstbReports.TabHeight
CRViewer(j).Width = sstbReports.Width - 360)
Next
End Sub
The report names are rptPresPrev1, rptPresPrev2, rptPresPrev3 and rptPresPrev4.
What am I doing wrong?
Thanks.