Results 1 to 5 of 5
  1. #1
    hajredin is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    2

    Smile Insert on tbl2 automatically when inserted on tbl1

    Hi,

    I am new in this forum,



    Can I do automatically insert on tbl2 table when i inserted on tbl1. tbl2 have 5 columns same with tbl1. When I insert on tbl1 from form automatically the new record can insert on tbl2.

    How can I do that?

    thanks for any help

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Welcome to the forum!

    What data are you going to put into tbl2? Is it the same data that is going into tbl1? What is the relationship between the info in tbl1 and tbl2? Could you provide some examples?

  3. #3
    hajredin is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    2
    Thanks for you answer Vip

    they are only some columns same on the tables not all,

    for example

    tbl1

    tID (autonumber) primary key
    tNumber of Fatura (text)
    Number of Cemer (text)

    tbl2

    CID (autonumber) primary key
    CNumber of Fatura (text)
    Date

    Now, when I insert data or new record on the tbl1, I want the database automatically insert the same data from the column (tID and tNumber of Fatura) tbl1 on the column (CID (autonumber) CNumber of Fatura) of table tbl2.

    Relatioship is one to one, but without Enforce Referential Integrity.

    thanks a lot.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    If the relationship is indeed one-to-one then I would recommend going with one table. If the relationship were one-to-many, then you would only need to reference the key field (tID) in the second table. Copy any more data than that would violate good database practices.

  5. #5
    Amicron's Avatar
    Amicron is offline Access Guru
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Amherst, New York (near Buffalo)
    Posts
    32
    These tables are RELATED, or just DUPLICATES? If they're related, then where is your FOREIGN key? You've got two PRIMARY keys. If you are relating these records together, then you can't use an AutoNumber in your second table. You'll need to just copy the AutoNumber that's assigned to table1 into table2.

    Personally, I would just use a little APPEND QUERY to do this. Once the record is entered into table1, you could make a little SAVE button (disable all other means of exiting the form) and have that save the record and append the data to the second table.

    Again, though, I would ask you to clarify EXACTLY what you're trying to do with these tables... like jzwp11 said, however, there are very few times where you would want to set something up like this with a 1-to-1 relationship. One of the only times you do this is if you have a lot of records (say, customers) and you have PRIMARY data for most of them (name, address, phone, etc.) but on SOME of them you have a LOT of additional data (spouse, color preferences, notes, etc.). You can throw that extra data into a related table so you're not reserving ALL of that extra space in your primary customer table for just a few customers.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Empty line inserted in database
    By jimgros in forum Forms
    Replies: 7
    Last Post: 08-27-2011, 06:04 AM
  2. Replies: 4
    Last Post: 08-01-2011, 03:36 PM
  3. additional detail records to be inserted
    By Mclaren in forum Reports
    Replies: 1
    Last Post: 03-16-2011, 02:10 AM
  4. Replies: 4
    Last Post: 02-11-2011, 10:25 AM
  5. Replies: 7
    Last Post: 04-27-2010, 10:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums