Foriegn Key update

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • irfi@emirates.net.ae

    #1

    Foriegn Key update

    Hi,

    I am a form which has a sub form,

    The sub form is linked with primary key of main form as a foriegn key
    in sub form, very basic,

    In the main form, I have another field which is investor, and in the
    sub form, I have created investory foreign key, this is the second link
    between main form and subm form.

    When i first enter the record, both the primary keys are updated in the
    sub form and it works fine.

    However, if later I have to go adn change the investor (which is a
    requirment) the forien key in the sub form do not get updated, it still
    show old invenstory.

    May be one way of doing is to have an event procedure, on the after
    update of investory field in the main form, which should go to sub form
    and update the investory foreign key to correct investor.

    Can someone please help me with sample code? or sugguest a better way
    of doing this.

    Thanks and Regards, Irf.

  • Mike Preston

    #2
    Re: Foriegn Key update

    On 25 Nov 2005 05:04:26 -0800, irfi@emirates.n et.ae wrote:
    [color=blue]
    >Hi,
    >
    >I am a form which has a sub form,
    >
    >The sub form is linked with primary key of main form as a foriegn key
    >in sub form, very basic,
    >
    >In the main form, I have another field which is investor, and in the
    >sub form, I have created investory foreign key, this is the second link
    >between main form and subm form.
    >
    >When i first enter the record, both the primary keys are updated in the
    >sub form and it works fine.
    >
    >However, if later I have to go adn change the investor (which is a
    >requirment) the forien key in the sub form do not get updated, it still
    >show old invenstory.
    >
    >May be one way of doing is to have an event procedure, on the after
    >update of investory field in the main form, which should go to sub form
    >and update the investory foreign key to correct investor.
    >
    >Can someone please help me with sample code? or sugguest a better way
    >of doing this.[/color]

    Since you say that it works fine with respect to initial entry,
    something is working. It would seem to me that tweaking that would be
    the best way to go.

    So, more information, please.

    There are two ways to have a subform's recordsource update. One is
    through the built=in Access method of linking the master and child
    links. The other way is to set the recordsource yourself, either once
    (assuming it is static) or dynamically.

    Which of these three options have you chosen? Show the details of
    what you have chosen so far.

    mike

    Comment

    • Beacher

      #3
      Re: Foriegn Key update

      Turn on cascading updating and deleting

      Comment

      • Terry Kreft

        #4
        Re: Foriegn Key update

        Create a link between the tables and ensure that Cascade Related Fields is
        switched on.

        --
        Terry Kreft



        <irfi@emirates. net.ae> wrote in message
        news:1132923866 .491200.125780@ o13g2000cwo.goo glegroups.com.. .[color=blue]
        > Hi,
        >
        > I am a form which has a sub form,
        >
        > The sub form is linked with primary key of main form as a foriegn key
        > in sub form, very basic,
        >
        > In the main form, I have another field which is investor, and in the
        > sub form, I have created investory foreign key, this is the second link
        > between main form and subm form.
        >
        > When i first enter the record, both the primary keys are updated in the
        > sub form and it works fine.
        >
        > However, if later I have to go adn change the investor (which is a
        > requirment) the forien key in the sub form do not get updated, it still
        > show old invenstory.
        >
        > May be one way of doing is to have an event procedure, on the after
        > update of investory field in the main form, which should go to sub form
        > and update the investory foreign key to correct investor.
        >
        > Can someone please help me with sample code? or sugguest a better way
        > of doing this.
        >
        > Thanks and Regards, Irf.
        >[/color]


        Comment

        • Terry Kreft

          #5
          Re: Foriegn Key update

          No, you would turn on cascade delete if you want to delete child records
          when the parent record is deleted, that is not what is being asked for.


          --
          Terry Kreft



          "Beacher" <beacher@gmail. com> wrote in message
          news:1132941994 .376449.124330@ z14g2000cwz.goo glegroups.com.. .[color=blue]
          > Turn on cascading updating and deleting
          >[/color]


          Comment

          Working...