Update DecimalPlaces property

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
 
T

TC

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
 

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