
Create an Index USING CODE on existing table
You need to append a field to the index's fields collection,
such as (air code):
Set db = CurrentDb
Set tdf = db.TableDefs("Table1")
Set idx = tdf.CreateIndex("Index1")
Set fld = idx.CreateField("Field1")
idx.Fields.Append fld
tdf.Indexes.Append idx
--
MichKa
-------------------------------------
don't send questions by e-mail unless
you're paying for it. (TANSTAAFL!) :-)
random junk of dubious value and
replica error and problem fixing at:
http://www.trigeminal.com
Quote:
> I have to create an index Using CODE on existing table.
Here is my code
> below what am i doing wrong. thank very much in advanece.
> Dim mydb as database
> Dim tmpNewPerson As TableDef
> Dim LastName As Index
> Dim LName As Field
> Set mydb = currentdb
> Set tmpNewPerson = mydb.TableDefs!tmpNewPerson
> Set LastName = tmpNewPerson.CreateIndex("LN")
> Set LName = tmpNewPerson.Fields("LNAME")
> tmpNewPerson.Indexes.Append LName