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

Setting Decimal Places property in Back End Table

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
0
0
US
I am using the following code to add a field to a backend table. The field is created fine but the Decimal Places property comes up "Auto" instead of 2 as I am trying to specify. Can anyone give me a hand?
Thanks

Set tdfUpdate = dbsUpdate.TableDefs("tbl2")
With tdfUpdate
Set tdfField = .CreateField("Field1", dbSingle)
.Fields.Append tdfField
tdfField.Properties.Append
tdfF ield.CreateProperty("Caption", dbText,"Field1")
tdfField.Properties.Append
tdfField.CreateProperty("Description", dbText, "This field is Field1")
tdfField.Properties.Append
tdfField.CreateProperty("Format", dbText, "Fixed")
tdfField.Properties.Append
tdfField.CreateProperty("Decimal Places", dbInteger, 2)
End With
 



Hi,

Don't think that you want any decimal places for an INTEGER. Try some floating point data type...
Code:
    tdfField.CreateProperty("Decimal Places", [red][b]dbInteger[/b][/red], 2)

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
I have tried a number of types including dbSingle and dbCurrency. They all set the Decimal Places to "Auto"

Eddy
 

HELP said:
Syntax

Set property = object.CreateProperty (name, type, value, DDL)

The CreateProperty method syntax has these parts.

Part Description
property An object variable that represents the Property object you want to create.
object An object variable that represents the Database, Field, Index, QueryDef, Document, or TableDef object you want to use to create the new Property object.
name Optional. A Variant (String subtype) that uniquely names the new Property object. See the Name property for details on valid Property names.
type Optional. A constant that defines the data type of the new Property object. See the Type property for valid data types.
value Optional. A Variant containing the initial property value. See the Value property for details.
DDL Optional. A Variant (Boolean subtype) that indicates whether or not the Property is a DDL object. The default is False. If DDL is True, users can't change or delete this Property object unless they have dbSecWriteDef permission
Take a look at the NAME property.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
This seems to work for me in

Set tdf = dbs.TableDefs!itemstbl
Set fld = tdf.CreateField("newfield", dbInteger)
tdf.Fields.Append fld
Set prp = fld.CreateProperty("Format", 3, 10)
fld.Properties.Append prp
Set prp = fld.CreateProperty("DecimalPlaces", 2, 2)
fld.Properties.Append prp
 
How are ya EddyLLC . . .

You prescribed:
Code:
[blue]Set tdfField = .CreateField("Field1", [purple][b]dbSingle[/b][/purple])[/blue]
So that:
Code:
[blue]tdfField.CreateProperty("Decimal Places", [purple][b]dbInteger[/b][/purple], 2)
     should be:
tdfField.CreateProperty("Decimal Places", [purple][b]dbSingle[/b][/purple], 2)[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks to everyone. gol4 you nailed it. It created just what I wanted. Thanks again all.
Eddy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top