On 7/11/2017 3:32 AM, Paul Newton wrote:
Hi all
Have been looking at all the responses to this and thought it might be useful to point out another potential problem with values in numeric fields with a decimal part. If you have a field MyField N(6,2) in theory it should have a maximum value of 999.99. However VFP will happily store values like 9999.9, up to 999999. IMO VFP should not allow this and it is a problem when accessing the data using ODBC or OLEDB. The solution for us was to disallow values greater than VAL("999.99"). The character part being constructed knowing the field definition, in this case N(6,2)
A side note: you can use database triggers to restrict values stored in databases.
And for VFP "screens" you can use the spinner control to get good control of value ranges. Actually, in VFP, you could create a subclass control that would examine the underlying data structure type and limit things in its own valid event, blah blah blah (and it could be pretty generic and handle all kinds of rules with numbers).
But yes, since VFP stores its "N" format as a character representation of a number instead of a "true" number, these weird things happen.
-Charlie