Print Page | Close Window

Direct table access based on parameter

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16152
Printed Date: 05 May 2024 at 4:46am


Topic: Direct table access based on parameter
Posted By: pare169
Subject: Direct table access based on parameter
Date Posted: 11 Apr 2012 at 2:37pm
Hi all,

I am new here. Now I have a very urgent question. I have two tables, Usage and Usage_Archive table. Usage table stores the recent 12 months usage data, and Usage_Archive table stores the usage data older than 12 months.

I want to dynamically decide which table to access according to the date parameter that the user entered. If the date user entered is within last 12 months, the crystal report will access the Usage table. Otherwise if the date is older than last 12 months, the report will access the Usage_Archive table. I used either formula or variable with a condition, but neither of them worked. It brought back wrong data set. I checked the query statement of the report, Usage and Usage_Archive tables were joined together, that brought more data than expected. The following is the formula that I defined:

if datediff("m", {?Date},currentdate)<=13
then {CONSOLIDATED_DAILY_USAGE.USAGE}
else {CONSOLIDATED_DAILY_USAGE_AR.USAGE}

I am using Crystal Report 2008.

Could anyone help me out? Thank you very much!



Replies:
Posted By: kostya1122
Date Posted: 13 Apr 2012 at 8:01am
you could try to use a sub-reports like
one sub-report contains {CONSOLIDATED_DAILY_USAGE.USAGE}
the other one {CONSOLIDATED_DAILY_USAGE_AR.USAGE}
then put a suppression formula in each of them.



Print Page | Close Window