Update DecimalPlaces property

  • Thread starter Thread starter Mick
  • Start date Start date
M

Mick

Hi

In a module I have the following code to add a Currency field to a table:

Public Function CreateAField()
Dim db As DATABASE, tdf As TableDef, fld As Field
Set db = DBEngine.OpenDatabase("d:\access 97\tables.mdb")
Set tdf = db.TableDefs("tblOrders")
Set fld = tdf.CreateField("Currency",dbCurrency)
tdf.Fields.Append fld
tdf.Fields.Refresh
End Function

This works fine as far as it goes. However, in addition to this I need to
set the DecimalPlaces to 2, set the required property and also a Default
value.

I am using Access 97 for this routine.

Thanks in advance for any suggestions.

Mick
 
The other things are set through custom properties. To see what they are,
create a field with the appropriate characteristics "manually", then iterate
its Properties collection. Then use CreateProperty to replicate those props.

BTW, I doubt you need to refresh the fields collection unless you want to
execute more code *in that session* to work with the new field. The Append
appends it permanently, but (I think) does not immediately update the fields
collection. Also maybe safer to db.Close before you exit?

HTH,
TC
 
Back
Top