Results 1 to 4 of 4

Thread: How to create decimal places in a field

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Dear VB users

    Please look at the next source:

    Private Sub Form_Load()
    Dim DB As Database
    Dim TD As TableDef
    Dim FD As Field

    Set DB = CreateDatabase(“c:\q.mdb”, dbLangGeneral)
    Set TD = DB.CreateTableDef("NewTable")

    With TD
    .Fields.Append .CreateField("NewField", dbLong)
    '.Fields("NewField").........
    'HOW DO i GIVE FIELD "NewField" DECIMAL PLACES???????????????
    End With

    End Sub

    HELP!!!!!!!!!!!!!!!!!!!!

    Can someone tell me how to give field "NewField" decimal places!


    Nice regards,

    Michelle.

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    dbLong will create a field of type Long Integer (which doesn't have decimals). Try using dbDecimal instead.

    Some more types available;

    Constant Description
    dbBigInt Big Integer
    dbBinary Binary
    dbBoolean Boolean
    dbByte Byte
    dbChar Char
    dbCurrency Currency
    dbDate Date/Time
    dbDecimal Decimal
    dbDouble Double
    dbFloat Float
    dbGUID GUID
    dbInteger Integer
    dbLong Long
    dbLongBinary Long Binary (OLE Object)
    dbMemo Memo
    dbNumeric Numeric
    dbSingle Single
    dbText Text
    dbTime Time
    dbTimeStamp Time Stamp
    dbVarBinary VarBinary
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3
    Guest


    set the field to vbCurrency and then

    Code:
        'set default values to zero
        Set td = db.TableDefs!NewTable
        td.Fields!NewField.DefaultValue = 0

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello larryn & Buzby,

    Thanks for your information.

    Michelle.

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