Field indexing problem

J

J Welsby

Within my database, a user can run a simulation routine which creates an
Access db in the users temp directory with a few tables. Everything works
fine

I have added the functionality (a checkbox on the form) to allow the user to
index the fields in this simulation db and have created the code below which
should index (or not) the fields in the external db depending on their
selection

The simulation routine runs fine when the user does not have the 'index'
checkbox selection chosen. However, when they want to index, only some of
the tables actually get indexed - it seems that linked forms in the main db
which point to certain tables in the simulation db will stop these tables
from having their indexes appended, updated or whatever

I have tried to close the connection to the simulation database and reopen
it right after this piece of code runs but no luck

Anyone have any ideas?
Many thanks in advance
James


If Me.chkboxIndexSimulationData = -1 Then
With dbNew
For Each tdf In dbNew.TableDefs
If Left(tdf.Name, 3) = "tbl" Then
For Each fld In tdf.Fields
Set ind = tdf.CreateIndex("ind" & fld.Name)
With ind
.Fields.Append .CreateField(fld.Name)
End With
tdf.Indexes.Append ind
Next
End If
Next
End With
Set tdf = Nothing
Set fld = Nothing
Set ind = Nothing
End If

dbNew.TableDefs.Refresh
 

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