We help IT Professionals succeed at work.

Fields do not refresh

Pennywisdom
Pennywisdom asked
on
I have a field "TransferDate" that is computed. It's formula is :
@If(Name="";"";@DbLookup(""; ""; "vEmpl"; Name; "TransferDate"))

So when I change the field "Name", "TransferDate" is changed automaticly to the transfer date of the employe.

Now I want to display the number of Years, months and days between now and the transfer date. To do this I have 4 computed fields:
1) "ExpTotalDays" is hidden and has the formula:
@If(TransferDate="";0;@Now - @TextToTime(TransferDate)) / 60 / 60 / 24

2) "ExpYears" that has the formula:
@Integer(ExpTotalDays / 365)

3) "ExpMonths" that has the formula:
@Integer(@Modulo(ExpTotalDays;365) / 30)

4) "ExpDays" that has the formula:
@Modulo(@Modulo(ExpTotalDays;365);30)

My problem is that these 4 fields are not refreshed automaticly, even if I checked the option "Automaticly Refresh Fields" in the Forms properties. "TransferDate" is refreshed automaticly dought. I don't understand this, can anyone help me out?
Comment
Watch Question

Commented:
Hello Pennywisdom,

you have to be aware of the Z order of field calculation. Z order means: first field in upper left corner, than from left to right every line until last field in lower right corner. So ExpTotalDays field have to be before others using it.

Also include in every field the previous field name needed for calculation. For example, write the formula for the "ExpMonths" field like this:
FIELD ExpTotalDays:=ExpTotalDays;
@Integer(@Modulo(ExpTotalDays;365) / 30)


If this all does not help, than do it like I would do: place all calculation into one field, into TransferDate field. Than it looks like this:
FIELD Name:=Name;
FIELD ExpTotalDays:=ExpTotalDays;
FIELD ExpYears:=ExpYears;
FIELD ExpMonths:=ExpMonths;
FIELD ExpDays:=ExpDays;

@SetField("ExpTotalDays";0);
@SetField("ExpYears";0);
@SetField("ExpMonths";0);
@SetField("ExpDays";0);

@If(Name="";@Return("");"");
tmpTransferDate:=@DbLookup(""; ""; "vEmpl"; Name; "TransferDate");
@If(@IsError(tmpTransferDate);@Return("");"");
tmpExpTotalDays:=(@Now - @TextToTime(@Text(tmpTransferDate))) / 60 / 60 / 24;
@If(tmpExpTotalDays<0;@Return("");"");
@SetField("ExpTotalDays";tmpExpTotalDays);
@SetField("ExpYears";@Integer(tmpExpTotalDays / 365));
@SetField("ExpMonths";@Integer(@Modulo(tmpExpTotalDays;365) / 30));
@SetField("ExpDays";@Modulo(@Modulo(tmpExpTotalDays;365);30));
tmpTransferDate


Be also aware of Text, Number and Date field types.

Good luck,
zvonko





Author

Commented:
I placed my fields after TransferDate and it works, didn't need to change any of my formulas.

Thanks alot zvonco!

Commented:
sorry, I was late 'cose I was testing first all the code.

But anyway thank you Pennywisdom for the points and for the feedback.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.