Link to home
Start Free TrialLog in
Avatar of NeelMetha
NeelMetha

asked on

Refreshing Data Outside Crystal Reports

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
----
Avatar of hmadhur
hmadhur

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
Avatar of NeelMetha

ASKER

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
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 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
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.
Glad I could help

mlmcc