Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Crystal Report 10 and VB6...............

Posted on 2004-08-06
Medium Priority
Last Modified: 2012-06-27
Hi all,
        I am developing a small software which requires a couple of Reports to be generated...... Since I have no prior experience of developing in Crystal Reports, so a friend told me to follow these steps.......

1)  Develop a Report  "*.rpt"  in Crystal Report 10......Connect the Database to it........Change its design and add a few formula fields, text fields,Page Header, Page Footer etc. in the design within the Crystal Report IDE......

--> All of this is working perfectly and I am able to connect "Crystal Report 10" with the database and it all looks good.......

2) View the Report from within VB and then Print it...........

--> This is also working perfectly and I was able to view the Report from within VB and Print it........

but I have 2 main problems that I cant resolve.........

1) How to pass Parameters from VB to Crystal Report 10 created "*.rpt" file so that these parameters are displayed on the report when it is viewed ? I need help in VB (code as well as all references required) and in "Crystal Report 10" design of "*.rpt" file(What type of field should be used to receive parameters?).

2) I need to display fields from 2 different tables that are not linked together by any means...... i.e they have no relationship amongst them...... When I add field from one table(either) it works OK, but when I display data from two different tables it shows thousands of records which is obviously not correct.......A friend of mine told that when we display records from 2 tables which are not related to each other then it will give cartesian product and will not show the actual recods...(Is this correct ?)

So can I display records from two different tables that are have no relationship with each other(but have some common fields)  ?
As I have told earlier Databases is not my field so please if I have written something silly please ignore it.....
Please do tell me if I was not clear in explaining my point......(which is most probable)

Development Language : VB6
Database Used: Microsoft Access 2000
Crstal Report Ver. : 10
In VB I am using ADO to maipulate the Database........

Question by:imarshad
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 42

Accepted Solution

frodoman earned 2000 total points
ID: 11737725
For question #1, here is a sample application that contains everything you need.  References, code, etc.: http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9_vb_rdc_parameter.exe.asp

It's written for CR9 but will work just fine with CR10 also as the RDC (the dynamic components) haven't changed significantly.  

For question #2, Crystal won't display data from two sources on the same report w/out problems.  The best way to do this is to use subreports.  Create the first report for 1 of the tables.  Then select insert->subreport and create a new subreport to pull the data for the other table.  The result of this is you have two separate reports, each tied to one table, but both within the same report 'container' so they can be viewed together.

Hope this helps - let me know if you need clarification on anything.

LVL 13

Author Comment

ID: 11737903
Thanks frodoman for the quick response......

The reply to question # 2 is really good and I am confident that it will solve lots of my problems.....
as far as question # 1 is concerned I will not be able to comment on it until tomorrow as I donot have Crystal Report installed on my home PC......I will check it tomorrow at my workplace and will let you know......

Imran Arshad
LVL 42

Expert Comment

ID: 11737987
No problem.

Question #1 is really two pieces.  First part is to create the parameter(s) in the crystal report that you need and then the second part is writing the vb code to pass values to those parameters.  You can get both from the sample application I linked you to but feel free to ask if anything isn't clear.


What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 13

Author Comment

ID: 11750430
OK Thanks a lot frodoman..........
Almost all things are working now.....Only got one problem yet to be solved.....

If I donot want to insert the full subreport into the primary report and only want to insert some formula fields from subreport into different parts of Primary Report(like some fields into Header and some into footer)......How can this be done ?

and sorry for the delay as I forgot that it was Weekend............

Imran Arshad
LVL 42

Expert Comment

ID: 11751860
>>> If I donot want to insert the full subreport into the primary report and only want to insert some formula fields from subreport into different parts of Primary Report

You can't do this - a subreport is either inserted or it isn't, there's no halfway.  You do have some options though.

Option #1 would be to create a subreport that only shows what you want to be shown and insert that report.  There's no reason a subreport has to have a whole bunch of information - I have subreports that show only a single field (say for example a total of all records of a specific type).  

Option #2 would be to use shared variables to pass values from your subreport to your main report.  The entire subreport must be inserted, but it can be suppressed so that it isn't visible.  To achieve the value passing you must declare the variables in your main report (commonly in the report header) with a formula like this:

shared numberVar MyNumber := 0;
shared stringVar MyText := '';

Now in your subreport you can simply assign values to these variables and then they can be used in your main report.  The catch is that the variables won't have a value until after the subreport has executed so if you want to use the value it must be below the subreport in your main report.

Hope that helps,

LVL 13

Author Comment

ID: 11752297
Thanks a lot frodoman........
You have been very helpful and prompt in answering the questions......a positive feedback from me.......

Imran Arshad
LVL 42

Expert Comment

ID: 11752311
Glad I could help!

Expert Comment

ID: 11978523
I know you are using vb6 in vb.net I created a dataset to handle both problems. One thing I did to display stuff on a form was one create a temp table to hold the data to be displayed. Plus I have beefed up my SQL queries and joined tables in the query.

George - www.ipdg3.com

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question