• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1520
  • Last Modified:

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

0
Iamtehbest
Asked:
Iamtehbest
  • 3
  • 2
2 Solutions
 
mlmccCommented:
DO you need to export from the viewer or can you export from code

'
'   Set export options
'
    Report .ExportOptions.DestinationType = crEDTDiskFile
    Report .ExportOptions.DiskFileName = txtAttachmentFile
    Report .ExportOptions.FormatType = crEFTWordForWindows
    Report .Export False
   
    Set crRpt = Nothing

When you export from the viewer do you get to enter the path?
If you select application does the application open and have data?

mlmcc
0
 
IamtehbestAuthor Commented:
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
0
 
mlmccCommented:
There was an issue at one point which resulted in 0 byte files.

Apparently it is a known issue and was never resolved for CR7.

If you export through code does it worK?
If so you could add an export button of your own and do the export.

mlmcc
0
 
IamtehbestAuthor Commented:
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
0
 
mlmccCommented:
I don't know for sure.

I think it was crEFTXLS

mlmcc
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now