Breaking News

Tuesday, June 26, 2012

Ex11: VBA - List relationships using ADOX


Function ShowKeyAdox(strTableName As String)
'Purpose: List relationships using ADOX.
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
Dim ky As ADOX.Key
Dim strRIName As String

Set cat.ActiveConnection = CurrentProject.Connection
Set tbl = cat.Tables(strTableName)

For Each ky In tbl.Keys
With ky
Select Case .DeleteRule
Case adRINone
strRIName = "No delete rule"
Case adRICascade
strRIName = "Cascade delete"
Case adRISetNull
strRIName = "Cascade to null"
Case adRISetDefault
strRIName = "Cascade to default"
Case Else
strRIName = "DeleteRule of " & .DeleteRule & " unknown."
End Select
Debug.Print "Key: " & .Name & ", to table: " & .RelatedTable & ", with: " & strRIName
End With
Next

Set ky = Nothing
Set tbl = Nothing
Set cat = Nothing
End Function

No comments:

Post a Comment

Designed By Published.. Blogger Templates