-
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.
-
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
-
set the field to vbCurrency and then
Code:
'set default values to zero
Set td = db.TableDefs!NewTable
td.Fields!NewField.DefaultValue = 0
-
Hello larryn & Buzby,
Thanks for your information.
Michelle.