Unwwanted .tmp files with Crystal 8.5/Visual Basic 6.0

Posted on 2004-04-05
Last Modified: 2007-12-19
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.

Question by:SSC2004
  • 4
  • 2
LVL 18

Expert Comment

ID: 10758220
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

Author Comment

ID: 10758770
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
LVL 18

Accepted Solution

Sethi earned 500 total points
ID: 10758998
What you are doing in your code is absolutely correct. However, the following links would answer your question:

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.


Author Comment

ID: 10759428
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.

Author Comment

ID: 10776046

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.


Author Comment

ID: 10932209
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.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question