CreateRelation to Other Tables file, throws 3409 error

B

brandonjelinek

The following code throws a 3409 Error when i run it from my Development
database. When i run the code with set dbs = currentdb and run it within the
Tables_Main database.. it works.. but when i try to open a workspace and open
it remotely and add the relationship. It fails to work. Is there some trick
to adding a relationship to a remote access 2007 table?

Function NewRelation()
Dim dbs As Database, rel As Relation, fld As Field, wrkplace As Workspace

Set wrkplace = DBEngine.Workspaces(0)
Set dbs = wrkplace.OpenDatabase("Tables_Main.accdb")
Set rel = dbs.CreateRelation ("Main_People_Famlies", "Main_Families",
"Main_People")
rel.Attributes = dbRelationUpdateCascade And dbRelationDeleteCascade
Set fld = rel.CreateField("ID_Main_Famlies")
fld.ForeignName = "ID_Main_Famlies"
rel.Fields.Append fld
dbs.Relations.Append rel
dbs.Relations.Refresh
Set dbs = Nothing
End Function

sorry i accidentally posted this in general twice... might tell you
something about me
 

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