Link to home
Start Free TrialLog in
Avatar of Iamtehbest
Iamtehbest

asked on

VB6 + Crystal Reports 7 Viewer - Export creates blank file

I have a VB6 application that uses the CRViewer control to display a report, the report displays perfectly, but when I click the Export button the file created is blank.  This occurs with all of the options (Excel 7.0, TXT, RTF, Word, etc).  I would prefer to export it to an Excel 7.0 but Word would also be acceptable.

Steps I have tried:
Can export from another application that is not using CRViewer control but the CrystalReport control.
Reinstalled CR 7 to be safe
Copied all DLLs from c:\winnt\crystal to c:\winnt\system32 and registered.

Any help would be appreciated.  This is a Windows 2000 development pc.

Code for the CRViewer open & populate:

Public ReportEngine As New CRAXDRT.Application

Private Sub Form_Load()
    Dim Xrec As New ADODB.Recordset
    Dim Yrec As New ADODB.Recordset
    Dim Zrec As New ADODB.Recordset
    Dim SubReport As CRAXDRT.Report
    Dim SubReport2 As CRAXDRT.Report
    Dim temp As Integer
    Set Report = ReportEngine.OpenReport(Crystal_ReportPath)
    Report.ReportTitle = Crystal_ReportName
    Xrec.Open Crystal_SQL, MyDB, adOpenForwardOnly, adLockOptimistic, adCmdText
    temp = Report.Database.Tables.Count
    For i% = 1 To Report.Database.Tables.Count
        Report.Database.Tables(i%).SetLogOnInfo "", "", "", ""
    Next i%
    Report.DiscardSavedData
    Report.Database.SetDataSource Xrec, 3
    If Crystal_SubReportPath <> "" Then
        Set SubReport = Report.OpenSubreport(Crystal_SubReportPath)
        SubReport.DiscardSavedData
        SubReport.Database.SetDataSource Yrec, 3
        Yrec.Open Crystal_SubSQL, MyDB2, adOpenForwardOnly, adLockOptimistic, adCmdText
        For i% = 1 To SubReport.Database.Tables.Count
            SubReport.Database.Tables(i%).SetLogOnInfo "", "", "", ""
        Next i%
    End If
    If Crystal_SubReportPath2 <> "" Then
        Set SubReport2 = Report.OpenSubreport(Crystal_SubReportPath2)
        SubReport2.DiscardSavedData
        SubReport2.Database.SetDataSource Zrec, 3
        Zrec.Open Crystal_SubSQL2, MyDB, adOpenForwardOnly, adLockOptimistic, adCmdText
        For i% = 1 To SubReport2.Database.Tables.Count
            SubReport2.Database.Tables(i%).SetLogOnInfo "", "", "", ""
        Next i%
    End If
    Me.Caption = Report.ReportTitle
    Screen.MousePointer = vbHourglass
    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport
    Screen.MousePointer = vbDefault
    Me.Visible = True
    Do
        DoEvents
    Loop Until CRViewer1.IsBusy = False
    CRViewer1.Zoom 125
    Set Xrec = Nothing
    Set Yrec = Nothing
    Set Zrec = Nothing
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Iamtehbest
Iamtehbest

ASKER

mlmcc:

Yes, I need to export from the viewer.
Yes when I export from the viewer I get to enter the path, the file is created, it is just empty (0 bytes)
No, if I select application the application does not open.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mlmcc:

I tested out the code you provided for exporting from code, and it did work, do you by any chance know the .formatType for exporting to Excel?

Thanks
I don't know for sure.

I think it was crEFTXLS

mlmcc