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

Sub Report using recordset in VB

Status
Not open for further replies.

tonioJ

Programmer
Oct 7, 2002
90
PH
Hello everyone!

I have a report and almost all of the values are taken from recordset. I am using Field Definition to design my report in Crystal Report 8.5 for ease deployment of the application. I only know how to pass data from recordset to CR with no sub report inside. To pass the values of recordset to report use the code below:

---- sample code start here
dim rs as new ADODB.RECORDSET

rs.open "Select * from customer"

crpt1.reportfilename = app.path & "\report1.rpt"
Crpt1.SetTablePrivateData 0, 3, rs
Crpt1.action =1

---- end of my sample code

Again, I use the code above to pass the value of recordset to a report with no subreport.

Now, the problem is:
1. How do you pass the value of recordset to subreport of report?
2. Any sample codes for reference?

I need your help badly because I'm running out of time to implement my project. Please help. Thank you in advance.
 
It looks like you are using the OCX, so I would look up the "SubreportToChange" command in Crystal's help, which allows you to pass the same properties to the sub as you do to the main.

BTW, I think using "SELECT *" is risky with recordsets passed to CR, because the order of the fields in the RS has to match the order of the fields in the Field Definition. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
hello ken,
thanks for replying...
yes it's true that it is dangerous. because report will not work accordingly when the structure of tables will change. so let me change the statement "rs.open "Select * from customer" to


rs.open "SELECT LASTNAME, FIRSTNAME FROM CUSTOMER", dbcnn, .....

so here's the new problem posted next to this thread to avoid confusion.

 
Hello everyone!

I have a report and almost all of the values are taken from recordset. I am using Field Definition to design my report in Crystal Report 8.5 for ease deployment of the application. I only know how to pass data from recordset to CR with no sub report inside. To pass the values of recordset to report use the code below:

---- sample code start here
dim rs as new ADODB.RECORDSET

rs.open "Select LASTNAME, FIRSTNAME from customer", dbcnn, adOpenStatic, adLockOptimistic, adcmdtext

crpt1.reportfilename = app.path & "\report1.rpt"
Crpt1.SetTablePrivateData 0, 3, rs
Crpt1.action =1

---- end of my sample code

Again, I use the code above to pass the value of recordset to a report with no subreport.

Now, the problem is:
1. How do you pass the value of recordset to subreport of report?
2. Any sample codes for reference?

I need your help badly because I'm running out of time to implement my project. Please help. Thank you in advance.
 
The SELECT issue was just a side point. Did you look up the command I mentioned? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
hello ken,
yeah i got the command that you are referring. do you have a sample code on how i can work with this out. yes, i am using an OCX to interface CR and my VB Application. If ever you have, please provide me so that I will have an idea on how I can work this out. Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top