Solved

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

Posted on 2004-08-06
8
3,855 Views
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........

 
0
Comment
Question by:imarshad
  • 4
  • 3
8 Comments
 
LVL 42

Accepted Solution

by:
frodoman earned 500 total points
Comment Utility
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.

frodoman
0
 
LVL 13

Author Comment

by:imarshad
Comment Utility
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
0
 
LVL 42

Expert Comment

by:frodoman
Comment Utility
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.

frodoman

0
 
LVL 13

Author Comment

by:imarshad
Comment Utility
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
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 42

Expert Comment

by:frodoman
Comment Utility
>>> 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:

//@InitVars
shared numberVar MyNumber := 0;
shared stringVar MyText := '';
...etc...

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,

frodoman
0
 
LVL 13

Author Comment

by:imarshad
Comment Utility
Thanks a lot frodoman........
You have been very helpful and prompt in answering the questions......a positive feedback from me.......

Imran Arshad
0
 
LVL 42

Expert Comment

by:frodoman
Comment Utility
Glad I could help!
0
 
LVL 1

Expert Comment

by:iamtgo3
Comment Utility
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
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now