DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: cascading updates in relationships

  1. #1
    Alan Shiers Guest

    cascading updates in relationships

    Hi there:
    I'm in the process of creating a database using DAO and defining a
    relationship between two tables. The first table is called "Contacts",
    the other is called "Correspondence". When I define the relationship
    with:

    Dim rel As Relation
    Dim fl As Field

    Set rel = db.CreateRelation("relContacts", "Contacts", "Correspondence",
    dbRelationDeleteCascade + dbRelationUpdateCascade)
    Set fl = rel.CreateField("Cust_ID")
    fl.ForeignName = "Cust_ID"
    rel.Fields.Append fl
    db.Relations.Append rel

    this appears to work. That is I don't get any error messages. When I
    delete a record from the Contacts table indeed all related records in
    Correspondence are also deleted. However, when I change a record, for
    instance, the clients first name in the Contacts table and click on the
    Update button I would expect that all related records in Correspondence
    table would reflect the change also. But that is not what is
    happening. According to the help files on DAO under Attributes Property
    we're allowed to combine the constants dbRelationDeleteCascade and
    dbRelationUpdateCascade. Certainly the dbRelationDeleteCascade is
    working as expected but the dbRelationUpdateCascade is not. Does anyone
    have any suggestions or insights in this?

    Alan



  2. #2
    Larry Rebich Guest

    Re: cascading updates in relationships

    Alan,

    I'm not sure but I think the update only occurs on the relationship field
    since this is the field defined in the relationship. Have you defined a
    relationship for First Name?

    I usually test these kinds of thinks with Access. I open the tables in
    access and make changes then see what happens.

    Cheers,
    Larry Rebich

    larry@buygold.net
    www.buygold.net


    "Alan Shiers" <jshiers@istar.ca> wrote in message
    news:38F1F4B6.38293B92@istar.ca...
    > Hi there:
    > I'm in the process of creating a database using DAO and defining a
    > relationship between two tables. The first table is called "Contacts",
    > the other is called "Correspondence". When I define the relationship
    > with:
    >
    > Dim rel As Relation
    > Dim fl As Field
    >
    > Set rel = db.CreateRelation("relContacts", "Contacts", "Correspondence",
    > dbRelationDeleteCascade + dbRelationUpdateCascade)
    > Set fl = rel.CreateField("Cust_ID")
    > fl.ForeignName = "Cust_ID"
    > rel.Fields.Append fl
    > db.Relations.Append rel
    >
    > this appears to work. That is I don't get any error messages. When I
    > delete a record from the Contacts table indeed all related records in
    > Correspondence are also deleted. However, when I change a record, for
    > instance, the clients first name in the Contacts table and click on the
    > Update button I would expect that all related records in Correspondence
    > table would reflect the change also. But that is not what is
    > happening. According to the help files on DAO under Attributes Property
    > we're allowed to combine the constants dbRelationDeleteCascade and
    > dbRelationUpdateCascade. Certainly the dbRelationDeleteCascade is
    > working as expected but the dbRelationUpdateCascade is not. Does anyone
    > have any suggestions or insights in this?
    >
    > Alan
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center