Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chaging style of field from a formula

Status
Not open for further replies.

Alcar

Programmer
Sep 10, 2001
595
US
I have a datetime field and a flag field.
If the datetime field does not follow some rules, then the flag is set.

I need the field holder of the report to be highlighted if the field is empty or the flag is set.

I am using a formula field that it checks if the field is not in between those two dates, then it returns: formula = " " (eight spaces)

I have tried using the highlight expert and giving it the condition to be: not between 1/1/1900 and 12/31/3000; I have set it to change the background to red and the border to double line.

nothing. If the field is empty, it won't highlight it.

What am I doing wrong?
Thanks in advance
 
On your formula to conditionally highlight this, check for nulls first:

If Isnull({Field}) or
IF <<other criteria to highlight field>> then Yellow
Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
You can't format a null value, the field doesn't print.
You would have to put a dummy field (like a formula that contains &quot; &quot;) over top of it, and format that when the regular field is null. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
OK I think we must establish what you are doing here before firing off solutions

I think you are refering to the formula field on the report when you mention &quot;Field Holder&quot;...

*******************************************************
I have a datetime field and a flag field.
If the datetime field does not follow some rules, then the flag is set
*******************************************************

Ok so you have a formula for a flag something like

@DateTimeFlag (Suppressed in section with date formula)

WhilePrintingRecords;
numbervar Flag;

if {Table.Datetimefield} = <some condition> then
Flag := 1 //we want to highlight
else
Flag := 0 //we don't want to highlight

Flag;

*************************************************
I need the field holder of the report to be highlighted if the field is empty or the flag is set.

I am using a formula field that it checks if the field is not in between those two dates, then it returns: formula = &quot; &quot; (eight spaces)
**********************************************

Ok...now we have the datetime formula, you seem to have 2 conditions...

1. the date is Null
2. the date doesn't fall between 2 dates
3. the date is ok

I imagine if the date is ok...then it will be displayed in this formula...otherwise you will give a string of spaces.
To make the date criteria more general I have made them dateTime parameters.


@DateTimeFormula

WhilePrintingRecords;
stringVar Result;

if not isnull({Table.DateTimeField)) and
{Table.DateTimeField) >= {?StartDate} and
{Table.DateTimeField) <= {?EndDate} then
Result := totext({Table.DateTimeField),&quot;MM/dd/yyyy&quot;)
else
Result := &quot; &quot;; // 8 spaces

Result;

OK now all that is left is to set the conditional BackGround and conditional borders for the field

for the Background color the formula would be

WhilePrintingRecords;
Evaluateafter(@DateTimeFlag);
NumberVar Flag;
StringVar Result;

if Flag = 1 or Result = &quot; &quot; then
crRed
else
crNoColor;

You would use exactly the same formula for the conditional borders...except instead of colors you would set the border double line or single line (I forget what those constants are)

Ther I think this is what you want but it is only a guess on my part....If I am not right give us more details
Jim Broadbent
 
For:

&quot;I need the field holder of the report to be highlighted if the field is empty or the flag is set.&quot;

Create a Formula:

If
{MyTable.MyFlag} = true
or
Isnull({MyTable.MyDate})
// Add some overkill, this is probably covered by the flag:
or
{MyTable.MyDate} < cdate(&quot;1900/1/1&quot;)
or
{MyTable.MyDate} > cdate(&quot;12/31/3000&quot;)
then
&quot; &quot;
else
totext({MyTable.MyDate}

In the Drop Shadow or the border conditions of the font for the formula place:

If
{MyTable.MyFlag} = true
or
Isnull({MyTable.MyDate})
// Add some overkill, this is probably covered by the flag:
or
{MyTable.MyDate} < cdate(&quot;1900/1/1&quot;)
or
{MyTable.MyDate} > cdate(&quot;12/31/3000&quot;)
then
yellow

Now the field will either display a proper date or place a yellow drop shadow or border around the 8 spaces you wanted.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top