View Single Post
  #5  
Old March 14th, 2006, 07:48 PM posted to microsoft.public.access.tablesdbdesign
external usenet poster
 
Posts: n/a
Default Using Autonumber as PK, cascade update doesn't work?

KevinNGC wrote:
Greetings all,

I've been searching and searching and trying different things and I finally
need to ask.

Is it possible to use an Autonumber PK to cascade update new records?

For example, I have three tables, let's call them Main, Sub1 and Sub2:

In Main I have an Autonumber PK field named MainID.
In Sub1 I have an Autonumber PK field named Sub1ID, and a Number field MainID.
In Sub2 I have an Autonumber PK field named Sub2ID, and a Number field MainID.

I have set up a one-to-many relationship between Main and Sub1, using the
MainID field. Ref. Integrity Enforced, with Cascade Updates checked.

I have set up a one-to-one relationship between Main and Sub2, using the
MainID field. Ref. Integrity Enforced, with Cascade Updates checked.

So when I enter a new record in the Main table, I want that MainID
Autonumber to cascade update into the MainID fields of Sub1 and Sub2. I
don't know if it's not working because it's a new record and Cascade Update
only works if you *change* an already existing record, or if it doesn't work
because it doesn't like my Autonumber.

If anyone has the key to this I would be eternally greatful. I've tried
everything I can think of on my own, and from browsing here, Access Help, etc.

Thanks very much!


You're right that Cascade only affects existing records.

When you create your new record on the Main Table, no record is created
on the Sub1 or Sub2 tables.

It's your job to create these records through your forms.

If you use a subform to enter the data for Sub1, and you've got your
Link Child and Link Master properties setup, then the MainID will be
filled in automagically when you start creating a new record on Sub1. If
you aren't using a subform, then you'll have to explicitly set the value
of MainID yourself = to the MainID on the Main form.

It sounds like you might be trying to enter the new records directly in
table view.

--
-D
Duncan Bachen
Director of I.T., Ole Hansen and Sons, Inc.