Owen, it seems that Access caches a bunch of info about the table in the
link, even though that's not all exposed through DAO or other object model.
If my "relinking", you mean the common approach of setting the Connect
property of the TableDef, that might not be enough to get it to discover the
new index. Does it make a difference if you delete the link (attached
table), and recreate it?
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Owen Jenkins" <oj@healthbase.com.auwrote in message
news:44fa0bcb$0$22362$afc38c87@news.optusnet.com.a u...
Quote:
Hi,
>
No-one replied to this when I sent it last week. Any bites out there
today??
>
-----
>
My application allows users to create a new back end for separate
purposes. It does this by using Make Table Queries and Indexing via SQL.
For example ...
>
sqlString = "SELECT * INTO " & TableName & " IN '" & NewDBName & "' FROM
" & TableName & " WHERE 1=2;"
DoCmd.RunSQL sqlString
'The WHERE 1=2 ensures that no records are copied - only the structure is
created.
>
sqlString = "CREATE INDEX AccountNumber ON PatientsT (AccountNumber)
WITH PRIMARY"
NewDB.Execute (sqlString)
>
When this new back end is attached to the front end, creating a new record
is up to 10 times slower than with the original back end. With the various
procedures that the front end goes through, if the back end is on a file
server, it can take up to 10 seconds between hitting my <New record>
button and the cursor appearing in the first field. I can reliably fix
this problem by opening the back end manually in Access, and deleting and
recreating the primary key index using the menu option in the table design
view.
>
I have also tried creating the back end using the following syntax for the
indexes, viz ...
>
Set tdf = db.TableDefs("PatientsT")
Set ind = tdf.CreateIndex("PrimaryKey")
With ind
.Fields.Append .CreateField("AccountNumber")
.Unique = False
.Primary = True
End With
tdf.Indexes.Append ind
>
Both indexing methods appear to work - the primary key icon sits next to
the correct field in the table design window. But the only thing that
makes the file work properly is manually deleting and recreating the
primary key in the table design window. I've tried this with empty tables,
and tables with a small amount of data - makes no difference. Compacting,
refreshing, relinking etc make no difference.
>
Any ideas on what is happening?
>
Owen Jenkins