Create an Index USING CODE on existing table 
Author Message
 Create an Index USING CODE on existing table

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



Tue, 02 Apr 2002 03:00:00 GMT  
 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



Tue, 02 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Create code for existing tables

2. Create Index using SQL in Access 2000 Table

3. Create Index using SQL in Access 2000 Table

4. Create Index using SQL in Access 2000 Table

5. Using Codes to scheck if a table exists in Access database

6. Create new field in existing table exactly like field in second table

7. Problem with creating a table in Access from existing table

8. Referencing an existing table index in VB with Access 2000

9. Index already exists (while creating relationship)

10. Trouble running report off a table that was just created using VB code

11. Help using existing FoxPro or Dbase Indexes with VB5

12. Creating Indexes after Make Table query

 

 
Powered by phpBB® Forum Software