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

    PRIMARY KEY with MAKETABLE command (Access 2000)

    PRIMARY KEY with MAKETABLE command

    I have a very useful function used for append purposes. Unfortunately i have no primary key in the
    newly made table called orders 2 and hence i have problems with the appendments.Is it possible to
    make the field orderid in the table orders2 with primary key ? The field orderid in the original table called orders1 has a primary key,

    but this key is not inherited in the table orders2
    I am using the following function:
    Public Function Stock()
    Private Const strDepotWhere As String = " WHERE ((([orders1].[orderdate])>#1/1/2002#));"
    Dim strOrders As String
    strOrders = " SELECT orders1.orderid, orders1.customerid, orders1.orderdate INTO orders2 FROM orders1"
    CurrentDb.Execute strOrders & strDepotWhere
    Is it possible to place the command PRIMARY KEY somehere in my strOrders line ?
    I will be grateful for any reply

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Evergreen, CO, USA
    Thanked 65 Times in 64 Posts

    Re: PRIMARY KEY with MAKETABLE command (Access 2000)

    Unfortunately the Make Table query in Access cannot create a primary key on a table. In order to do that you have to run some code after the maketable query to actually create the index and declare it as the primary key. There was a thread a few days ago on this same subject - do a search on Primary Key and you should find it very quickly. As I recall one of the post included the code to do exactly what you need.

Posting Permissions

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