Link to home
Start Free TrialLog in
Avatar of aqk139
aqk139

asked on

Passing data to crystal reports

I need to pass a record set to a crystal report, how to do that? I have created data definition file and also design a report. Now from Visual basic I want to send a record set to this report. I have made a record set but don't know how to send this record set to the report which I dessign above.

If I am moving in wrong direction then please guide me in correct direction

Help required.

Thanks
AQK
Avatar of rprathab
rprathab

Design report as per ur requirements.
Then use rpt.selectionformula="{emp.idno=& txt1.text & }"

here u give the criteria
thatz it
Hi!

Dim crxApplication As New CRAXDRT.Application
Dim Report as craxdrt.Report
Dim Table as craxdrt.Table

'Open your report
Set Report = crxApplication.OpenReport("C:\.Report.rpt")
'(1=index of the table in the tables collection)
Set Table = Report.Database.Tables(1)


Call Table.SetPrivateData(3, rs)
'Where rs is your recordset

Hope it helps!
/Egget
aqk139

You can also pass parameters to a crystal report and have the report get its own record set.

1st create the crystal report with all the relevant parameters etc.

You then pass the specific parameter values to the crystal report.

The report then queries the DB and prints the results. ie it gets its own record set.

Here is an example of a report where you pass 2 parameters (employee name and year) to a report, and it then gets the relevant info.

On Error GoTo Err_Handler
Dim ReportPath
    ReportPath = "\\Hell\Library\Crystal Reports\Holidays & Sickness\"
    CRHol.ReportFileName = ReportPath & "H12 Holiday Detail (Specific Employee).rpt"
    CRHol.ParameterFields(0) = "Employee;" & cboEmployees.Text & ";true"
    CRHol.ParameterFields(1) = "Year;" & UCase(cboYear.Text) & ";true"
    CRHol.Connect = "DSN=" & EngSchedDataSource & ";UID=" & EngSchedUsername & ";PWD=" & EngSchedPassword & ";DSQ=" & EngSchedDataBase
    CRHol.Destination = crptToWindow
    CRHol.PrintReport

Exit Sub
Err_Handler:
    MsgBox Err.Number & vbCrLf & Err.Description, vbExclamation, "Error 'Run_Report_H12' code"
I recommend you to use the ActiveReport, which is much better than both DataReport and CrytalReport.
You can download it from www.datadynamics.com
it's very useful and easy...try it!
ASKER CERTIFIED SOLUTION
Avatar of SWEngineer
SWEngineer

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 AQK,

I forgot to add a tip to my previous posting. All reports were aggregated, sorted, joined, etc on the server side.

The reports were doing nothing more than displaying the recordsets and were very fast due to little or no work done on the client side.

You can use the CRW scripting and functions to format data on the client side for presentation only ... I can provide sample stored procedures, reports, etc if needed.

Good luck!
There has been no activity in this question in quite some time, and it looks like it has been abandoned. As part of our ongoing mission to clean up the topic areas, a Moderator will finalize this question within the next seven (7) days. At that time, either I or one of the other Moderators will force/accept the comment of SWEngineer.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER. If you have further comments on this question or the recommendation, please leave them here.

aqk139,

Some of these questions have been open for some time, and records indicate you logged in as recently as last week. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days.

https://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=20202508
https://www.experts-exchange.com/jsp/qShow.jsp?ta=crystal&qid=20255526
https://www.experts-exchange.com/jsp/qShow.jsp?ta=oracle&qid=20167212
https://www.experts-exchange.com/jsp/qShow.jsp?ta=oracle&qid=20165928
https://www.experts-exchange.com/jsp/qShow.jsp?ta=oracle&qid=20141926
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20243322
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20207867
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20207526
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20191215
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20183720
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20180355
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20175537
https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20175003

Thanks,

Netminder
Community Support Moderator
Experts Exchange
Admin notified of user neglect. Force/accepted by

Netminder
Community Support Moderator
Experts Exchange