crystal-reportscrystal-reports-2010

How to set sql table name in a variable and refer that in the formula fields?


We have multiple SQL views that have the same data structure. Only difference is the filter conditions that have been used to create those views. our task is to create crystal reports for every SQL view.

currently, we have created a sample template with a dummy table and created formula fields for each field in the view. when we create a report we are changing table names in all of those formula fields manually.

Is there a way to set the table name along with the database connection in a parameter so that after we create one crystal report we can change only that parameter to create the other reports? If it can't what is the best way to do redundant tasks like this in crystal report?

Please help!

we are using SAP Crystal Reports - 2016


Solution

  • One option is to use a COMMAND as the data source and embed a parameter in the COMMAND to control the table name. However, that approach won't allow you to change the data source for the report.

    If performance is not an issue, you can UNION data from different tables into a single result set. Then, use a parameter to filter the records to those belonging to one of those tables.

    Some of the 3rd-party Crystal Reports Viewers listed here allow you to switch the data source of the report on the fly (using a command line argument of a user interface presenting alternative ODBC DSNs for use by the report.