Modify a Relation in MS Access / DAO


I am now coding in VB6/DAO (not my idea).

Any ideas on how to modify the attributes of a relation in MS Access?

I would like to remove the attributes for a bunch of relations.  They are now:

dbRelationDeleteCascade + dbRelationUpdateCascade

and I would like to remove them and have the default attributes.

Thanks
Bob
BobsExExAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

earlnoliCommented:
in MS-ACCESS press the "Relationships" button and from there you can delete/modify ang relationships you want.
0
BobsExExAuthor Commented:

I appreciate the feedback.  This is something that I need to do through VB Code using DAO because there are many databases that this will be used on.

Bob
0
earlnoliCommented:
im not really with DAO... why not use ADOX then?  ADO and DAO can exist together anyway in one code...
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

BobsExExAuthor Commented:

Well I am in VB6 - isn't ADOX .NET?  Do you know a way of doing it in regular ADO?
0
earlnoliCommented:
actually ADOX is a part of ADO that deals with table manipulation and such... u cant create a table using ADO, u have to use ADOX... this is actaully the reason ADO is better than DAO, bec it separated its components making it less resource hungry.  But since u specify u need to modify relationships via code, the only way to do it via ADO is using ADOX...

Normally using ADO, you reference...

-Microsoft ActiveX Data Objects 2.5 Library

To use ADOX to manipulate tables and relationships via code... use...

-Microsoft ADO Ext. 2.5 for DLL and Security (this is what im using now, and it depends on what Version of MDAC you currently have)

0
BobsExExAuthor Commented:
I am not sure if you are correct on that.  I usually use ADO and can do anything in there I want with db.execute and I always just use "Microsoft ActiveX Data Objects 2.6 Library".

I am now using DAO because I am working at a new job and here, they only want to use DAO because they are familiar with it, are transitioning from VB to Java (so it won't be an issue anymore), and don't need the problems caused by the small nuances of changing from DAO to ADO (I don't care either way, really).

In any case, what I ended up doing was going through the  DAO db.relations collection, pulling out the .Name, .Table, .ForeignTable, .Field(0).name, and .Field(0).ForeignName values, then deleting the relation with db.Relations.Delete .Name, and then immediately recreating the relation with the same values but with no attributes specified.

Thanks for the attempt, though.

Bob
0
SpideyModCommented:
PAQ'd and points refunded

SpideyMod
Community Support Moderator @Experts Exchange
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
earlnoliCommented:
ah... ic... no problem then...
but im still sure about the ADOX stuff about table manipulation and relationship definition... if u dont believe me... this is a cut and paste defintion of ADOX from the ADO help file... they are just located in one help file together with ADOMD

anyway this is heading of ADOX..

Microsoft® ActiveX® Data Objects Extensions for Data Definition Language and Security (ADOX) is an extension to the ADO objects and programming model. ADOX includes objects for schema creation and modification, as well as security. Because it is an object-based approach to schema manipulation, you can write code that will work against various data sources regardless of differences in their native syntaxes.

ADOX is a companion library to the core ADO objects. It exposes additional objects for creating, modifying, and deleting schema objects, such as tables and procedures. It also includes security objects to maintain users and groups and to grant and revoke permissions on objects.


--------
anyways this is an example how u can create a relationhip on ADOX... which you cant do in ADO alone...


Sub CreateKey()

    Dim kyForeign As New ADOX.Key
    Dim cat As New ADOX.Catalog

    ' Connect the catalog
    cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=c:\Program Files\Microsoft Office\" & _
        "Office\Samples\Northwind.mdb;"

    ' Define the foreign key
    kyForeign.Name = "CustOrder"
    kyForeign.Type = adKeyForeign
    kyForeign.RelatedTable = "Customers"
    kyForeign.Columns.Append "CustomerId"
    kyForeign.Columns("CustomerId").RelatedColumn = "CustomerId"
    kyForeign.UpdateRule = adRICascade
   
    ' Append the foreign key
    cat.Tables("Orders").Keys.Append kyForeign
   
    'Delete the Key as this is a demonstration
    cat.Tables("Orders").Keys.Delete kyForeign.Name
End Sub

---

I hope this clarifies some of ur notions of ADO... DAO sucks bec its all in one package... sometimes you just want to take what you want to use... less network footprint... faster...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.