
-2147206429 (80043ae3) Invalid TLV Record
I want to be able to keep my reports external to
my application (in .rpt format) but view the
reports using the Smart Viewer (CRViewer). This works fine on my own
computer, but it does not work on my managers computer. We both have
Crystal Reports 8.5 installed on our machines.
I've tried the following code;
Private Sub cmdViewReport_Click()
Dim ldtmReportDate As Date
ldtmReportDate = Now()
Load frmReportViewer
frmReportViewer.LoadReport "ftr.rpt"
frmReportViewer.DisplayReport
frmReportViewer.Show vbModal, Me
End Sub
---------------------------------------------
frmReportViewer code:
---------------------------------------------
' To use this form
'
' 1) load the form
' Load(frmReportViewer)
'
' 2) define type of form to load
' frmReportViewer.SetReport "ReportA001Clin"
'
' 3) define parameters
' frmReportViewer.SetParameter "TIStatus", 4
' frmReportViewer.SetParameter "BeginDate", #5/28/2001#
'
' 4) display report
' frmReportViewer.DisplayReport
'
Dim mobjReport As Report
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
CRViewer1.Zoom 100
CRViewer1.EnableExportButton = True
End Sub
Public Sub LoadReport(ByRef pstrFileName As Variant)
Dim lobjApp As CRAXDRT.Application
Dim lstrLocation As String
Dim llngIndex As Long
Set lobjApp = New CRAXDRT.Application
Set mobjReport = lobjApp.OpenReport(App.Path & "\Reports\" &
pstrFileName, 1)
Set lobjApp = Nothing
' Switch the location stored within the report itself
lstrLocation = mobjReport.Database.Tables(1).Location
llngIndex = InStr(1, lstrLocation, "Proc(", vbTextCompare)
lstrLocation = Database & ".dbo." & Mid(lstrLocation, llngIndex)
mobjReport.Database.Tables(1).Location = lstrLocation
' Login to server
mobjReport.Database.Tables(1).SetLogOnInfo gstrDBServer,
gstrDBDatabase, "MyUsername", "MyPassword"
End Sub
Public Sub SetReport(ByRef pstrReportName)
Dim lstrLocation As String
Dim llngIndex As Long
Set objReport = Nothing
Select Case pstrReportName
Case "ReportA001Clin"
Set mobjReport = New ReportA001Clin
Case "ReportA001Slin"
Set mobjReport = New ReportA001Slin
Case "ReportA001TI"
Set mobjReport = New ReportA001TI
Case "ReportA004Main"
Set mobjReport = New ReportA004Main
Case "ReportLstOfCmpTIbyDate"
Set mobjReport = New ReportLstOfCmpTIbyDate
Case Else
MsgBox "Could not load report."
Call Unload(Me)
Exit Sub
End Select
With mobjReport.Database
lstrLocation = .Tables(1).Location
llngIndex = InStr(1, lstrLocation, "Proc(", vbTextCompare)
lstrLocation = gstrDBDatabase & ".dbo." & Mid(lstrLocation,
llngIndex)
.Tables(1).SetLogOnInfo gstrDBServer, gstrDBDatabase
.Tables(1).Location = lstrLocation
End With
End Sub
Public Sub SetParameter(ByRef pstrName As String, ByRef pvarValue As
Variant)
On Error Resume Next
If mobjReport.ParameterFields.GetItemByName(pstrName).IsCurrentValueSet
Then
mobjReport.ParameterFields.GetItemByName(pstrName).ClearCurrentValueAndRange
End If
mobjReport.ParameterFields.GetItemByName(pstrName).AddCurrentValue
pvarValue
If Err Then
MsgBox "Got an error setting parameter """ & pstrName & """ to
:" & pvarValue & vbCrLf & vbCrLf & Err.Description
End If
End Sub
Public Sub DisplayReport()
CRViewer1.ReportSource = mobjReport
DoEvents
CRViewer1.ViewReport
DoEvents
Screen.MousePointer = vbDefault
DoEvents
On Error Resume Next
Me.Show
End Sub
Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub