Connecting Tech Pros Worldwide Forums | Help | Site Map

Table relationships and join type

Gandalf
Guest
 
Posts: n/a
#1: Nov 13 '05
I'm creating relationships between tables using VBA and ADOX. I can
create one-to-one relationships with an inner join, but I can't figure
out how to create these relationships with an outer join (specifically
a left outer join). I'm including the code that creates the
relationships with the inner join. Any help or suggestions would be
greatly appreciated.

Thanks!

<----- CODE FOLLOWS ----->

Function CreateRelationship()

Dim catDB As ADOX.Catalog
Dim tbl As ADOX.Table
Dim key As ADOX.key

Dim strForeignTbl As String
Dim strRelName As String
Dim strFTKey As String
Dim strRelatedTbl As String
Dim strRTKey As String

strForeignTbl = "theChildTable"
strRelName = "myRelationship"
strFTKey = "foreignTableKey"
strRelatedTbl = "parentTable"
strRTKey = "parentTableKey"

Set catDB = New ADOX.Catalog
catDB.ActiveConnection = CurrentProject.Connection

Set key = New ADOX.key
With key
.Name = strRelName
.RelatedTable = strRelatedTbl
.Type = adKeyForeign
.Columns.Append strFTKey
.Columns(strFTKey).RelatedColumn = strRTKey
End With

Set tbl = New ADOX.Table
Set tbl = catDB.Tables(strForeignTbl)
tbl.Keys.Append key

Set key = Nothing
Set tbl = Nothing
Set catDB = Nothing

End Function


Matthew Wells
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Table relationships and join type


To the best of my knowledge, relationships don't use outer joins, jsut
cascading updates and deletes and enforcing referential integrigty. Outer
joins are only used in queries.

Matthew Wells
MWells@FirstByte.ent



"Gandalf" <Gandalf.Green@gmail.com> wrote in message
news:1113055049.118455.34240@o13g2000cwo.googlegro ups.com...[color=blue]
> I'm creating relationships between tables using VBA and ADOX. I can
> create one-to-one relationships with an inner join, but I can't figure
> out how to create these relationships with an outer join (specifically
> a left outer join). I'm including the code that creates the
> relationships with the inner join. Any help or suggestions would be
> greatly appreciated.
>
> Thanks!
>
> <----- CODE FOLLOWS ----->
>
> Function CreateRelationship()
>
> Dim catDB As ADOX.Catalog
> Dim tbl As ADOX.Table
> Dim key As ADOX.key
>
> Dim strForeignTbl As String
> Dim strRelName As String
> Dim strFTKey As String
> Dim strRelatedTbl As String
> Dim strRTKey As String
>
> strForeignTbl = "theChildTable"
> strRelName = "myRelationship"
> strFTKey = "foreignTableKey"
> strRelatedTbl = "parentTable"
> strRTKey = "parentTableKey"
>
> Set catDB = New ADOX.Catalog
> catDB.ActiveConnection = CurrentProject.Connection
>
> Set key = New ADOX.key
> With key
> .Name = strRelName
> .RelatedTable = strRelatedTbl
> .Type = adKeyForeign
> .Columns.Append strFTKey
> .Columns(strFTKey).RelatedColumn = strRTKey
> End With
>
> Set tbl = New ADOX.Table
> Set tbl = catDB.Tables(strForeignTbl)
> tbl.Keys.Append key
>
> Set key = Nothing
> Set tbl = Nothing
> Set catDB = Nothing
>
> End Function
>[/color]


Closed Thread