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:

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.


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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now