Results 1 to 4 of 4

Thread: Relationships

  1. #1
    Join Date
    May 2003
    Posts
    70

    Unanswered: Relationships

    Hi,

    I am using VB to read relationships in an Access DB.

    How would I find out whether a relationshis is Cascade Delete or Cascade Update?

    I am using DAO.

    Thanks

  2. #2
    Join Date
    Jun 2002
    Location
    Mpls/St.Paul area
    Posts
    303

    Re: Relationships

    Here is a little bit of code that I tried just to read the relationships.

    Function gRelationships()

    ....Dim dbs As DAO.Database
    ....Dim ThisRelation As DAO.Relation

    ....On Error GoTo ErrorHandler
    ....Set dbs = CurrentDb

    ....For i = 0 To dbs.Relations.Count - 1
    ........Set ThisRelation = dbs.Relations(i)
    ........Debug.Print "Properties of " & ThisRelation.Name & " Relation"
    ........Debug.Print " Table = " & ThisRelation.Table
    ........Debug.Print " ForeignTable = " & ThisRelation.ForeignTable
    ........Debug.Print " Attributes " & ThisRelation.Attributes & " Attributes"
    ....Next i


    ....GoTo endsub: 'Skip error handler
    ErrorHandler:
    ....MsgBox Err.Number & vbCrLf & Err.Description
    endsub:
    ....Set frmCRF = Nothing
    End Function


    Sorry I don't know anymore than that
    John
    This is the day the Lord has made, I will rejoice and be glad in it.

  3. #3
    Join Date
    Oct 2003
    Location
    Roanoke, Va
    Posts
    445

    Re: Relationships

    Originally posted by vbgladiator
    Hi,

    I am using VB to read relationships in an Access DB.

    How would I find out whether a relationshis is Cascade Delete or Cascade Update?

    I am using DAO.

    Thanks
    One way.

    Use the UpdateRule property of the Key object.

    Dim cat1 as ADOX.Catalog
    Set cat1 = New ADOX.Catalog

    MsgBox cat1.Tables("TableName").Keys("PrimaryKey").Update Rule

    Just used the primarykey as an example.

    Using the ADOX.RuleEnum you can see what the different numbers mean. 0 = adRINone, 1 = adRICascade etc...

    Gregg

  4. #4
    Join Date
    May 2003
    Posts
    70
    I have to use DAO.

    Thanks guys, It is in the attributes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •