Create Index VBA (1 Viewer)

zezo2021

Member
Local time
Today, 15:30
Joined
Mar 25, 2021
Messages
381
friends
1- Is this the right way to create an index on a table after created using VBA

2- how to set indexed = YES >>>>>Viea VBA Access

Code:
Private Sub Command0_Click()
Dim db As Database
Set db = CurrentDb
With db.TableDefs("MyTable")

     ' Create first Index object, create and append Field
     ' objects to the Index object, and then append the
     ' Index object to the Indexes collection of the
     ' TableDef.
     Set idxlinked = .CreateIndex("LinkedIndex")
     With idxlinked
     .Fields.Append .CreateField("First Name")
     .Fields.Append .CreateField("Last Name")
     .Fields.Append .CreateField("Course Title")
     End With
     .Indexes.Append idxlinked
End With
End Sub
 

sonic8

AWF VIP
Local time
Today, 15:30
Joined
Oct 27, 2015
Messages
998
how to set indexed = YES >>>>>Viea VBA Access
Your code looks fine to me on first glance. What seems to be the problem?
Please note: If a columns is part of a multi-column index, the Indexed property for that column may still be "No" because the column on its own is not indexed.
 

Users who are viewing this thread

Top Bottom