I have a code below and was running when we were using Crystal Report 8. However when we change to Crystal 9, it won't work anymore. Can you tell me why. Thanks.
Option Explicit
Dim Crep As String
Dim CApp As New CRAXDRT.Application
Dim CReport As New CRAXDRT.Report
Private Sub CmdExit_Click()
Unload Me
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path ' Set file list box path.
End Sub
Private Sub File1_DblClick()
openRpt File1.FileName
Crep = File1.FileName
End Sub
Private Sub Form_Load()
On Error Resume Next
Dir1.Path = "G:\PCRM\Reports"
End Sub
Sub openRpt(rptName As String)
Dim ind As Integer
Set CReport = CApp.OpenReport(Crep)
CRViewer91.ReportSource = CReport
'File1.FileName
'CRViewer91.ProgressDialog = True
On Error GoTo comboErr
CRViewer91.PrintReport
CRViewer91.WindowHeight = Screen.Height
CRViewer91.WindowWidth = Screen.Width
'CR1.WindowsAllowDrillDown = True
CRViewer91.WindowAllowDrillDown = True
Exit Sub
comboErr:
MsgBox "Error: " & rptName
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
'Process the appropriate toolbar button and call the
'corresponding menu item
Select Case Button.Key
Case "btnCut"
Call mnuEditCut_Click
Case "btnCopy"
Call mnuEditCopy_Click
Case "btnPaste"
Call mnuEditPaste_Click
Case "btnFind"
Case "btnHelp"
End Select
End Sub
Private Sub mnuEditCopy_Click()
'Ignore errors for combo boxes with a style property of 2
On Error Resume Next
If TypeOf Me.ActiveControl Is TextBox Or _
TypeOf Me.ActiveControl Is ComboBox Then
'Clear clipboard contents
Clipboard.Clear
'Copy contents to clipboard
Clipboard.SetText Me.ActiveControl.SelText
End If
End Sub
Private Sub mnuEditCut_Click()
'Ignore errors for combo boxes with a style property of 2
On Error Resume Next
If TypeOf Me.ActiveControl Is TextBox Or _
TypeOf Me.ActiveControl Is ComboBox Then
'Clear clipboard contents
Clipboard.Clear
'Copy contents to clipboard
Clipboard.SetText Me.ActiveControl.SelText
'Clear contents
Me.ActiveControl.SelText = ""
End If
End Sub
Private Sub mnuEditPaste_Click()
'Ignore errors for combo boxes with a style property of 2
On Error Resume Next
If TypeOf Me.ActiveControl Is TextBox Or _
TypeOf Me.ActiveControl Is ComboBox Then
'Paste contents of clipboard
Me.ActiveControl.SelText = Clipboard.GetText()
End If
End Sub
Option Explicit
Dim Crep As String
Dim CApp As New CRAXDRT.Application
Dim CReport As New CRAXDRT.Report
Private Sub CmdExit_Click()
Unload Me
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path ' Set file list box path.
End Sub
Private Sub File1_DblClick()
openRpt File1.FileName
Crep = File1.FileName
End Sub
Private Sub Form_Load()
On Error Resume Next
Dir1.Path = "G:\PCRM\Reports"
End Sub
Sub openRpt(rptName As String)
Dim ind As Integer
Set CReport = CApp.OpenReport(Crep)
CRViewer91.ReportSource = CReport
'File1.FileName
'CRViewer91.ProgressDialog = True
On Error GoTo comboErr
CRViewer91.PrintReport
CRViewer91.WindowHeight = Screen.Height
CRViewer91.WindowWidth = Screen.Width
'CR1.WindowsAllowDrillDown = True
CRViewer91.WindowAllowDrillDown = True
Exit Sub
comboErr:
MsgBox "Error: " & rptName
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
'Process the appropriate toolbar button and call the
'corresponding menu item
Select Case Button.Key
Case "btnCut"
Call mnuEditCut_Click
Case "btnCopy"
Call mnuEditCopy_Click
Case "btnPaste"
Call mnuEditPaste_Click
Case "btnFind"
Case "btnHelp"
End Select
End Sub
Private Sub mnuEditCopy_Click()
'Ignore errors for combo boxes with a style property of 2
On Error Resume Next
If TypeOf Me.ActiveControl Is TextBox Or _
TypeOf Me.ActiveControl Is ComboBox Then
'Clear clipboard contents
Clipboard.Clear
'Copy contents to clipboard
Clipboard.SetText Me.ActiveControl.SelText
End If
End Sub
Private Sub mnuEditCut_Click()
'Ignore errors for combo boxes with a style property of 2
On Error Resume Next
If TypeOf Me.ActiveControl Is TextBox Or _
TypeOf Me.ActiveControl Is ComboBox Then
'Clear clipboard contents
Clipboard.Clear
'Copy contents to clipboard
Clipboard.SetText Me.ActiveControl.SelText
'Clear contents
Me.ActiveControl.SelText = ""
End If
End Sub
Private Sub mnuEditPaste_Click()
'Ignore errors for combo boxes with a style property of 2
On Error Resume Next
If TypeOf Me.ActiveControl Is TextBox Or _
TypeOf Me.ActiveControl Is ComboBox Then
'Paste contents of clipboard
Me.ActiveControl.SelText = Clipboard.GetText()
End If
End Sub