Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine Precison and Scale via Code 2

Status
Not open for further replies.

buddafish

Programmer
Apr 26, 2002
478
US
Hello All -

I am coding a utility to write stored procedures based on the field names and data types in any given table. I can get the field-Type and field-Size but if the Type is a Decimal (number), I am hitting a wall when attemping to find out the precision and scale via code. I can only get a Size value and that just won't work.

code example:
For Each fld In db.TableDefs(sTableName).Fields

Select Case fld.Type
Case 4 'int
'
Case 7 'dbl
'
Case 8 'date
'
Case 10 'string
'pass in the iTextLen arg...
iLen = fld.Size
tstrm.WriteLine BuildCastString(fld.Name, 10, iLen)

Any ideas?

Thanks - Scott
 
buddafish,
It looks like you are using DAO?
Microsoft said:
...Microsoft Jet Decimal, instead of Currency. This data type is not supported via Data Access Objects (DAO). It is supported only with ActiveX Data Objects (ADO).

You should be able to change your code over to ADO and return the [tt]Field.NumericScale[/tt] & [tt]Field.Precision[/tt] properties for this field.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Perfect!! ADO is the answer. Thanks for pointing me in the right direction.

Scott
 
The link I posted says:

DECIMAL (precision, scale) [7]

[7] Not available in the Access query interface or DAO. Use ADO to Execute the DDL query statement.
 
Perfect!! ADO is the answer. Thanks for the reference chart too! (I missed the footnote)

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top