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!

Passing recordsets to Crystal Reports 8.5. 2

Status
Not open for further replies.

magicscreen

Programmer
May 4, 2001
10
US
How do I set up a ttx file for Crystal Reports in order to pass it a recordset? I would like to get the data in a vb 6 program and then pass the recordset to Crystal Reports 8.5.

What is the structure of a ttx file and what are the valid entries?

 
There is info on TTX files on the Seagate Web site, but you can create reports that accept recordsets without using TTX files. You can create the report using the Active Data Driver, and then pass it a recordset that matches the fields used in the report. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
(I found the answer to my own question) Here's what I used in CR8, if you're good at sql, you will like this alot:

'this code sample illustrates how to pass two records from an ADO recordset, to a report
'that has two formula fields (in the Details section) and NO database connection.

Dim Report As New CrystalReport1
Dim ADOrs As ADODB.Recordset
Dim DBLocation As String

Private Sub Form_Load()

'Show the common dialog to select the sample database
CommonDialog1.ShowOpen

'binds the ADO recordset object to ADO recordset variables
Set ADOrs = CreateObject("adodb.recordset")

'sets cursor location for recordset
'the CursorLocation, CursorType and LockType in this sample are the recommeneded
'choices when working with the Crystal Reports active data driver.
ADOrs.CursorLocation = adUseClient

'open the recordset
ADOrs.Open "select * from customer", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & CommonDialog1.FileName & ";Persist Security Info=False", adOpenDynamic, adLockBatchOptimistic

'add the ADO recordset to the report
Report.Database.AddADOCommand ADOrs.ActiveConnection, ADOrs.ActiveCommand

'these variables will be used in the Check method to validate the formula fields
Dim x As Boolean
Dim y As String

'Note: once the ADO recordset is added to the report it is referenced as a table object within
'the report

'pass the first field name from the added ADO recordset to the first formula field in the report
Report.FormulaFields(1).Text = Report.Database.Tables(1).Fields(1).Name
'match the field name from the ADO recordset for a column header
Report.Text1.SetText ADOrs.Fields(0).Name
'validate the formula field
Report.FormulaFields(1).Check x, y

'pass the second field name from the added ADO recordset to the second formula field in the report
Report.FormulaFields(2).Text = Report.Database.Tables(1).Fields(3).Name
'match the field name from the recordset for a column header
Report.Text2.SetText ADOrs.Fields(2).Name
'validate the formula field
Report.FormulaFields(2).Check x, y


Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault

End Sub
 
i found that you are using commondialog box for getting the database connection.
i have problem like, i build my recordset using append.fields property of adodb.recordset object.i getting data for this recordset from xml object transported from remote server.i want to use this recordset as data sources for my report.
please help me imm in this regard
 
ftam,

I saw your code for this and it makes sense. But I'm dealing with a slightly different problem I think.

My recordset is not associated with an active connection. It gets passed in rather than created in this portion of code.

So, my application blows up if I try to use
Report.Database.AddADOCommand ADOrs.ActiveConnection, ADOrs.ActiveCommand

Did you come across anything like this in your travels?

Thanks for any help!
 
I am generating a bar chart and I want to display the sales on change of visitdate and brand name. The graph is ok utill i pass the sql querry. When i pass sql querry to chart it display the graph with x-Axis with visitdate but on legend it display the visitdate instead of brand name.
 
Does anyone know if you could create a dll that would read a database, perform calculations on those records, create a detached recordset and feed it to the crystal reports runtime engine? This is intended to be a web application where multiple instances could be running simultaneously. I'm thinking I'd create a VB activeX dll to do the calculations and reference the engine.

Has someone out there done this or know how I could go about doing it?

Thanks!
 
I am developing a reporting software that we will serve to our clients and need help understanding how we might use Crystal Reports with VB6 to report upon data that is queried from a database and subsequently processed by our VB application rather than data that is simply reported upon directly from the database. In other words, our data is 'in-memory' application data. How can I pass this 'in-memory' data to CR?
 
Can this 'in-memory' data be captured as a vb recordset? Crystal reports can be designed to accept a recordset passed from a VB application. The commands and syntax vary with the integration method. See faq149-237. The options are: OCX, RDC, API, Automation Server.

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