Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Refreshing Data Outside Crystal Reports

Posted on 2003-03-27
6
Medium Priority
?
355 Views
Last Modified: 2011-10-03
Hi:
I'm using VB6 with the Report Designer that comes with it
I have a VB application that accepts certain data from a user, and
places this data in a MS Access Database. When the user selects the
print command on my VB App, the data that he/she entered shows up as a
Crystal Report. I am using the Crystal Report 4.6 control
(crystl32.ocx).

The problem I am having is that the report that shows up is using data
that I had when designing the report, and not the data that the user
enters from my VB application. Many people have suggested doing this
before printing:

CrystalReport1.DiscardSavedData = True. But it doesn't help. I also
tried this

Set CrystalReport1 = Nothing
Set CrystalReport1 = CreateObject("Crystal.CrystalReport")

- and have not been successful.

In summary, what I need is a command that would trigger a response
similar to  selecting Report->Refresh Report Data in Crystal Reports

Any suggestions & help would be appreciated.

Neel
----
0
Comment
Question by:NeelMetha
6 Comments
 
LVL 1

Expert Comment

by:hmadhur
ID: 8217936
Crystal Reports 4.6..hmmmm Frankly I have not worked on any Crystal version less than 7. So...
First some questions:

Microsoft has stopped shipping Crystal Reports with Visual Studio. So this 4.6 is really very old version. Where do you create the Report? Do you create the report in VB environment? Or do you have a seperate designer that allows you to create report files with .rpt extension?

Secondly, you say you are using Crystal32.ocx to display the Report? This is what confuses me. Because reports created using the Designer component cannot be shown using ActiveX Control.

Thirdly, Do you get refresh button on the report preview window? If not try setting the WindowShowRefreshBtn property to true. This will make the refresh button appear on the preview window. Try clicking on that.

Better shift to the latest version of Crystal Reports (9.0) or version 7 also works fairly good (with some bugs of course).

See if this helps. Or you can always get back.

Regards
Madhur
0
 

Author Comment

by:NeelMetha
ID: 8218100
To answer your questions:
1 - I created the report in the 4.6 version that comes with VB6
2 - Well this is the code I use to print the report to screen

Dim CrystalReport1 As Object

Set CrystalReport1 = CreateObject("Crystal.CrystalReport")
CrystalReport1.ReportFileName = App.Path & "\db1report.RPT"
CrystalReport1.DiscardSavedData = True
CrystalReport1.Destination = crptToWindow
CrystalReport1.Action = 1

When I remove the line CrystalReport1.DiscardSavedData = True, the report prints the old data as I mentioned in my question. When I put it the report is blank.

3- I don't get any refresh button. There is no WindowShowRefreshBtn. property in the Crystal Report Control

4- I have CR8, but how do I refer to (or install) the CR Control component in VB?

Maybe you could enlighten me on how I could use the Designer component that you mention in your comment

Thanks for the help,
Neel
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 100 total points
ID: 8218425
Actually CR4.6 still ships with Visual Basic and Visual Studio ver6.  It is in a strange location and doesn't automatically install.  You have to install it yourself.

You need the
CrystalReport1.DiscardSavedData = True
to discard the saved data.

If you remove it and hit the refresh button on the viewer what do you get?

CR8 - Install it on the machine with VB.  I would uninstall CR4.6 first.
It should add itself to the VB

You may have to
Open the project
Click PROJECT --> COMPONENTS
Click DESIGNERS
Add the CR designer

YOu will also need to add the references
Click PROJECT --> REFERENCES
Add the CR Design time libraries.

mlmcc
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:hmadhur
ID: 8223215
Hi
I completely agree with mlmcc. When you install CR8, it will automatically be added into VB designers. If not then you will have to add it by going into Project->Components and Click on Crystal Reports 8. After this when you right click on the Project Explorer window and point to Add you will get Crystal Reports 8 in the context menu.

After this go to Project->Components and select Crystal Report Control. Add the crystal Report Control on your form and name it Report1.

Then write the code in form load event:

Report1.ReportFileName = App.Path & "\db1Report.Rpt"
Report1.DiscardSavedData = True
Report1.Action = 1

This should do it. Now if you look in the properties of the Crystal Report Control you should get the property WindowShowRefreshBtn. This property will show the refresh button on the preview window.

Right Click on the Crystal Report Control and click on the Crystal Properties menu option. You will see various prperties. Properly go through each of them. Crystal Reports is wonderful. You can build almost any kind of report. Go through the Developers help also. They also have some samples on how to write code in VB.

Check it out. CR8 is much better than CR4.6 :~)

Regards
Madhur
0
 

Expert Comment

by:CleanupPing
ID: 8531520
Hi NeelMetha,
This old question (QID 20565107) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8538004
Glad I could help

mlmcc
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 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…
Suggested Courses

580 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