sql - How to INDEX a new DAO CreateField on the Fly - MS Access -


i have problem. need take newly created table column (field) had name "id" , index (unique). have tried several ways no success. i'm asking offer fresh perspective. ~ shaw

public sub orclejetounmatched() dim db database dim tdf dao.tabledef dim fld1 dao.field, fld2 dao.field dim idx index dim rst dao.recordset dim hertz string  set db = currentdb()  'copies table data oracle je table; creates / overwrites existing data unmatched table (working table) docmd.runsql "select [oracle je].* unmatched [oracle je];"  set tdf = db.tabledefs("unmatched") set fld1 = tdf.createfield("id", dbtext, 255) set fld2 = tdf.createfield("batchcalc", dbtext, 255) tdf   .fields.append fld1   .fields.append fld2 end  set rst = db.openrecordset("unmatched", dbopentable) until rst.eof   hertz = rst![accounting document item] & mid(rst![je line description], 20, 2) & round(abs(rst![transaction amount]), 0)   rst.edit   rst!id = replace(hertz, " ", "")   rst!batchcalc = mid(rst![je line description], 8, 8)   rst.update   rst.movenext loop rst.close application.refreshdatabasewindow  set fld1 = nothing set fld2 = nothing set tdf = nothing set db = nothing end sub 

if want stick dao object model create field , index it, @ index.createfield method in access' system.

but think it's easier both executing alter table statement ...

currentdb.execute "alter table unmatched add column id text(255) unique;" 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -