Improve company productivity with a Business Account.Sign Up

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

Unwwanted .tmp files with Crystal 8.5/Visual Basic 6.0

I have an application which uses Crystal Reports for reporting. At runtime, each time a report is created, a zero length .tmp file (e.g. 10E.tmp) is created under the root directory. These file persists when the application closes.  I am closing, set to nothing etc everything I can think of at program termination. Can anyone tell me what to do to stop proliferation of these files? (These files are only created when a Crystal Report is created and they are NOT the design time files from VB/Crystal). I can't find an answer anywhere except the general advice to clean up 'everything' at close. Please be as specific as possible  if you have a suggestion. Thanks.

  • 4
  • 2
1 Solution
They are removed when you set all Crystal reports related variables to Nothing. Please recheck whether you are setting all crystal variables to nothing. Also post the code
SSC2004Author Commented:
I am not sure what variables you refer to. I also am not sure I have the correct syntax. Is it possible to set the viewer to nothing? Examples are welcome. Here is a code sample. There are many reports in this application, I have tried to pare down the code to include all the variables. The situation is the same no matter which report is created. Thanks very much for you help.

*On the form that shows the reports :
Dim Report As CRAXDRT.Report
Public DisplayDateRange As String
Public DisplayPlaceField
Option Explicit
Private Sub Form_Load()
Dim ProjectTitle As String
Dim ReportTitle As String
ProjectTitle = "NJ"
ReportTitle = frmReport.frameParams
 Set Report = New CRHelp
Report.ParameterFields.GetItemByName("ParamTitle").AddCurrentValue  ReportTitle
Report.ParameterFields.GetItemByName("ParamNJ").AddCurrentValue ProjectTitle  
CRViewer1.ReportSource = Report
Report.Database.Tables(1).Location = AppPath & "NJ.mdb"
Private Sub Form_Unload(Cancel As Integer)
Set Report = Nothing
End Sub

*Below is the module that is called at program termination

Public Sub UnloadAllForms()
Dim Form As Form

'close all the recordsets by name   (each recordset is closed individually by name for lack of a better way)
'set all the Crystal reports to nothing (each crystal report is closed by name)
Set CRHelp = Nothing

'Unload and Set all the forms to nothing
 For Each Form In Forms
    Unload Form
    Set Form = Nothing
 Next Form
'close all the workspaces and database
Do While Workspaces(0).Databases.Count > 0
Set dbNJ = Nothing
End Sub
What you are doing in your code is absolutely correct. However, the following links would answer your question:

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

SSC2004Author Commented:
That's interesting and sounds similar. The article refers to crw###.tmp when exporting to a pdf but this happens when I view the report and my files are named ###.tmp so I am not sure this is the same thing. I am going to check the service packs but believe we may be up to date.  I have not found any CRW### files out there.
SSC2004Author Commented:

After several tries, I received the following from Crystal Support ...

"Is the application developed using RDC? If yes, then we have come across such a problem that is a known issue for applications using the RDC engine and appears to be specific to Windows XP. The track number is ADAPT00090506. The temp files may be of 0-byte in size and get left in the root directory of the drive running the application. This is an issue with versions 8.5 and 9."

The only workaround they suggested was a batch job to delete files which is not practical in the distributed (consumer) environment for my application. If anyone has found a workaround, please let me know.

Thanks to all who had a look at this question.

SSC2004Author Commented:
Further discussion with Crystal support included the following solution:

"The ADAPT00090506 referenced is not in the external Knowledge Base but it exactly describes your findings - Temp files being created in the root directory only on XP. The problem is with the .dsr files you create inside Visual Basic when creating your reports.

The problem is corrected in the latest version of the RDC in Crystal Reports 10.

The workaround in Crystal Reports 8.5 is to create the report in the Crystal Reports designer as an .rpt file and load it as an external report. You can save your .dsr as a report by right clicking on the report, going to the Report menu and choosing Save to Crystal Reports file.

To load it as an external report, the code would be:

Dim crxApplication As New CRAXDRT.Application
Dim External_Report As CRAXDRT.Report

Private Sub Form_Load()
Screen.MousePointer = vbHourglass

'Using the MS CommonDialog control to prompt for a report name CommonDialog1.InitDir = App.Path CommonDialog1.Filter = "RPT Files (*.rpt)|*.rpt" CommonDialog1.ShowOpen

ReportFileName = CommonDialog1.FileName

Set External_Report = crxApplication.OpenReport(ReportFileName, 1)

'Or opening the report using the path to the report
'Set External_Report = crxApplication.OpenReport("C:\1 - Reports\BasicSQL.rpt", 1)

CRViewer1.EnableExportButton = True
CRViewer1.ReportSource = External_Report

Screen.MousePointer = vbDefault

End Sub

These reports are not embedded in the application and would need to be distributed with your application. "

Points to Sethi for taking a look at it and getting me far enough along to press Crystal for the facts. This problem only seems to exist when the application is run on xp.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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