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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set decimal places for number data type in VBA ?

Status
Not open for further replies.

lingyi

Programmer
Apr 11, 2001
65
SG
Hi,
How could I use VBA with coding to set the decimal places for number field type? I try to set like below but it got error.
Set tbl = dbs.TableDefs("tbltest")
Set fld = tbl.Fields("test")
fld.DecimalPlaces =4
 
Which Error?

Anyway I don't think you can't achieve your duty like that. In my mind such property can only be set when you create a Table.
Once a table exists and contains data, you must use an SQL statement "ALTER TABLE" in a query.

Unfortunately, I don't find the syntax to set the DecimalPlaces property of a field through ALTER TABLE.

When you change using only VBA code, you must:
Create a NEW field with the new property (ies)
Copy the data of each record from the old to the new field
Delete the old field
Rename the new field as the old one

This would work easily if you no relationship nor indexes on this field....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top