Table Locking Problems

J

Jonathan Wood

Greetings,

I use the following code to create a relationship between table A and table
B:

Set rel = db.CreateRelation("A_B")
rel.Table = "A"
rel.ForeignTable = "B"
Set fld = rel.CreateField("AID")
fld.ForeignName = "BID"
rel.Fields.Append fld
db.Relations.Append rel

This code works as expected, but a few lines later I call DLookup() on table
'B' and I get the following error:

"Run-time error '3008': The table 'B' is already opened exclusively by
another user, or it is already open through the user interface and cannot be
manipulated programmatically."

If I comment out the code above, the error goes away. I tried setting rel
and fld to Nothing, and I tried calling db.Tabledefs.Refresh but this
appears to have no effect.

Does anyone understand why this lock is occurring or what I might to about
it?

Thanks.

Jon
 

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