Results 1 to 4 of 4
  1. #1
    ducthang88 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    12

    insert into another table from another table


    this is the scenario... I have a form named Borrower, Books and Borrowedbooks...

    From the form Books, i have a command button which what i want is to select the current value on the textbox (BorrowerNo) in the form Borrower and put it in the (BorrowerNo) field in the Borrowedbooks...

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    If your tables are joined properly, you should be able to use a form with a subform to enter the data without the need to execute any code behind the command button.

    Could you provide the fields of the tables you mention and how those tables are related?

  3. #3
    ducthang88 is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    12
    i have a:

    borrower table connected to borrowedbooks table (via borrowerno)
    -borrowerno(PK)(auto)
    -Lname
    -Fname
    -Mi
    -Contact

    borrowedbooks table (via borrowerno)
    -bookno(PK)(auto)
    -borrowerno
    -title
    -author


    Books table (standalonetable)
    -accessno (auto)
    -title
    -author

    then ive created a form with 2 subforms..

    the main form is the borrower then 2 subforms which is books then borrowedbooks..
    the command button is in the books which i want is to copy the value of borrowerno (in the main form borrower) then copy it in the table of the borrowerno in the borrowedbooks

  4. #4
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Since a book can be borrowed by many people and a person can borrow many books, you have a many-to-many relationship. Your tables are almost correct; the borrowed books table needs a little tweak. There is no need to repeat title/author of the book in the borrowed book table

    borrower table connected to borrowedbooks table (via borrowerno)
    -borrowerno(PK)(auto)
    -Lname
    -Fname
    -Mi
    -Contact

    borrowedbooks table (via borrowerno)
    -bookno(PK)(auto)
    -borrowerno foreign key to borrower table
    -accessno foreign key to books table


    Books table (standalonetable)
    -accessno pk, auto
    -title
    -author

    In terms of forms, you would have your main form based on the borrower table and the subform based on the borrowed books table. Within that subform, you would use a combo box based on the books table to populate the accessno. I do not see a way for you to determine when a book is borrowed/returned. How do you plan on tracking that?

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

Similar Threads

  1. Insert query into table FROM two table sources
    By svcghost in forum Queries
    Replies: 2
    Last Post: 11-05-2010, 09:10 AM
  2. Insert Record checks table
    By pfarnell in forum Forms
    Replies: 13
    Last Post: 09-05-2010, 10:47 AM
  3. Insert into table
    By Mclaren in forum Programming
    Replies: 4
    Last Post: 05-02-2010, 11:28 PM
  4. Replies: 0
    Last Post: 02-24-2010, 12:56 AM
  5. Insert Query output into a table
    By ammu_sridhar in forum Programming
    Replies: 1
    Last Post: 06-12-2009, 01:09 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