Creating fields in tdfNew

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access03/WinXP

This should be fairly straightforward, so not sure what I am missing.
Looking at the help example for .CreateField (from the Northwind DB), I am
following the same format:

Set db = CurrentDb
set tdfNew = db.CreateTableDef("zTempBillInfo")

{definition of recordset}
rs.MoveFirst
With tdfNew
.Fields.Append .CreateField("ContactID", vbNumber)
.Fields.Append .CreateField("GroupA", vbCurrency)
...
End With

The code is bombing on the first .Fields.Append with an error "Data Type
Conversion Error" (#3421).

Ideas/suggestions?

Thanks.
 
Okay, I figured out the problem. For each field I was naming, I needed to
add the following line prior to the Append:

set fldName = tdfNew.CreateField(....)

and then after each instance I needed to have the tdfNew.Fields.Append fldName

Also, I discovered that the field definition is vbLong and vbNumber.

Works like a charm.
 
With tdfNew
.Fields.Append .CreateField("ContactID", vbNumber)
.Fields.Append .CreateField("GroupA", vbCurrency)
...
End With

should work, but neither vbNumber or vbCurrency are valid (unless you've
declared them yourself). If ContactID is supposed to be a Long Integer, use
dbLong. Use dbCurrency for GroupA.
 
Back
Top