Gustav Brock
gustav at cactus.dk
Mon Feb 10 09:33:00 CST 2003
Hi Oleg I can't see why this shouldn't work. However, you may try this variation: Set fld = tbl.CreateField("YourField") fld.Type = dbLong fld.Attributes = dbAutoIncrField tbl.Fields.Append fld Stepping through the code, which line failes? /gustav > Hey Andy > Nope, not working :)) > I assume that having it done in function, and saying > OpenDatabase("YoutMDB") instead of CurrentDB made no fifference but i did > it anyway. > Still getting that dreadful type mismatch error.. > (I was able to just the the "Pri Key field, without numbers in it..) > going to try again now... >> Well I just checked it in A2K and it works fine. I'm reposting the code >> so you can just copy and paste it and try it agin, obviously >> substituting your MDB, table and field names. >> >> Function test() >> Dim db As Database >> Dim tbl As TableDef >> Dim fld As Field >> >> Set db = OpenDatabase("YoutMDB") >> Set tbl = db.TableDefs("YourTable") >> >> Set fld = tbl.CreateField("YourField", dbLong) >> fld.Attributes = dbAutoIncrField >> tbl.Fields.Append fld >> >> Set fld = Nothing >> Set tbl = Nothing >> Set db = Nothing >> >> End Function