Refreshing Data Outside Crystal Reports

Posted on 2003-03-27
Medium Priority
Last Modified: 2011-10-03
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

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.

Question by:NeelMetha
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

Expert Comment

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.


Author Comment

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,
LVL 101

Accepted Solution

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
Add the CR designer

YOu will also need to add the references
Add the CR Design time libraries.

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 8223215
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 :~)


Expert Comment

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.
LVL 101

Expert Comment

ID: 8538004
Glad I could help


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 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