Group:  Microsoft Access » microsoft.public.access.modulesdaovba.ado
Thread: Clear Database and Reset the AutoNumber

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Clear Database and Reset the AutoNumber
"jillian.calderon[ at ]gmail.com" <jillian.calderon[ at ]gmail.com> 21.07.2006 15:41:25
Good Morning Everyone,

I'm making a database and I'm playing with it using test data. When
I want to put the actual data in, how do I reset the autonumber back to
1? How do I tell the database to completely delete the fake records so
the autonumber doesn't start at, o, 50?

Thanks!
Jillian

Re: Clear Database and Reset the AutoNumber
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 21.07.2006 22:06:02
Once you've deleted all the data, compact the database.

Having said that, though, why do you care? Autonumbers exist for one
purpose: to provide a (practically guaranteed) unique value that can be used
as a primary key. That purpose is met just as easily by 50, 51, 54 as by 1,
2, 3. Meaning should never be assigned to the value of autonumber fields. In
fact, usually you don't even show their values to the user.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


<jillian.calderon[ at ]gmail.com> wrote in message
news:1153496485.591022.230730[ at ]i3g2000cwc.googlegroups.com...
[Quoted Text]
> Good Morning Everyone,
>
> I'm making a database and I'm playing with it using test data. When
> I want to put the actual data in, how do I reset the autonumber back to
> 1? How do I tell the database to completely delete the fake records so
> the autonumber doesn't start at, o, 50?
>
> Thanks!
> Jillian
>


Re: Clear Database and Reset the AutoNumber
"René François" <rf44[ at ]hotmail.com> 31.07.2006 10:25:04
Douglas is right (as usual, of course!). However, if you really want to
reset the autonumber to 1 here's a way to do it:
1) Edit the table definition and change the autonumber field from Autonumber
to Numeric (Long Integer) and save the table.
2) Open the table (as I can undurstand it should be empty as you deleted all
the test data).
3) Compact the database and reopen it.
4) Edit the table definition again and revert the previously modified field
to Autonumber.

Once more, you should not assing any particular meaning to an autonumber
field. If you need a continuous numbering of records you should implement it
by yourself through a function.Try something like this:

Function GetNextNumber as Long

dim lngReturnValue as long
'
' Number is the name of the column containing the sequancial numbers
' MyTable is the name of the table you're working with
'
lngReturnValue = (DMax("Number", "Mytable") + 1)
GetNextNumber=lngReturnValue

End Function


<jillian.calderon[ at ]gmail.com> a écrit dans le message de news:
1153496485.591022.230730[ at ]i3g2000cwc.googlegroups.com...
[Quoted Text]
> Good Morning Everyone,
>
> I'm making a database and I'm playing with it using test data. When
> I want to put the actual data in, how do I reset the autonumber back to
> 1? How do I tell the database to completely delete the fake records so
> the autonumber doesn't start at, o, 50?
>
> Thanks!
> Jillian
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net