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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL -- > VB -- > Crystal Report

Status
Not open for further replies.

netcashin

Programmer
Nov 13, 2000
159
US
Quick background. At a previous job we had a crystal expert who created all the crystal reports and then we passed values to the reports through VB apps. We were using Crystal 7.0 at the time I believe.

I am at a different job now and the Crystal expert has left her job and I have no contact with her. Currently, I have Crystal 8.0. I am missing some of the details on how to accomplish this.

Basically all I am doing is allowing the selection of records to be done in the VB app with the data coming from a SQL server and then wanting to pass along the recordset to a Crystal Report without the Report having any connection to the database. The report would only get the data from the application. The fields for the recordset would not change, only the values would change.

I have been reading through the help sections but I am starting to get pressed for time, so I am looking for some direction. Any help or ideas would be appreciated.

Thanks in advance.

 
My example assumes you're using the automation server:

Dim DbTables As CRPEAuto.DatabaseTables
Dim DbTable As CRPEAuto.DatabaseTable
Dim Db As CRPEAuto.Database
Dim Report as CRPEAuto.Report
Dim StockDB as DAO.Database 'or ADO, etc.
Dim RecordSet as DAO.Recordset 'or ADO, etc.

Set Db = Report.Database
Set DbTables = Db.Tables

For Each DbTable In DbTables
If DBTable.Location="Stock.TTX" Then
'Open the correct recordset, eg:
Set Recordset = StockDB.Openrecordset("Stock"...)
Elseif DBTable.Location="SomethingElse.TTX" then
'open a recordset
Endif

'Pass the recordset into the report:
DbTable.SetPrivateData 3, RecordSet
Next DBTable
**********************

I assume you're using ttx files as you are passing in recordsets. The above code loops through the tables saved in the report file. If if finds one called Stock.TTX, it opens a stock recordset and passes it in.

Hope some of this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top