Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Location
    West Chester, Pennsylvania, USA
    Posts
    5

    Unanswered: Add Record to Multiple Tables

    Exucse me for asking what seems like an easy question, but I do not seem to be able to do the following:

    I have created tables within a database that all have a primary key of First_Name and Last_Name. One of the functions I have on a form is for a user to be able to add a new First_Name and Last_Name into the system.

    I can get the form to add the record to the table the form is linked to, but not to the other tables (probably because my programming skill is very limited).

    I attempted to place code into the OnClick Event to add the records with no success. How can I add new records to the additional tables even though the form is only tied to one specific table source?

    Any help anyone can offer would be most helpful.

    Thanks.

    Neil

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    Use the SQL INSERT INTO statement in conjuction with the RunSQL function.


    SQL The INSERT INTO Statement







    The INSERT INTO Statement

    The INSERT INTO statement is used to insert new rows into a table.

    Syntax

    INSERT INTO table_nameVALUES (value1, value2,....)
    You can also specify the columns for which you want to insert data:

    INSERT INTO table_name (column1, column2,...)VALUES (value1, value2,....)


    Insert a New Row

    This "Persons" table:

    LastName

    FirstName

    Address

    City

    Pettersen

    Kari

    Storgt 20

    Stavanger


    And this SQL statement:

    INSERT INTO Persons VALUES ('Hetland', 'Camilla', 'Hagabakka 24', 'Sandnes')
    Will give this result:

    LastName

    FirstName

    Address

    City

    Pettersen

    Kari

    Storgt 20

    Stavanger

    Hetland

    Camilla

    Hagabakka 24

    Sandnes




    Insert Data in Specified Columns

    This "Persons" table:

    LastName

    FirstName

    Address

    City

    Pettersen

    Kari

    Storgt 20

    Stavanger

    Hetland

    Camilla

    Hagabakka 24

    Sandnes


    And This SQL statement:

    INSERT INTO Persons (LastName, Address)VALUES ('Rasmussen', 'Storgt 67')
    Will give this result:

    LastName

    FirstName

    Address

    City

    Pettersen

    Kari

    Storgt 20

    Stavanger

    Hetland

    Camilla

    Hagabakka 24

    Sandnes

    Rasmussen



    Storgt 67









Posting Permissions

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