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

dynamically pointing to a specific table 1

Status
Not open for further replies.

wiplash

MIS
Jun 29, 2004
99
US
Can I dynamically "point" to the "correct" table depending upon the user prompts. For instance, if the customer (via a parameter) chooses PARAMETER A, then I want to retrieve the data from one particular table, however if they choose PARAMETER B, the the data needs to come from a different table.

Currently this requires two separate reports, but I'd like to know if it can be done within one program.

By the way, I'm using Crystal Reports 10 and SQL.

Thanks
 
Depends upon your database and connectivity type as to how you might do this.

Does SQL mean SQL Server? (SQL is a database programming language common to many databases).

One way you might do this is to use a UNION ALL query in the Add Command which combines the 2 tables, and then filter out the tables rows that you don't want by adding in an identifier for each table, such as:

select field1, field2, 'table1' Source from table1
union all
select field1, field2, 'table2' Source from table2

Now in the Report->Selection Formulas->Record use something like:

{table.Source} = {?MyParameter}

-k

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top