Table relationships and join type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gandalf

    #1

    Table relationships and join type

    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 CreateRelations hip()

    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 = "theChildTa ble"
    strRelName = "myRelationship "
    strFTKey = "foreignTableKe y"
    strRelatedTbl = "parentTabl e"
    strRTKey = "parentTableKey "

    Set catDB = New ADOX.Catalog
    catDB.ActiveCon nection = CurrentProject. Connection

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

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

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

    End Function

  • Matthew Wells

    #2
    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@FirstByt e.ent



    "Gandalf" <Gandalf.Green@ gmail.com> wrote in message
    news:1113055049 .118455.34240@o 13g2000cwo.goog legroups.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 CreateRelations hip()
    >
    > 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 = "theChildTa ble"
    > strRelName = "myRelationship "
    > strFTKey = "foreignTableKe y"
    > strRelatedTbl = "parentTabl e"
    > strRTKey = "parentTableKey "
    >
    > Set catDB = New ADOX.Catalog
    > catDB.ActiveCon nection = CurrentProject. Connection
    >
    > Set key = New ADOX.key
    > With key
    > .Name = strRelName
    > .RelatedTable = strRelatedTbl
    > .Type = adKeyForeign
    > .Columns.Append strFTKey
    > .Columns(strFTK ey).RelatedColu mn = strRTKey
    > End With
    >
    > Set tbl = New ADOX.Table
    > Set tbl = catDB.Tables(st rForeignTbl)
    > tbl.Keys.Append key
    >
    > Set key = Nothing
    > Set tbl = Nothing
    > Set catDB = Nothing
    >
    > End Function
    >[/color]


    Comment

    Working...