G
Gibson
I am trying to change the Indexed property field of a backend table from
'Indexed (No Duplicates)' to 'Indexed (Duplicates OK)' . I am trying to do
this through code from the front end. I am trying the following code below.
I realize there most probably substantial errors in the code. I am new to
this. A problem occurs when I get to the line that deletes FIELD1. I
receive an Item not found in collection error. As you can readily see, I am
floundering a bit. First of all do I have to delete the field and or index
in order to change it? Can anybody give me some guidence here or guide me to
somewhere I can find some answers. This is something I will be using in the
future so I need to learn this.
Thanks for any help.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wrkJet.OpenDatabase("C:\BACKEND.MDB", True)
'Table to Change
Set tdf = db.TableDefs("flkpTABLE1")
'Delete problem index
tdf.Indexes.Delete ("FIELD1")
'Build new index
With tdf
Set idx = .CreateIndex("INDEX")
With idx
.Fields.CreatField ("NewField")
End With
'Add index t collection
.Indexes.Append idx
End With
db.Close
Set db = Nothing
End Sub
'Indexed (No Duplicates)' to 'Indexed (Duplicates OK)' . I am trying to do
this through code from the front end. I am trying the following code below.
I realize there most probably substantial errors in the code. I am new to
this. A problem occurs when I get to the line that deletes FIELD1. I
receive an Item not found in collection error. As you can readily see, I am
floundering a bit. First of all do I have to delete the field and or index
in order to change it? Can anybody give me some guidence here or guide me to
somewhere I can find some answers. This is something I will be using in the
future so I need to learn this.
Thanks for any help.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wrkJet.OpenDatabase("C:\BACKEND.MDB", True)
'Table to Change
Set tdf = db.TableDefs("flkpTABLE1")
'Delete problem index
tdf.Indexes.Delete ("FIELD1")
'Build new index
With tdf
Set idx = .CreateIndex("INDEX")
With idx
.Fields.CreatField ("NewField")
End With
'Add index t collection
.Indexes.Append idx
End With
db.Close
Set db = Nothing
End Sub