PDA

Click to See Complete Forum and Search --> : Problem with length of numeric fields


Tonatiuh
Feb 24th, 2000, 07:07 AM
I'm using VB5 and AD0 2.1 accessing to FoxPro database. A numeric field is defined as 10 integer digits and 2 dcimal digits. But when I try to asign number with 12 integer digits id returns me an error saying just 'Errors'. I just can assign a number with maximun of 7 integer digits.

In a small numeric field defined as 4 integer digits and 0 decimal digits. I can assign a 4 integer digits without problems.

What's happening? How can I really know how many digits are supported by certain numeric field.


Any idea will bee very deeply appreciated.

Thanks!

JHausmann
Feb 24th, 2000, 08:58 AM
The FoxPro function FSIZE() will tell you how big a field is.

Tonatiuh
Feb 25th, 2000, 01:08 AM
But, I'm accessing from VB5. I think I can't call a FoxPro function from VB.

When I try to assign a new value to the field, it returns 'errors' if the length of the value is bigger than the file size. So I set the MaxLength property of the textbox to the size of the field. In order to the changes I frequently do to the database (in size or type of fields) I use a funtion to get the value I must set this MaxLength property. This is my function:

'returns the maximum length the TextBox must have when the field is editing
Public Function GetLon(ByRef fd As ADODB.Field) As Integer

Select Case fd.Type
Case 129 'character
'this returns the width of the field. Easy
GetLon = fd.DefinedSize
Case 131 'numeric
'this returns the number of integer digits - 1
GetLon = fd.Precision + 1
'this returns the number of decimal digits if exists
'I add 1 to allow the decimal point space
If fd.NumericScale > 0 Then GetLon = GetLon + fd.NumericScale + 1
Case 133 'fecha
'if it is a date field, set the width to 10. Easy
GetLon = 10
End Select

End Function


Any idea will be very deeply appreciated.

Thanks!

Edited by Tonatiuh on 02-25-2000 at 02:13 PM