change to standard format

A

accessman2

Set tbl = db.TableDefs("Invoice")

tbl.Fields.Append tbl.CreateField("amount", dbCurrency)

the above code is working well.
However, the below code, I cannot change the format (standard), n
dollar sign.

tbl.Fields("amount").Properties("Format") = "Standard"

The message said that "property no found"
What's wrong with it?
How can I change the format (standard)?
Please let me know, thanks
 
D

Douglas J. Steele

Not all properties are created when a field is created: some are only
created when they're required.

Try the following:

Dim fld As DAO.Field
Dim prp As DAO.Property

Set tbl = db.TableDefs("Invoice")
Set fld = tbl.CreateField("amount", dbCurrency)
Set prp = fld.CreateProperty("Format", dbText, "Standard")
fld.Properties.Append prp
tbl.Fields.Append fld
 
J

John Vinson

Set tbl = db.TableDefs("Invoice")

tbl.Fields.Append tbl.CreateField("amount", dbCurrency)

the above code is working well.
However, the below code, I cannot change the format (standard), no
dollar sign.

tbl.Fields("amount").Properties("Format") = "Standard"

The message said that "property no found"
What's wrong with it?
How can I change the format (standard)?
Please let me know, thanks.

You may need to add the Format property to the field - if there is
none, it's not there to change.

However, the format of a Table field is - generally - completely
irrelevant. You shouldn't be displaying data in Tables in any case;
and you can easily set the format property of a Form or Report textbox
in which you're displaying the [Amount] field.


John W. Vinson[MVP]
 

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