?
Solved

Modify a Relation in MS Access / DAO

Posted on 2003-02-26
8
Medium Priority
?
341 Views
Last Modified: 2013-12-25

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
0
Comment
Question by:BobsExEx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 

Expert Comment

by:earlnoli
ID: 8046324
in MS-ACCESS press the "Relationships" button and from there you can delete/modify ang relationships you want.
0
 

Author Comment

by:BobsExEx
ID: 8058503

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
 

Expert Comment

by:earlnoli
ID: 8061346
im not really with DAO... why not use ADOX then?  ADO and DAO can exist together anyway in one code...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:BobsExEx
ID: 8064212

Well I am in VB6 - isn't ADOX .NET?  Do you know a way of doing it in regular ADO?
0
 

Expert Comment

by:earlnoli
ID: 8068723
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
 

Author Comment

by:BobsExEx
ID: 8071763
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
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8072811
PAQ'd and points refunded

SpideyMod
Community Support Moderator @Experts Exchange
0
 

Expert Comment

by:earlnoli
ID: 8076426
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question