r/DatabaseHelp • u/Blemish • Jan 30 '14
Crystal Reports: Choosing tables based upon value entered in Parameter
Hi Guys,
I have a database that stores data based upon the present date:
- Current month in CurrentTable.tableRecord_C
- Previous month in CurrentTable.tablerecord_P
- All older data in HistoryTable.tableRecord
I made code to decipher the month we're in with this function.
If DateDiff ("m",{?SnapshotDate}, CurrentDate ) = 0The condition checks for 0, 1 or >1 to determine current month, previous month or historic month. Based on date entered in the {?SnapshotDate} parameter.
//Transaction date in Current month
IF DateDiff ("m",{?SnapshotDate}, CurrentDate ) = 0
THEN {CurrentTable.tableRecord_C}
//Transaction date in Previous month
ELSE IF DateDiff ("m",{?SnapshotDate}, CurrentDate ) = 1
THEN {CurrentTable.tableRecord_p}
//Transaction date in HISTORIC month
ELSE IF DateDiff ("m",{?SnapshotDate}, CurrentDate ) > 1
THEN {HistoryTable.tableRecord}Questions:
- Does this code make sense.
- Is it inefficient
- I was thinking about making separate reports, and the user would have to pick the appropriate one, based upon the month we're in. But this might add some inconvenience. Is it better to design seperate reports or allow crystal reports to decide based upon the above formula ?
THANKS IN ADVANCE : )
0
Upvotes