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

generate a report for tables with similar structure 2

Status
Not open for further replies.

bhavanipodipireddy

Programmer
Jan 13, 2004
7
FR
Hallo ,

I am new to Crystal Reports. I have a Problem. I have different tables in database with different names.. But the structure of all the tables is same. All the tables contain same fields. Now my problem is to generate a report for those tables only one at a time based on the table name given by the user. User can select the required table name from a combo box. Based on the selected table a report has to be generated for that table.

I have already created a report for one table, how can i just change the source table for that report to create report for the selected table.

Can anyone help me regarding this problem.

Thank you
 
One option is to create a UNION statement that combines data from all these tables and adds a column with table name.

Then, filter the report based on the table name parameter.

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
If you have CR 9, you might use an Add Command with a parameter for the table on the right side to prompt the user to enter a table name.

An example is using the Access Xtreme database, wherein you could create a parameter called MyTable and then write the following SQL in the Add Command SQL Query box:

select * from {?MyTable};

Unfortunately you can't populate it with all of the choices in a picklist, and Crystal doesn't support dynamic parameters so if you added tables it wouldn't show it.

Ido's solution will work for CR 9 and for previous versions, and has the advantage that you can prepopulate the parameter with the table names by setting defaults, however the Crystal limitation of not allowing for dynamic picklists still exists for prepopulating the parameter.

Also a Union will be slower than the solution I offered.

-k
 
Thanx for the Reply. How to create the parameter MyTable. because in the Add Command box when i have typed the select command it is showing an error.

Select * from {?MyTable};

Can u help me how to create the parameter MyTable. I am using Crystal Reports using Visula Studio.NET.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top