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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to reset DateTimeVar to null

Status
Not open for further replies.

kbbdnc

Technical User
Oct 19, 2000
10
0
0
US
I am trying to reset a DateTimeVar to null and when I use:

Global DateTimeVar C10DueDate :="";

I get an error message telling me that I need a date time after the =. I have the formula field resting in the detail section, but must have the value displayed in the group footer. So I created another formula field in the group footer that is the value of the variable.

Any suggestions?

Kim
 
I don't believe that you can assign a null value to any variable. I think the closest you can come is the default value for that data type:

Strings = ""
Numbers = 0
Dates = Date (0,0,0)
DateTime = DateTime(0,0,0,0,0,0)

I didn't get why you need to assign the null? Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
I need to set it to null/ or reset it so that it evaluates correctly for each group. Right now it appears to be retaining the first value it comes across, and populates each group with that information. So I thought if I could reset the variable to null in the group header, then it would evaluate correctly for each group. Is my logic off? Do you know of a better way?

Thanks!!!
 
See evaluation time functions in the help index.

When the report is printed, the date variable formula has already been calculated, so to save time, SCR doesn't re-evaluate it.
You want to force SCR to evaluate the formula at the correct time. The options are:
WhilePrintingRecords ;
WhileReadingRecords ;
BeforeReadingRecords ;
EvaluateAfter (x) ; //where x is any valid formula name Malcolm
Remember, if it wasn't for electricity, we'd be surfing the net by candlelight.
 
You should start the formula with this first line:

WhilePrintingRecords;


Also remember that where you place the formula that does the assignment (which section) is crucial, since it will re-assign each time it appears. You probably want to have the assignment itself occur in each group header. Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
Hi Ken,
Pardon me. This is question related to the original issue.
If you want to add the date to display (like a running total) using a formula the variable requires a number. How would you takle the problem.
For example:
We are going to use a formula @MaxDate
@MaxDate = If Amount = Max(Amount, Group1) then xxx.Date
Var1 (in GH1)
WhilePrintingRecords;
DateVar Max := Date (0,0,0);

Var2 (Detail)
WhilePrintingRecords,
DateVar Max := Max + ({@MaxDate});

Var3 (GF1)
WhilePrintingRecords;
DateVar Max := Max;

When you try to run the report the error message pops up for Var2 saying "A number is required here".
Is there a solution?
CR 9 SQL 2K.
Thanks in advance.
 
Consider that you're better off starting a new thread rather than attempting to piggyback on a thread from the year 2000.

Ken may have retired and moved to Bolivia by now.

But do you only want Ken to respond, as opposed to the wealth of experts in this forum? Ken rarely posts here these days.

@max_date doesn't return a value, it returns a date, and you can't add dates together.

What are you trying to do? Don't show just bad formulas without showing example data and what you need to show.

Consider that your software version, database and connectivity are important details when performing architecture.

And why do this:

Var3 (GF1)
WhilePrintingRecords;
DateVar Max := Max;

Just use:

Var3 (GF1)
WhilePrintingRecords;
DateVar Max

You're pigeon holing the design help based on some bad theory and principles.

Try posting:

Crystal version/edition
Database/connectivity used
Example data
Expected output

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top