Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Use of If Then Statement to Select Table Post Reply Post New Topic
Author Message
kc27
Newbie
Newbie


Joined: 19 Sep 2008
Location: United States
Online Status: Offline
Posts: 7
Quote kc27 Replybullet Topic: Use of If Then Statement to Select Table
     Posted: 12 Jul 2012 at 11:39am
I am composing a report in Crystal Reports 9 in which I need to access and display data (due dates for multiple projects) that may be in one of two tables, depending on the type of project. I am picking a calendar date range via Crystal, then attempting to get all the due dates for a series of project within that date range. In order to make this work I need to tell Crystal to check the media code for the project, and depending on the type of media, go to the correct table to find the corresponding due dates for that project.

Most of my reports are simple ones, and I have no problem if I run separate due date reports for each of the two project types. However, I would like to include the due dates for both types of projects in a single report, and this is the first time I've tried to  incorporate an if then statement in a report. Is the formula I wrote below on the right track to get me a functioning report?


If {ad_info.media_cd} = "ROP" Then
   {vrsn.prdctn_schdl.job_step_due_dt}
Else
If {ad_info.media_cd} <> "ROP" Then
{ad_prdctn_schdl.job_step_due_dt}
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 13 Jul 2012 at 4:41am
This should work.  However, if you can make changes in the database, I would try creating a View that combines the two tables in a UNION query.  Then, instead of joining to two separate tables, your report could join to just the one view and you wouldn't have to create all of these formulas.
-Dell
IP IP Logged
kc27
Newbie
Newbie


Joined: 19 Sep 2008
Location: United States
Online Status: Offline
Posts: 7
Quote kc27 Replybullet Posted: 16 Jul 2012 at 3:53am
Thanks. I am not familiar with union queries, but  I will investigate your suggestion to see if this is something that is available to me.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum