Friday, March 23, 2012

Report ciew correct but print no

Hi,
first
Program language visual basic 6 +SP5
Crystal Report 8.5
SQL Server2000

Day2(Namr of report)

the problem
i use these code so when any one click print in report view he can select the printer

UseDefault = False
Day2.PrinterSetup Me.hwnd
Day2.PrintOut True

first time view report its print ok but if i open report again with differnet parameters its showing correct data in report view but after i click print and choose printer it still print the first report

why these happen?I've seen this problem before, a few years ago.
I don't work at the same place now, so I can't go back into SourceSafe and check the code, but I seem to recall we had this problem due to originally not properly disposing of the report object.
If you have a report object open (instantiated) and you then reset some parameters, it may not function properly unless you dispose of the object when you next start a "view" process.
So, when you click on a button to regenerate your view of the report, make sure you do something like this;

set objReport = Nothing
set objParams = Nothing

and then provide code to recreate the objects, which should flush the report object and all objects is has created, and then create a clean new object so you can set parameters.

Davesql

No comments:

Post a Comment