Local lcAlias, lcField, lcType, laFields[1], ; lnElement, lnRow, lcIntegerPart, lcDecimalPart With This *** Save default backgound color .nOrigBackColor = .BackColor If Not Empty( .ControlSource ) And ( '.' $ .ControlSource ) And Not( '(' $ .ControlSource ) If Empty( .InputMask ) *** Only set the inputmask for numeric and character fields *** and check the data type of the underlying field so we *** can set it appropriately lcType = Type( This.ControlSource ) If Inlist( lcType, 'C', 'N', 'I', 'Y' ) *** Parse the alias and the field name from the ControlSource lcAlias = Juststem( .ControlSource ) lcField = Justext ( .ControlSource ) *** Don't attempt to check the properties of the underlying *** field if we are bound to a form property If Not( Upper( Left( lcAlias, 4 ) ) == 'THIS' ) And Used( lcAlias ) *** format the field if it is character If lcType = 'C' .InputMask = Replicate( 'X', Fsize( lcField, lcAlias ) ) Else Afields(laFields, lcAlias) lnElement = Ascan(laFields, Upper(lcField)) If lnElement > 0 lnRow = Asubscript(laFields, lnElement, 1) If laFields[lnRow,2] = 'N' lcIntegerPart = Replicate('9', laFields[lnRow, 3] - laFields[lnRow, 4] - 1) lcDecimalPart = Replicate('9', laFields[lnRow, 4]) .InputMask = lcIntegerPart + '.' + lcDecimalPart Else If laFields[lnRow,2] = 'I' *** Max integer value is 2147483647...make sure we don't overflow .InputMask = '999,999,999' Else If laFields[lnRow,2] = 'Y' *** Max currency value is 922337203685477.5807...make sure we don't overflow .InputMask = '99,999,999,999,999.9999' Endif && IF laFields[lnRow,2] = 'Y' Endif && IF laFields[lnRow,2] = 'I' Endif && IF laFields[lnRow,2] = 'N' Endif && IF lnElement > 0 Endif && IF lcType = 'C' Endif && IF UPPER( lcAlias ) # 'THIS' Endif && IF INLIST( lcType, 'C', 'N', 'I', 'Y' ) Endif && IF EMPTY( .InputMask ) Endif && IF ! EMPTY( .ControlSource ) Endwith