Print Page | Close Window

Conditional Text Field

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2570
Printed Date: 18 May 2024 at 6:32am


Topic: Conditional Text Field
Posted By: mgriba
Subject: Conditional Text Field
Date Posted: 10 Mar 2008 at 3:48pm

Ok, first time ever using CR and I must say it is great!  I have my report almost completed, but have one lingering problem - I need to add a text object that is populated conditionally based on the contents of a database field.  Is there a way to do this?

 
For example, I have numerous records with the need to indicate (in a text box, or some other object) one of two things - "PAST DUE" or "BASE" based on the contents of another field (database) per record.
 
Thank you.



Replies:
Posted By: hilfy
Date Posted: 10 Mar 2008 at 4:02pm
This is fairly easy using an "If...Then...Else" statement in a formula.  If you would like a sample, please post the conditions that determine "Past Due" or "Base".
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: mgriba
Date Posted: 10 Mar 2008 at 4:04pm
For "BASE" the database field in question must be the current month, for "PAST DUE" the same database field in question must be < current month.  Thank you so much for the quick reply.


Posted By: hilfy
Date Posted: 10 Mar 2008 at 4:18pm

Try something like this (you may have to tweak it...)

If month({table.datefield}) = month(CurrentDate) then 'BASE'
else if month({table.datefield}) < month(CurrentDate) then 'PAST DUE'
 
Place this formula on the report where you want the text to appear.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: mgriba
Date Posted: 10 Mar 2008 at 4:21pm
Sorry to bother again - since you have helped so much.  But, on Crystal Reports 2008 (which I'm using), how do I go about placing code without an object container to hold it?  Thank you again.


Posted By: hilfy
Date Posted: 10 Mar 2008 at 4:36pm
I'm not familiar with CR 2008.  However, if it's similar to previous versions, in the Field Explorer where you see your database fields, there should be an entry called "Formula Fields".  Right-click on it and select "New".  Enter the formula and then save it.  Crystal will let you know if there's a problem in the formula.  After it's saved, just drag it onto your report.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: mgriba
Date Posted: 12 Mar 2008 at 11:41am
Worked like a charm!  Thank you again.  This is my first post here as well.  Is there a rating system/points system for the awesome replies you gave me?


Posted By: hilfy
Date Posted: 12 Mar 2008 at 12:56pm

Not that I know of, but I appreciate the thought!

-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: mgriba
Date Posted: 12 Mar 2008 at 3:51pm
If I could load this up on our GoDaddy hosted (yuck!) account and pass a form variable from a login field to filter out the data for a particular user without spending any extra cash, I would be a rockstar.  But, in a one man IT department, being jack of all trades, master of none, I will revisit that when the heavier fires are put out first.  Thanks.



Print Page | Close Window