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

Are you entering a record directly into the table? If so, how are you
entering the related record(s)? You really shoud be using forms, if you are
not already.
Typically you would have a form frmMain based on tblMain, and subforms
(fsubSub1 and fsubSub2) based on tblSub1 and tblSub2. If you add to the
main form and the subforms a text box bound to MainID (in the record source
table for that particular form or subform) you will have an easier time
seeing what is going on.
Because of the relationships between tblMain and tblSub1/tblSub2, every
record you create in the subform will have the same value in MainID as does
frmMain. Below the surface, all of those records created through the
subforms will have the same value in MainID as did the parent record (the
one entered by way of frmMain).
This is not Cascade Update. Cascade Update occurs if you need to change the
PK in tblMain. It will update the FK field (MainID) in the subforms,
assuring that relationships that existed before the change still exist after
the change. If MainID in tblMain is 999, MainID in related records in
tblSub1/tblSub2 will also be 999. If you change 999 to 1234 in tblMain, 999
will also change to 1234 in tblSub1/tblSub2.

"KevinNGC" wrote in message
news
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!