Creating a new field definied as deciaml

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
 
A

Allen Browne

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top