I have a problem with exiting event in lotusScript, when i exit from a field , i run a procedure definde in globals section that takes uidoc.currentfield and replaces the content of current field with 0,0 if currentfield is empty.
The problem is that current field is the field that i want to go, i think that exiting event runs after move the cursor, but it have to run before th cursor go to another field.
If I understand your situation, you have the code in the Field Exiting event but you would like to have it run before the user exits the field. It would be nice if it could be triggered when the user stops typing (or something). I suggest leaving it in the Exiting event but also put it in a button near the field so that they can click it if they want to see the new value populated into the field. Is this close to what you intended?
Actually, I think what Borja is saying, is that the global function can’t tell which field was just exited because when it asks for hte current field, it gets the field they just moved to, not the one they moved from.
The only way I can think of, is to have the Exiting event in each field supply a string parameter to the global function, telling it which field the user’s exiting.
Alternately, they could just set the value 0,0 as the default formula for each field; then, use the Entering (or onFocus) event to SelectAll what’s in the field, so that they can type over the value if they choose.
Or, in the Input Translation for each field, if document is being saved and the value is “”, change it to 0,0. This could also be done in a Querysave event if they prefer to write code to loop thru the fields instead of having to change the formula for each field.
Andre thanks for your response, the problem is as you described, because i call the procedure in exiting event. The code is in exiting
Sub IRTEN
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=w.currentdocument
nc=uidoc.currentfield
If uidoc.FieldGetText(nc)="" Then Call uidoc.FieldSetText(nc,"0,0") End If
End Sub
Ths doesnt works, because lotus evaluate uidoc.currentfield after change cursor, then the code would be
Sub IRTEN(fieldname as String)
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=w.currentdocument
If uidoc.FieldGetText(fieldname)="" Then Call uidoc.FieldSetText(nc,"0,0") End If
End Sub
I have a table with at least 80 fields, it will be a hard work makea diferent call sub in each field.
Yet another option for the specific task you describe, is to use the onblur event (to be preferred over Exiting in any case) and write it in JavaScript so that you can refer to the current field as “this”.
Also, now that you have described the problem a little better, it seems you might find use for the table editing tools found in this download, which may make it unnecessary to have quite so many fields. Lots of fields are a drag on your application’s performance, as well as a complexity of your design when you have so many to customize.