• PRIMARY KEY with MAKETABLE command (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » PRIMARY KEY with MAKETABLE command (Access 2000)

    Author
    Topic
    #366343

    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

    Viewing 0 reply threads
    Author
    Replies
    • #567914

      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.

    Viewing 0 reply threads
    Reply To: PRIMARY KEY with MAKETABLE command (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: