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
Solved

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

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

frodoman
0
 
LVL 13

Author Comment

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

Expert Comment

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

frodoman

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 13

Author Comment

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

Expert Comment

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

//@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
ID: 11752297
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
ID: 11752311
Glad I could help!
0
 
LVL 1

Expert Comment

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

840 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