Re: Adding Fields property DecimalPlaces using the fields collection



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