Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

crystal error crashing VB 6.0 when viewing multiple reports

Posted on 1999-07-16
5
Medium Priority
?
212 Views
Last Modified: 2011-09-20
I've
created 2 reports in crystal using a different table in each. I've got
them on a drop down menu. The menu click code for them is:

CrystalReport1.action = 1   and CrystalReport2.action = 1

If I only view one (either) of the reports when I run it, everything
is
fine. But if I view BOTH, I get the following error message when I close the program and VB
gets shut down entirely. (I can go to other forms before closing and
there is no problem, just when I close the program.):

VB6 caused an invalid page fault in
module CRYSTL32.OCX at 0137:250127fb.
Registers:
EAX=00000000 CS=0137 EIP=250127fb EFLGS=00010202
EBX=0064146c SS=013f ESP=007ff3dc EBP=007ff46c
ECX=00000000 DS=013f ESI=00641274 FS=0f87
EDX=006412ac ES=013f EDI=00000000 GS=0000
Bytes at CS:EIP:
c7 41 04 00 00 00 00 c3 56 8b f1 83 79 04 00 74
Stack dump:
2500e831 00641284 00641274 00000000 25003832 00641274 25003765
00641274 2501ca30 00000001 00000006 0175f9b4 0041eb1b 00641280
0000105c 0175f9b4

Is there a solution for this?

0
Comment
Question by:dtmaurer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
apratima earned 600 total points
ID: 1525296
Yes it happens, which is you can say is drawback of using two crystal controls simultaneously.
In Normal cases what we do is we call report from a form and after completing the report viewing we come back to same form, means yuor form is not yet unloaded.
But in this case where we use 2 crystal controls simultaneously as soon as you write statements
CrystalReport1.Action
CrystalReport2.Action

you should write

Unload Me

Which will solve your problem. If You don't want it this way
Other solution is as follows.
Don't use 2 crystal controls. You can do it with single crystal control as follows:

After you say

CrystalReport1.Action

Again write the code for setting values for another report using the same control and again say

CrystalReport1.Action

In this case you Don't have to Unload current form.
If you think explaination is not sufficient or have any doubts regarding this you can ask I will explain in details.

0
 

Author Comment

by:dtmaurer
ID: 1525297
I have changed my code as follows:

Private Sub mnuCustomerReport_Click()
CrystalReport1.Action = 1
Unload Me
End Sub

Private Sub munInventoryReport_Click()
CrystalReport2.Action = 1
Unload Me

But when I click on the menu, the report opens but then disappears with the form and the
program ends.  Have I understood your instructions correctly?
End Sub

0
 
LVL 1

Expert Comment

by:apratima
ID: 1525298
No no, ..
Ok
Are U placing Your crystal controls on the main form?
And directly running the report after selecting menu option?
I think yes.
I am Sorry.
I thought it other way
You have to change your program little bit, follow steps
1)Don't directly place controls on the main form from where you are invoking the menu.
2)When you click the menu option for report display a form in which you will place your crystal control.
You can also place two Command Buttons "Start" and "Cancel" or something simillar on that form.
3)In your start button you can give necessary code for displaying a report (which right now you are coding in menuitems click events)
Unload me is not needed in that case because you will be using only one crystal control for that particular form.
4)Repeat the steps 1-3 for all the reports you have in your program.
5)Remove the code CrystalReport1.Action and whatever from your Menu items click event instead you have to say
FormName.Show


The advantage of following this method is
1)In future if you like to pass some parameters to your report by taking input from user You can do it by placing desired controls on your form (having Crystal Control)
2)All the time you will not be using each and every report but as soon as your Main Form gets loaded all the crystal controls will also be loaded in memory and will stay there untill your application ends which is not advisable.


Okay, If you need any help on this don't hasitate to email me, b'cos I may not be able to log on this site frequently during weekends.
Bye


0
 
LVL 1

Expert Comment

by:apratima
ID: 1525299
Isn't it a long time since you havn't gave any comment for my comeent
0
 

Author Comment

by:dtmaurer
ID: 1525300
Sorry for the delay.  I used only one control and changed the report info in the menu click event.  Thanks so much!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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.
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…
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…
Suggested Courses

705 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