[AccessD] Problem Defining New Table Field

Bill Patten bill_patten at embarqmail.com
Tue Oct 21 13:54:26 CDT 2008


Perhaps field names need to be characters does this work?
Set fldNewField = tdfNewDef.CreateField(Cstr(I + 1), dbInteger)

HTH

Bill

----- Original Message ----- 
From: "Kaup, Chester" <Chester_Kaup at kindermorgan.com>
To: "Access Developers discussion and problem solving" 
<accessd at databaseadvisors.com>
Sent: Tuesday, October 21, 2008 11:27 AM
Subject: [AccessD] Problem Defining New Table Field


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.

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list