Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2013
    Posts
    23

    Unanswered: Create new record in Multiple tables

    When a new record is created in a Parent table, how do I get records created in the child table also.

    I have the ID as the Primary key in the main table - this then becomes the ID in the child tables also. Both are auto numbers

    Any ideas

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I have the ID as the Primary key in the main table - this then becomes the ID in the child tables also. Both are auto numbers
    ...this is not possible
    you cannot have a column in the 'child table' which is a foreign key to the parent table which is an autonumber.


    it may be your terminology, but.

    any table can use an autonumber column as a primary key, an d assumign there is no better way of creating a primary key its fine. if there are 'better' ways of identifying a primary key (usualy a so called natural key, or one that is by definition already there and unique) then its fine. exampoles of a 'natural key could be in an order detail table where you might be tempted to use an autonumber key, but instead coudl use a composite of the order number and a line/item no

    a 'child' table could use an autonumber column as a primary key, but it CANNOT use an autonumber column as a primary key which is also foreign key to a 'parent' table. The foreign key int he child table must be of the saem datatype as the parent table, if you are using an autonumber column in the parent table then use a long integer as the datatype in the child table.

    as to:-
    how do I get records created in the child table also.
    I don't understand what you are asking....
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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