cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to add trailing 0s to field during SetItem() in itemchanged event

0 Kudos

Hello. Please help me on this problem which I have tried to fix for hours but failed.

I am doing a SetItem() on a field in itemchanged() event. The requirement is the field will always be 6 numeric characters. So if users types 11, on tab-out I am trying to set 0000 so the value becomes 110000.

During debug, I see the value 110000 being set in datawindow but when the execution goes to itemfocuschanged() event, the value automatically changes to 11.

Initially I thought the field is Char type so that may be a issue but its not. The behavior is same for Long type field also. I have also tried putting AcceptText() in the itemChanged() and ItemFocusChanged() Event but no sucess.

Below is my code in Itemchanged event():

ls_col_value = This.GetItemString(row,"col_name")//not mentioning actual column name due to security reasons//

IF Len(data) < 6 THEN

data = data + fill("0", 6 - Len(data))

This.SetItem(row, "col_name", data)

END IF

View Entire Topic
cpollach
Explorer
0 Kudos

Try this ....

String ls_name
String ls_data

ls_name = String ( DWO.Name )

ls_data = Trim ( data )
Choose case ls_name
case "<your col name>"
IF Len ( ls_data ) < 6 then
data = ls_data + fill ( "0", 6 - Len ( ls_data ) )
END IF
end choose

Return 0