Hello,
I try to use the ADOX model with an Access2K mdb from a VB6 project.
The ADOX Help reports :
"The Microsoft OLE DB Provider for the Microsoft Jet Database Engine fully
supports ADOX."
I hope so, but...
I have pairs of tables with many-to-many relationships between them.
I can browse the Keys collection of the tables, test whether a table's key
is primary or not, but the RelatedTable property then fails to return the
correspondance table name (Object variable not set).
I would like to know whether I misunderstood something, or if this has to be
considered as a bug.
Sample code here below.
Thanks for posting.
Naum Jancen
-----------------------------------------------------------
The Engine object is the lower layer of my object model, it holds a
connection, returns recordsets and an ADOX catalog.
Private Sub Query(ByVal ClientName As String, ByVal ServerName As String)
Dim ClientSide As String
Dim ServerSide As String
Dim Key As Key
With Engine.Catalog.Tables(ClientName)
For Each Key In .Keys
If Key.Type = adKeyPrimary Then ClientSide = Key.RelatedTable
Next Key
End With
With Engine.Catalog.Tables(ServerName)
For Each Key In .Keys
If Key.Type = adKeyPrimary Then ServerSide = Key.RelatedTable
Next Key
End With
If Not ClientSide = ServerSide Then
MsgBox ClientName & " <=> " & ServerName & _
": Not a many-to-many relationship", vbCritical
Set mRecordset = Nothing
Exit Sub
End If
Set mRecordset = Engine.GetRecordset(ClientSide, mLockType, mRowMode)
mDataMember = ClientSide
End Sub