Author |
Message |
mgriba
Newbie
Joined: 10 Mar 2008
Online Status: Offline
Posts: 5
|
Topic: Conditional Text Field 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.
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
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
|
|
IP Logged |
|
mgriba
Newbie
Joined: 10 Mar 2008
Online Status: Offline
Posts: 5
|
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.
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
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
|
|
IP Logged |
|
mgriba
Newbie
Joined: 10 Mar 2008
Online Status: Offline
Posts: 5
|
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.
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
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
|
|
IP Logged |
|
mgriba
Newbie
Joined: 10 Mar 2008
Online Status: Offline
Posts: 5
|
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?
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
Posted: 12 Mar 2008 at 12:56pm |
Not that I know of, but I appreciate the thought!
-Dell
|
|
IP Logged |
|
mgriba
Newbie
Joined: 10 Mar 2008
Online Status: Offline
Posts: 5
|
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.
|
IP Logged |
|
|