tags:

views:

95

answers:

1

I need to create a decimal field in MsAccess 2003 through DAO. How do I do that? Other fields I can create using following codesnippet, but not decimal.

How do I set type, precision and scale?

NOTE : a decimals datatype = 20, but setting a datatype to 20 results in invalid data type

Dim db As DAO.Database
Dim tbl As TableDef
Dim fld As Field

Set db = CurrentDb

tbl = database.CreateTableDef("Test")
fld = tbl.CreateField( ....   )
+2  A: 

You may find this useful: http://allenbrowne.com/ser-49.html#%5Fftn7

It states that decimal is not available in DAO and ADO should be used to create such fields.

Remou
The correct answer is : you cannot... not what i was looking for..
Peter
A fudge solution could be to use currency data type and format the field to display as you see fit
heferav
Welcome to the lovely world of MS's stupidity in regard to Jet 4, ADO and DAO. There is absolutely no reason MS should not have implemented this in DAO, but they chose not to because they were pushing the now dead classic ADO. You might check to see if the ACE's version of DAO supports it (i.e., the Access 2007 version of DAO).
David-W-Fenton
@David W. Fenton: "now dead classic ADO" -- welcome to the real world. ADO classic is not dead in MS Access Land because it's still needed to do the things in which DAO is deficient (for whatever reason): CHECK constraints, UNICODE compression data types, fixed-length text data types, no index foreign keys, ... oh yeah, and the DECIMAL data type ;) –
onedaywhen