Re: Adding Fields property DecimalPlaces using the fields collection



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

"Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote in message
news:%23kvH$RQOHHA.4172@xxxxxxxxxxxxxxxxxxxxxxx
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?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"jeff" <jeff@work> wrote in message
news:OhDfgNQOHHA.324@xxxxxxxxxxxxxxxxxxxxxxx
Alex
I have changed my code to match yours....

Dim ldbsCurrent As DAODatabase
Dim lrstSource As DAO.Recordset
Dim lfldSource As DAO.Field
Dim lstrDestination As String
Dim lrstDestination As DAO.Recordset
Dim ltdfDestination As DAO.TableDef
Dim lfldDestination As DAO.Field '<<<<<<< added
Dim lprpDestination As DAO.Property
Dim lstrCurrentEntityClass As String
Dim lstrNewEntityClass As String

'using the source fields collection, create fields in the new
table definition
For Each lfldSource In lrstSource.Fields
Set lfldDestination =
ltdfDestination.CreateField(lfldSource.Name, lfldSource.Type)
If lfldSource.Type = dbLong Then
Set lprpDestination =
lfldDestination.CreateProperty("DecimalPlaces", dbByte, 0)
lfldDestination.Properties.Append lprpDestination
'<<<<<<<< fails at this line with error below
End If
ltdfDestination.Fields.Append lfldDestination
ltdfDestination.Fields(lfldSource.Name).AllowZeroLength =
True
Next

'append the new destination table to the tables collection and
'open a new recordset (implicitly closes the previous open
recordset)
ldbsCurrent.TableDefs.Append ltdfDestination
Set lrstDestination =
ldbsCurrent.OpenRecordset(lstrDestination)

Error:

Error# 3219 was generated by DAO.Property
Invalid operation.


It looks as though it should work...but...




.



Relevant Pages

  • Re: Table decimal places
    ... "Hank" wrote in message ... Dim td As DAO.TableDef ... properties and found out that "DecimalPlaces" was number 23 but could ... Some properties, like the Caption property, doesn't exist until they are ...
    (comp.databases.ms-access)
  • Re: Creating Currency Column using ADOX for Access
    ... A Jet Currency field always stores 4 decimal places, ... wrong) the Format and DecimalPlaces properties are not exposed via ADOX. ... Dim tdf As DAO.TableDef ... I have been able to go into Access and modify the database after ...
    (microsoft.public.data.ado)
  • Re: Table decimal places
    ... Dim td As DAO.TableDef ... I tried listing the ... properties and found out that "DecimalPlaces" was number 23 but could ... I added a new table with singles in it and your ...
    (comp.databases.ms-access)
  • RE: Multiply qty of filtered records
    ... If you should want to try doing this with a query (which is probably the more ... etc in the bottom part of the design view. ... I do know how to get this information in a Report, ... Dim rs As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: Default use Specific Printer and Label Size
    ... Thanks, however this is a .mde file, so the design view wouldn't be available. ... Dim rpt As Access.Report ... Dim lngNumber As Long ... 'print to the label printer ...
    (comp.databases.ms-access)