Given that a Long Integer cannot have any decimal places, it really doesn't
make sense to set the DecimalPlaces property for such a field.
I'm wondering if that's the problem?

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
> Alex
> I have changed my code to match yours....
[quoted text clipped - 39 lines]
>
> It looks as though it should work...but...
jeff - 16 Jan 2007 01:04 GMT
Thx Douglas for the input!
When viewing an equivalent field in the table design view, the field is set
to Number and has a field size of Long Integer with Decimal Places set to 2.
The data in the field is showing 2 decimal places, so it appears that it is
correct.
I understand what you are saying in that an Integer by definition is a whole
number and therefore no decimal places...but I am not sure that Access
understands this.. <grinning>. The Access Design view allows a size of Long
Integer to be specified and Decimal Places of 2 to be set.
It is baffling me...but i May just have to find a workaround...more to
come...
cheers
Jeff
> Given that a Long Integer cannot have any decimal places, it really
> doesn't make sense to set the DecimalPlaces property for such a field.
[quoted text clipped - 44 lines]
>>
>> It looks as though it should work...but...
jeff - 16 Jan 2007 02:30 GMT
Guys
I have done some more work...I enumerated the properties of a manually
created tabledef with the appropriate field def using the table design
view:-
PercentageUsage
Value = 18
Attributes = 34
CollatingOrder = 18
Type = 20
Name = PercentageUsage
OrdinalPosition = 4
Size = 16
SourceField = PercentageUsage
SourceTable = tblXML_FieldUsage_Component
ValidateOnSet = False
DataUpdatable = True
ForeignName
DefaultValue = 0
ValidationRule =
ValidationText =
Required = False
AllowZeroLength = False
FieldSize = 4
OriginalValue =
VisibleValue =
ColumnWidth = -1
ColumnOrder = 0
ColumnHidden = False
Description = Percentage Usage of the Field in the Table
PercentageUsage
DecimalPlaces = 2
DisplayControl = 109
Type = 20 is for a DAO object a dbDecimal and the Type for the DecimalPlaces
is 2 (dbByte).so I tried the following...
If lfldSource.Name = "PercentageUsage" Then
Set lfldDestination =
ltdfDestination.CreateField(lfldSource.Name, dbDecimal)
Set lprpDestination =
lfldDestination.CreateProperty("Decimal Places", dbByte, 0)
lfldDestination.Properties.Append lprpDestination
Else
Set lfldDestination =
ltdfDestination.CreateField(lfldSource.Name, lfldSource.Type)
End If
and now I get an error of:-
Error# 3259 was generated by DAO.Field
Invalid field data type.
the saga continues...
jeff
> Given that a Long Integer cannot have any decimal places, it really
> doesn't make sense to set the DecimalPlaces property for such a field.
[quoted text clipped - 44 lines]
>>
>> It looks as though it should work...but...
jeff - 16 Jan 2007 03:18 GMT
Guys and finally....
It appears that the table needs to be appended to the TableDefs collection
BEFORE adding these properties...maybe something to do with the fact that
they only relate to an Access database table and not say a SQL database
table??? (maybe barking up the wrong tree). Anyway by simply creating the
tabledef completely and appending it to the collection I then changed the
particular fields proeprties as below:-
ldbsCurrent.TableDefs.Append ltdfDestination
Set ltdfDestination = ldbsCurrent.TableDefs(lstrDestination)
Set lfldDestination = ltdfDestination.Fields("PercentageUsage")
Set lprpDestination = lfldDestination.CreateProperty("Format",
dbText, "Fixed") '<=this appears critical
lfldDestination.Properties.Append lprpDestination
Set lprpDestination =
lfldDestination.CreateProperty("DecimalPlaces", 2, 0) '<= this now
works....
lfldDestination.Properties.Append lprpDestination
Anyway...it achieved the result I was after...BTW the field was first
created as a Double....maybe there is something to that!
cheers and thanks to Alex and Doug for your Input!!
aussie jeff
> Given that a Long Integer cannot have any decimal places, it really
> doesn't make sense to set the DecimalPlaces property for such a field.
[quoted text clipped - 44 lines]
>>
>> It looks as though it should work...but...
Alex Dybenko - 16 Jan 2007 11:57 GMT
Great, that you made it work. But strange, AFAIR - in my code for just
created field it was required to add first properties. I never understand
this...

Signature
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
> Guys and finally....
>
[quoted text clipped - 73 lines]
>>>
>>> It looks as though it should work...but...