Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Thanked 0 Times in 0 Posts

    Problems with aqppend query (Access 2000)

    Problems with the append query

    I have the following append query, inserting the data from table products1 into table products:

    INSERT INTO products ( Productid, branch2 )
    SELECT products1.productid, products1.branch2
    FROM products1;

    Since both tables have primary keys, i cannot carry out the append action.The append query works only if i remove manually the primary keys from both tables.My append query works only with the primary keys removed.I have to do it each time i want to append.Since i am appending a lot of times, it is a waste of time.i want to do it programatically,but i do not know how.Is it possible to add some code removing the primary keys,to the following code:

    DoCmd.OpenQuery "AppendOrder", acNormal, acEdit

    So in short what i want is to carry out an appending action with code
    of two tables both having a primary code.Perhpas there is another solution to this problem.I will be very grateful for any help.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Sacramento, California, USA
    Thanked 1 Time in 1 Post

    Re: Problems with aqppend query (Access 2000)

    Are the primary keys autonumbers? If so, and if you actually *want* to append them from one table to the other, try this:

    INSERT INTO products ( Productid, branch2 )
    SELECT CLng(products1.productid), products1.branch2
    FROM products1;

    However, it isn't really clear what you're doing here. If the ProductIDs have meaning in their several tables, then does that meaning change when you append them to the other table? Is it possible that a productID already exists in the Products table? Then your append query will throw a duplicate key or index error.

Posting Permissions

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