Create index using DAO in MS Access

E

Eugene

Hi.
I have a form in MS Access which uses Oracle view as its
source. In that form I need to have an updatable field.
To do that, i have to have a link to the Oracle table and
a Primary key with index.
When I try to link this table first time I'm able to
update the field. Next time I do this, I get different
error messages, such as "Can't create indexes multiple
amount of times..." Also, Primary key and index are no
longer seen ther. I use example from article # 112107, but
looks like it doesn't work for a linked table.
Could you please tell me how to do this with linked table
or show an example? I'm new to MSD Access.

Regards,
Eugene

Here is the script which I'm using:
Sub TDAppendIdx(strName As String, strSource As String,
strConn As String)
Dim db As DAO.Database
Dim td As DAO.TableDef
Dim idx As DAO.Index
Dim Fld As DAO.Field
'Dim StrSQL
Set db = CurrentDb
Set td = db.CreateTableDef(strName)
td.SourceTableName = strSource
td.Connect = strConn
Set idx = td.CreateIndex("PK")
idx.Primary = True
idx.Required = True
idx.IgnoreNulls = False
td.Indexes.Append idx
Set Fld = idx.CreateField("RESULT_ID")
idx.Fields.Append Fld

db.TableDefs.Append td

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top