[AccessD] Problem Defining New Table Field

Kaup, Chester Chester_Kaup at kindermorgan.com
Tue Oct 21 13:27:08 CDT 2008


I want to define a field in a new table as an integer type in VBA. The compiler does not like the following statement. I is dimmed as an integer. Message is runtime error 3001 invalid argument

Set fldNewField = tdfNewDef.CreateField(CInt(I + 1), dbInteger)

I have also tried the following version with the same error
Set fldNewField = tdfNewDef.CreateField(I + 1, dbInteger)
Set fldNewField = tdfNewDef.CreateField(I + 1)

This statement however works
Set fldNewField = tdfNewDef.CreateField(CStr(I + 1), dbText)

Here is the whole loop it is in if that matters
For I = 0 To rstSource.RecordCount - 1
    Set fldNewField = tdfNewDef.CreateField(CStr(I + 1), dbText)
    tdfNewDef.Fields.Append fldNewField
Next I

Thanks for any ideas.



Chester Kaup

Engineering Technician

Kinder Morgan CO2 Company, LLP

Office (432) 688-3797

FAX (432) 688-3799





No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.




More information about the AccessD mailing list