Link to home
Start Free TrialLog in
Avatar of vickyboyy
vickyboyy

asked on

Crystal Reports 10 app crash when report is previewd 2nd time

I made a vb6 app that shows pre disigned reports in Crystal reports 10, i use a form with Crystal report viewer Activx control. it was working fine until a week ago suddenly it start crashing. when i run my app from vb6 IDE the first time, i can see a report and when i want to see a second report or the same again app just crash and VB IDE crash also sometime telling me that vb6.exe stop working and Send this error .... sometimes it give me a memory error right after i click " Dont send" , it says that the memory could not be "read" and the two location it points are always the same e.g 0x032e2110. any idea what im doing wrong ??
Avatar of Mike McCracken
Mike McCracken

Has anything changed on the machine?
O/S fixes?

What code are you using to run the application?

When you close the viewer what code runs to cleanup the VB objects?

mlmcc
Avatar of vickyboyy

ASKER

thanks for the reply
nothing changed on my machine only if you consider it a change i change my monitor, on my Win xp pro nothing is changed. no new softwares installed, no service pack nothing, after i have this problem i installed sp6 for vb6, it didnt helped. i made an installer for my app and installed on a machine with win xp pro, there i can not open the form for previewing reports. if i open it the app crash immediatly. on a notebook i installed xp home and sp2 for xp. and then i installed my app and all is working i can see the reports without any problem. one thing more what i saw yesterday was that when i add crystal designer to my app in vb6 and run it then it dont give me any error and no crash....but i make an installer with designer added to my app  and try it on a machine with xp pro ..... same crash occurs...here is my code  ( it was working without any problem till a week ago) ... when i dont add crystal designer then i can view one report. second time i want to view the same report or an other report, Crash with or without memory read error but always with " visual basic encounterd bla bla bla ......"

ReportViewRqs is a Global string type

Private Sub Form_Load()


Dim CrReport As CRAXDRT.Report
Dim appcr As CRAXDRT.Application
Dim coninfo As CRAXDRT.ConnectionProperties
Dim CrxTable As CRAXDRT.DatabaseTable
Dim CrTables As CRAXDRT.DatabaseTables
Dim CrTable As CRAXDRT.DatabaseTable

Me.MousePointer = vbHourglass

Set CrReport = New Report
Set appcr = New Application

Dim rpath As String
Dim password As String
password = "MypassworD"



If ReportViewRqst = "Duo" Then




    rpath = App.Path + "\reports\" + "Duo.rpt"
 

    Set CrReport = appcr.OpenReport(rpath)
   
    For Each CrTable In CrReport.Database.Tables
            CrTable.Location = App.Path + "\Database\FIGHT.mdb"
        Next
   
   

    For Each CrxTable In CrReport.Database.Tables
            CrxTable.SetSessionInfo "", Chr(10) & password
        Next CrxTable
   
 CrReport.RecordSelectionFormula = "{Fightsystem.Fight_ID}=1"
   
   
   
  ElseIf ReportViewRqst = "Fighting" Then




    rpath = App.Path + "\reports\" + "Fighting.rpt"
 

    Set CrReport = appcr.OpenReport(rpath)
   
    For Each CrTable In CrReport.Database.Tables
            CrTable.Location = App.Path + "\Database\FIGHT.mdb"
        Next
   
   

    For Each CrxTable In CrReport.Database.Tables
            CrxTable.SetSessionInfo "", Chr(10) & password
        Next CrxTable
   
 CrReport.RecordSelectionFormula = "{Fightlist.Fightsystemid} = 2 and {Fightlist.Fightid} = 1"
   

 
 
End If
Cr.ReportSource = CrReport




Cr.ViewReport
Me.MousePointer = vbNormal
Set CrReport = Nothing
Set appcr = Nothing
Set coninfo = Nothing
Set CrxTable = Nothing
   

End Sub

hope to see your comment soon while i have to finish this in this week ..Thanks again

You might change the order of the Set to nothing

Set CrxTable = Nothing
Set coninfo = Nothing
Set CrReport = Nothing
Set appcr = Nothing
   
In that way you are working out from the inards of the report.  When you set the report object to nothing you may alsio be deleting the memory pointed to by the connection info and the tables.

mlmcc
i was waiting for your answer all the time...
i tried it ... same as before .. crash

is there a simple way to display reports. am i using anything which i really dont need and may be that is the caus of my problem. i dont know much about crystal reports 10.
waiting.......
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi
i try to do it your way and without any selection formula, just to show the report as it was saved in crystal report 10. it also didnt worked. can you tell me that is there any diffrence between CR 10 and CR XI and which one is supported on Vista. i tried to install my app on vista and it gaved me a dependency error for crviewer.dll ( installed and run as admin). can i use CRXI with vb6. will it bring something good. i mean that can i get rid of this error if i use CR XI

thanks for your help.
Regards
CR XI with a service pack is supported on Vista.

If you have CR XI R1 (11.0.xx) then it is SP4
If you have CR XI R2 (11.5.xx) then it is SP2

I don't think CR10 is supported on Vista.

mlmcc
You can use CR XI with VB6.  That is the last version that will support VB6.

mlmcc
the last thing i want to know. can you give me a link to a good tutorial for CR XI to use with vb6. or any website where i can learn more about CR XI ....
Thank you for your time and help.
and To create install package for vista.
Unfortunately I can't give you one for use with VB6.

The best I can do is refer you to the references I use which are the complete reference series.

The Complete Reference Crystak Reports nn by Peck

http://www.crystalbook.com/crtcr/program/book/home.asp

mlmcc
Hey
I found out what i was doing wrong. i want to share that with you. i found that in CR 10 examples and then i examin your code and there it was also. so what was going wrong. in my code ...


Dim CrReport As CRAXDRT.Report
Dim appcr As CRAXDRT.Application
........
.......

here is the PROBLEM  im setting CrReport as new report butt i have to set it as New CRAXDRT.Report
and the same for .Application ....
and what i was doing wrong ...

Set CrReport = New Report
Set appcr = New Application

i tried it and it workd 100%
Thanks that you took interest in my problem. i will accept your example as solution. afterall you are the only one here who is trying to help me and you did.
CHEERS
Thank you ... I tried all the ways to resolve this problem but it's never help
and then I simply define the report  object generaly and  Realy it's working with me very good
thank you guys