Creating a new field definied as deciaml

  • Thread starter Thread starter mike.ross
  • Start date Start date
M

mike.ross

Someone please help me. I have bee searching for a way to
create a column with a decimal definition.

I have tried

Set FieldNew = tdNew.CreateField("FieldName", dbDecimal)

with no success.


Is there a way to do this?

Thanks

Mike
 
Microsoft did not update the DAO library to create the decimal field type,
so that is the reason you were not able to do it that way.

It can be done with ADOX, as in the example below. However, are you really
sure you want to do this? Although the Decimal field type was added 3
versions ago, the implimentation is incomplete (e.g. there is no matching
field type in VBA, so you are stuck with using Variants), and buggy (e.g.
http://allenbrowne.com/bug-08.html )

If you want to do it anyway:
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table

Set cat.ActiveConnection = CurrentProject.Connection
Set tbl = New ADOX.Table
tbl.Name = "MyTable"
tbl.Columns.Append "MyDecimal", adNumeric
cat.Tables.Append tbl
 
Back
Top