Exiting doesn't work samely after then before Save

Hello, i got a problem that i can’t solved like i want, hope you can help me

The field has a Date/Time type

The option : “Run Exiting/OnChange events after value change” is checked

The Exiting code is :

Dim w As New NotesUIWorkspace

If w.CurrentDocument.FieldGetText(“DateField”) <> “” Then

If Cdat(w.CurrentDocument.FieldGetText("DateField")) < Cdat(Format(Now(),"DD/MM/YYYY")) Then

	Call w.CurrentDocument.FieldSetText("DateField", Format(Now(),"DD/MM/YYYY"))

	w.CurrentDocument.Refresh

End If

End If

This code works like i want when :

You edit the document, the you set a date wich is before Today … the date of today is automaticaly set …

But, in a special case wich is :

You edit the document, then you save the document without closing it, then if you editing the document again, if you try to modify the field and set a date before today, the Exiting code isn’t execute.

Here is the formula of my Save Button :

FIELD SaveOptions := “1”;

@If(@Command([FileSave]);@Do(

FIELD SaveOptions := “0”;

@Command([EditDocument]));@Return(“”))

Here is the formula of my Edit Button :

@Command([EditDocument])

Thanks for your help, and have a nice day

Subject: Exiting doesn’t work samely after then before Save

If I understand correctly what you are trying to do, you want the date field to be set to today’s date if the user clicks into it and then exits the field.

Does the field have to be editable?

I would use a computed date time field and set the formula to something like this:

@if(@isdocbeingsaved;@now;@thisvalue)

This will update the field value with today’s date if the document is saved.

Also you have a bit of overkill on your save button.

You don’t need to use save options to save properly.

try@if(@command([FileSave]);@command([EditDocument];“0”);“”)

This says, if you save successfully, switch to read mode.

Subject: RE: Exiting doesn’t work samely after then before Save

Hi,

First thanks to answer so quick,

i’m gonna give you information on what i want to do with my Exiting Code :

The user have to set a date, but the date have to be > or = to Today, if not the date is automaticaly set with the Date of today

and it work perfect, except, if i Edit => Save => and Edit again my document.

The Exiting code run well only on first Edit, or if you close the document, re open it, and edit it again …

But it don’t work if there is no close between 2 Edit …

Sorry for my english, hope i was clearest in this second message …

Julien