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:

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.


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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA to copy paste columns form one file to other 20 88
Passing a Text Box name to a Sub 6 96
MsgBox 4 61
Problem to With line 4 57
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

809 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