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...
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...