Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing report data from VB application 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello

I'm using VB6(front end) and Access2000(back end)for a data entry application. I'm accessing crystal reports from the vb application. Is it possible to refresh the report data from within the application or to set the crystal reports so that the data is refreshed when printed to the screen?

Thaks in advance
 
If you don't save data with the report Crystal should run and get fresh data. For some reason Crystal defaults to saving data with the report so you have to remove this setting and resave the report.

If this isn't the problem, tell us how you are launching CR in your app. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 

Ken thanks for your help

I removed the 'save data with report' setting and resaved the report. However, the report no longer launches - nothing appears to happen - not even a blank report.

I launch CR the in the following manner:
I've added a CR control to the form and set the following:
ReportFileName - The path and the filename of the report;
Destination - 0
To display the report I've used the printreport method i.e CrystalReport1.PrintReport (attached to command button)

marcus

 
The report runs fine from the report designer and the app is on the same PC as the report design environment?
Are you connecting via ODBC?
You may need to use the connect property before the report is launched:

rptMyReport.Connect = "DSN=MyConnection; UID=MyUser; PWD=MyPWD"
Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Ken

I'm using ODBC and the report designer and app reside on the same PC, and the report runs fine from the report designer.

I will give it a try using the connect property as you suggest.

Thank

Marcus
 
To Ken or Marcus,

Unfortunately, I have exactly the same problem. I have tried the above Connect property and it still doesn't work.

I am using the following command:
EOMBy_Income_BandRPT.PrintReport

However, I do not know what I should code exactly for the connect string. I am interested in what Marcus coded to solve the problem.

What I noted was the Report window is launched, but immediately the window closes automatically.

Would appreciate your assistance here.

Thanks and regards...
 
see faq149-237 and tell us which "integration method" you are using. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Ken,

I apologies for the brief details. I am new to VB and CR and is basically self-trained.

I am using :
* VB6.0
* Crystal Report 6.0
* Data connection is ADO.

As per Marcus, I have :
* Added a CR control in my form, the control is called EOMBy_Income_BandRPT.
* ReportFileName was specified with Destination - 0.
* To display the report, I have used "EOMBy_Income_BandRPT.PrintReport"

Basically, I am using ADO, but for this report, I have specified the database via ReportFileName. I am not sure whether this constitute an ADO connectivity.

The report will launch through VB if I specified "Save data with report" in CR Designer. If I set this option to off, the report will no longer launch through VB (actually launch and closes immediately).

Thanks for for your assistance.
 
If you are trying to pass a recordset to the report you need to design the original report with the "Active Data" driver. Then you need the "SetPrivateData" command in the application to actually send the recordset to the report. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks for your reply Ken,

The report is being excuted from VB, but the data extraction is being done through CR6. However, I did coded in an extra line prior to "printreport" as per below:

EOMBy_Income_BandRPT.DataFiles(0) = "C:\My Documents\Database.mdb"
EOMBy_Income_BandRPT.PrintReport

Again, this still didn't work!
 
First, see faq766-1006

1) Which Crystal components/references did you add to the application (actual file names)?

2) If you open the report and use menu commands:

"Database - Convert database Driver"

What driver is the report using? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks for your reply Ken.

(1) I have removed the 'Saved with data' option from the report. Actually, when I did this, the report did not launch from the VB application. While with 'Saved with data' the report could launch successfully.

(2) I added a Crystal Report Control to the application. Filename 'C:\WINDOWS\SYSTEM\CRYSTL32.OCX'. No further Crystal Report references were made in the application. If there were, its not in the VB book I bought.

(3) The "Database - Convert database Driver" I noted that there were no drivers used. THIS COULD BE IT !! Which driver should I used? VB Data Control ?

Thanks and regards...
 
If the report runs from the report designer than there must be a driver. When you check of the convert (which you will cancel) it will show you the current driver in the window. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks again for your reply.

The Convert Database Driver is 'pdsodbc.dll [ODBC]'. The report launches OK from the CR Designer, but not from VB.

I've noted the following:
(1) I have tried changing several of the drivers and ticked the 'Convert Database Driver on next refresh'. But everytime I go back to the 'Convert Database Driver' window, the 'Convert Database Driver on next refresh' I previously ticked is gone. ie. un-ticked.
(2) Still unable to launch report via VB.

Sorry to waste your time. What I liked to do is to go back to the CONNECT string which worked for Marcus previously, which was :-
"rptMyReport.Connect = "DSN=MyConnection; UID=MyUser; PWD=MyPWD""

Is DSN is the full directory name for my Database. What should UID and PWD be if I was using Access 97 database with no logon/password?

Thanks and regards...
 
DSN is the "Data Source Name" or the name of the ODBC Connection. You shouldn't need a user name and password if there is no security. I don't remember if you pass empty strings for them, or if you just don't include the arguments at all. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I know that the OCX in v8 supports passing recordsets. I would be surprised if that is new with v8 but I haven't tested the prior versions. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
This looks like the right thread for my question. I created a report using VB 6.0 and CR 8.5. The report doesn't refresh itself when the report is rerun using a different dataset. Turning off "Save Data with Report" looks like it might be the answer. How do I turn this option off within VB or can I?
 
You turn it off within the report, and then save the report. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top