0 Replies - 1204 Views - Last Post: 24 June 2013 - 11:29 AM Rate Topic: -----

#1 Pegasus40218   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 24-June 13

Crystal Reports 8.5 Static Letter Template

Posted 24 June 2013 - 11:29 AM

Unfortunately, there are still some of us stuck in VB6 and Crystal 8.5...Anyway here's the problem:

I have an application that runs against some flat files for data, so there is no database at runtime or design time. We use Crystal Reports to provide all of our printing / reporting capabilities, using the SetTablePrivateData function to bind a recordset to the report at run time. For the most part, this works pretty well.

I've been asked to create a static letter template (no actual data, just fixed text values). Again, this was not a problem -- just create a report with no data source and a bunch of Text fields. However, at run time, if I attempt to generate this letter AFTER a report with data has been run, I get a runtime error: 20000 "no error".

The code being used to generate reports that contain data looks like this:

                Set rs = BuildReportRecordset
                Set rs.ActiveConnection = Nothing
                crViewer.SetTablePrivateData 0, 3, rs
                crViewer.ReportFileName = ReportFile
                crViewer.WindowShowPrintSetupBtn = True
                crViewer.Destination = crptToWindow
                crViewer.WindowState = crptMaximized
                crViewer.Action = 1

(Notes: rs is an ADO Recordset object that gets constructed and populated in the BuildReportRecordset function. crViewer is a reference to a Crystal Reports OCX on a form.)

The code being used to generate the letter looks like this:
    Path = REPORT_PATH
    filename = GetLetterFileName(ClientID)
    With crViewer
        .ReportFileName = Path & filename
        .WindowShowPrintSetupBtn = True
        .Destination = crptToWindow
        .WindowState = crptMaximized
        .Action = 1
    End With

If the letter code is run first (before a report with data), it works perfectly -- the first time only. If it's run after a report with data, I get the error 20000.

What I've tried:
I've tried calling the SetTablePrivateData method of the Crystal Reports OCX and passing in "Nothing" for the recordset.
I've tried passing in a recordset that has been created (i.e., it's an object, not Nothing) but not populated.

What I'm after
I'm thinking that there should be some way to "clear" whatever is being set behind the scenes by the SetTablePrivateData method -- because apparently, the "Reset" method isn't doing it. If anyone knows how to do what I need, I'd love to hear about it!


This post has been edited by andrewsw: 24 June 2013 - 11:57 AM
Reason for edit:: Please use CODE tags

Is This A Good Question/Topic? 0
  • +

Page 1 of 1