Professional Web Applications Themes

DELETE table and reset AutoNumber - ASP Database

I'm using MS-Access and was wondering if there's a way to DELETE a table and reset the primary key which is an AutoNumber field. If I do "DELETE FROM table_name" then all the rows are removed but the AutoNumber isn't initialized; thus, the next the AutoNumber field after the next INSERT is not 1. Thanks in advance....

  1. #1

    Default DELETE table and reset AutoNumber

    I'm using MS-Access and was wondering if there's a way to DELETE a table and
    reset the primary key which is an AutoNumber field.

    If I do "DELETE FROM table_name" then all the rows are removed but the
    AutoNumber isn't initialized; thus, the next the AutoNumber field after the
    next INSERT is not 1.

    Thanks in advance.


    McKirahan Guest

  2. #2

    Default Re: DELETE table and reset AutoNumber

    McKirahan wrote:
    > I'm using MS-Access and was wondering if there's a way to DELETE a
    > table and reset the primary key which is an AutoNumber field.
    >
    > If I do "DELETE FROM table_name" then all the rows are removed but the
    > AutoNumber isn't initialized; thus, the next the AutoNumber field
    > after the next INSERT is not 1.
    >
    > Thanks in advance.
    This is a frequently-asked question in the Access newsgroups (where it
    should have been asked <grin>)

    The easiest way is to compact the database after the deletion..

    Another way is to change the field to Number and back to AutoNumber.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  3. #3

    Default Re: DELETE table and reset AutoNumber

    "Bob Barrows [MVP]" <reb01501NOyahoo.SPAMcom> wrote in message
    news:#b7GbZMeEHA.1000TK2MSFTNGP12.phx.gbl...
    > McKirahan wrote:
    > > I'm using MS-Access and was wondering if there's a way to DELETE a
    > > table and reset the primary key which is an AutoNumber field.
    > >
    > > If I do "DELETE FROM table_name" then all the rows are removed but the
    > > AutoNumber isn't initialized; thus, the next the AutoNumber field
    > > after the next INSERT is not 1.
    > >
    > > Thanks in advance.
    >
    > This is a frequently-asked question in the Access newsgroups (where it
    > should have been asked <grin>)
    >
    > The easiest way is to compact the database after the deletion..
    >
    > Another way is to change the field to Number and back to AutoNumber.
    >
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >

    You're a god!

    Compacting after deleting and before inserting works great.

    Sorry for posting in the wrong ng; it's just that it was a "db" question and
    I monitor this ng.



    McKirahan Guest

Similar Threads

  1. Delete form - Post data to a table and delete uponsubmit.
    By FusionRed in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: July 28th, 01:27 PM
  2. How do you Reset the palletes in Windows XP? Delete the aiprefs?
    By Vancouver_Workstation@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 4
    Last Post: July 10th, 06:22 AM
  3. Replies: 5
    Last Post: July 2nd, 05:47 PM
  4. Delete key doesn't delete when datagrid is bound to a disconnected table
    By Fred Zolar in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: April 1st, 07:47 AM
  5. How to delete or reset Mozilla default printer
    By Ross Boylan in forum Debian
    Replies: 0
    Last Post: July 23rd, 02:40 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139