Access append query...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sakakini
    New Member
    • Jun 2007
    • 3

    #1

    Access append query...

    How ccan append last entry form one table to another????
  • tdw
    New Member
    • Mar 2007
    • 206

    #2
    Originally posted by Sakakini
    How ccan append last entry form one table to another????
    Create an append query. If you are trying to copy the record from Table1 to Table2, the SQL will look something like this:
    Code:
    INSERT INTO Table2
    SELECT Table1.*
    FROM Table1
    WHERE ((([Forms]![Formname]![Fieldname])=[Table1]![Fieldname]));
    Then if you want to delete the record from Table1 after copying it to Table2, create a delete query, which would like something like this:
    Code:
    DELETE Table1.*
    FROM Table1
    WHERE ((([Forms]![Formname]![Fieldname])=[Table1]![Fieldname]));

    Comment

    • Sakakini
      New Member
      • Jun 2007
      • 3

      #3
      Originally posted by tdw
      Create an append query. If you are trying to copy the record from Table1 to Table2, the SQL will look something like this:
      Code:
      INSERT INTO Table2
      SELECT Table1.*
      FROM Table1
      WHERE ((([Forms]![Formname]![Fieldname])=[Table1]![Fieldname]));
      Then if you want to delete the record from Table1 after copying it to Table2, create a delete query, which would like something like this:
      Code:
      DELETE Table1.*
      FROM Table1
      WHERE ((([Forms]![Formname]![Fieldname])=[Table1]![Fieldname]));

      I tried what you have suggested and it create a new col. in the query. Maybe I was not clear in my quest for an answer to my question. Let me try again:
      I have two tables, Table1 and Table2. Table1 has 5 fields out of which 2 fields I want to copy from table2. Here is my delima. when I enter new record into tablel I need to pick the 2 new fileds and append table1 by insurting these two fileds in a new record in table1.
      Awaiting your advice....
      Thanks,

      Comment

      • tdw
        New Member
        • Mar 2007
        • 206

        #4
        Originally posted by Sakakini
        I tried what you have suggested and it create a new col. in the query. Maybe I was not clear in my quest for an answer to my question. Let me try again:
        I have two tables, Table1 and Table2. Table1 has 5 fields out of which 2 fields I want to copy from table2. Here is my delima. when I enter new record into tablel I need to pick the 2 new fileds and append table1 by insurting these two fileds in a new record in table1.
        Awaiting your advice....
        Thanks,
        Yes, that is a little different than I was thinking. Unfortunately I don't quite understand exactly what you are trying to do. Maybe the answer to the following questions will help:

        1. Are you entering data from a form, and what table is the form's control source?
        2. How are you entering data into the other table? What is it's purpose?

        Go ahead and give me specific table and field names so we can avoid using confusing nicknames for your fields.

        Comment

        • stpark22
          New Member
          • Jun 2007
          • 8

          #5
          Originally posted by Sakakini
          I tried what you have suggested and it create a new col. in the query. Maybe I was not clear in my quest for an answer to my question. Let me try again:
          I have two tables, Table1 and Table2. Table1 has 5 fields out of which 2 fields I want to copy from table2. Here is my delima. when I enter new record into tablel I need to pick the 2 new fileds and append table1 by insurting these two fileds in a new record in table1.
          Awaiting your advice....
          Thanks,
          If I'm understanding this correctly, it appears that you want to update certain fields in a table instead of adding a series of records to a table. If so, you must run an "Update" query. Here is a generic SQL statement illustrating this.

          UPDATE Table1
          INNER JOIN Table2
          ON Table1.[JOIN KEY] = Table2.[JOIN KEY]
          SET
          Table1.[FIELD 4] = [Table2]![FIELD 1],
          Table1.[FIELD 5] = [Table2]![FIELD 2];

          Hope this helps...

          Comment

          Working...