Results 1 to 3 of 3

Thread: Problem with length of numeric fields

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274

    Post

    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!

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    The FoxPro function FSIZE() will tell you how big a field is.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274

    Post

    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:
    Code:
    '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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width