Refreshing Data Outside Crystal Reports

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.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

NeelMethaAuthor Commented:
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,
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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

Hi NeelMetha,
This old question (QID 20565107) needs to be finalized -- accept an answer, split points, or get a refund.  Please see for information and options.
Glad I could help

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.