Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Replacing an ID in all tables (2003)

    I dont know how to approach this issue by using the replace function or something else; i have a profile table that his ID or in this case NAME field is the primary key and doesnt allow duplicates of this info, then I have other tables that have info pertaining to that NAME identifier, they're all in relationship by the NAME field. I want to place a code where if that NAME field it is change for some reason from the profile table to update those other tables with the new NAME. I know that I need the code included in the beforeupdate event of the textbox in form1 or in the beforeupdate event of the form to perform this task. The code will need to know what is the old NAME to replace it with the NEWDATA in the NAME field without changing other people info. I attach a little sample of the database. All help is appreciated!
    Attached Files Attached Files

  2. #2
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Replacing an ID in all tables (2003)

    Why not just set the relationships to allow referential integrity and cascade updates?

    Access will then take of that for you - don't re-invent the wheel if you don't have to!
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Replacing an ID in all tables (2003)

    In the Relationships window, change your relation to Enforce Referential Integrity and Cascade Update Related Fields.
    All the code you need to refresh your form is in the AfterUpdate Event of the textbox Name :

    Private Sub Name_AfterUpdate()
    Me.Refresh
    End Sub
    Francois

  4. #4
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Replacing an ID in all tables (2003)

    Thanks Guys, that did the trick! It does exactly what I want it. Ya the best. Have a great holidays season and a Happy new year!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •