473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to reset the autonumber

I have a db that has a table that is never deleted but just has records
cleaned out

"delete * from table"

but each time it is populated, the autonumber is not reset to 0 and picks up
where it left off even though I delete the records.

Is there a way in code i can compact the database (I know this is the way to
reset that blank tables autonumber to 0). I know I can compacdt on exit but
the table will always be populated at this point and must stay that way for
the user puprposes.

Thanks in advance
Nov 13 '05 #1
4 8761
On Sat, 02 Oct 2004 13:12:02 GMT, "Danny" <da********@hotmail.com>
wrote:
I have a db that has a table that is never deleted but just has records
cleaned out

"delete * from table"

but each time it is populated, the autonumber is not reset to 0 and picks up
where it left off even though I delete the records.

Is there a way in code i can compact the database (I know this is the way to
reset that blank tables autonumber to 0). I know I can compacdt on exit but
the table will always be populated at this point and must stay that way for
the user puprposes.

Thanks in advance

Hi
If the table has no external relationships you can just delete it and
replace it with a new empty version, either by code or by copying a
template table. This can be a lot quicker than deleting a large number
of records if the table is indexed. However most tables should have
some relationships!
David

Nov 13 '05 #2
If you want to reset the autonumber without compacting, you will need to set
a reference to the ADOX library. You can then set the Seed property of the
Column in the Table.

There is a rather involved example of setting the Seed (for a different
purpose) in this link:
http://members.iinet.net.au/~allenbrowne/ser-40.html

Note that this approach works only in JET 4 (Access 2000 and later).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Danny" <da********@hotmail.com> wrote in message
news:CO**********************@news4.srv.hcvlny.cv. net...
I have a db that has a table that is never deleted but just has records
cleaned out

"delete * from table"

but each time it is populated, the autonumber is not reset to 0 and picks
up
where it left off even though I delete the records.

Is there a way in code i can compact the database (I know this is the way
to
reset that blank tables autonumber to 0). I know I can compacdt on exit
but
the table will always be populated at this point and must stay that way
for
the user puprposes.

Nov 13 '05 #3
Thanks for all of your responses. I will take a look at both suggestions.
"Danny" <da********@hotmail.com> wrote in message
news:CO**********************@news4.srv.hcvlny.cv. net...
I have a db that has a table that is never deleted but just has records
cleaned out

"delete * from table"

but each time it is populated, the autonumber is not reset to 0 and picks up where it left off even though I delete the records.

Is there a way in code i can compact the database (I know this is the way to reset that blank tables autonumber to 0). I know I can compacdt on exit but the table will always be populated at this point and must stay that way for the user puprposes.

Thanks in advance

Nov 13 '05 #4
On Sat, 02 Oct 2004 13:12:02 GMT, "Danny" <da********@hotmail.com>
wrote:
I have a db that has a table that is never deleted but just has records
cleaned out

"delete * from table"

but each time it is populated, the autonumber is not reset to 0 and picks up
where it left off even though I delete the records.

Is there a way in code i can compact the database (I know this is the way to
reset that blank tables autonumber to 0). I know I can compacdt on exit but
the table will always be populated at this point and must stay that way for
the user puprposes.

Thanks in advance

A few thoughts on this ...

First: Why do you care what the autonumbers are? It is considered best
not to rely on them for any user information - they are there only for
PKs and relationships.

Second: Is the database split? (it really should be) If so then you
could close all connected objects (forms, reports and queries) and
Name it to a different location and then Compact it back to the
original location. e.g.

Dim strPathSrce As String
Dim strPathDest As String

strPathSrce = 'where the backend data is now
strPathDest = 'a temporary location (or backup location)

'Move file to destination
Name strPathSrce As strPathDest
DoEvents
'Compact it back to the original source
DBEngine.CompactDatabase strPathDest, strPathSrce

Third: In Code create a temporary database to hold the temporary table
whenever you need it. No need to compact just destroy and recreate the
temporary database (and table) as needed. Leave the link alone.
- Jim

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: deko | last post by:
Is there a way to reset the AutoNumber sequence? I have several tables that use the AutoNumber field as the Primary Key, and I'd like to somehow do an Import/Export that will make remove the...
3
by: Cillies | last post by:
Hello, I was wondering if anyone knew how to reset an auto number. I.E. in my database I have two tables with autonumbers as primary keys. So I was wondering if anyone knew an easy way of...
2
by: N. Graves | last post by:
Hey is there a command like in SQL Transactional that will reset the Autonumber field to the highest number in the found in the field? I developing a access database with a several table that...
16
by: John Baker | last post by:
Hi: I know this is a strange question, but I have inherited a system where files are copied and records re auto numbered (as an index field) )frequently, and I am wondering how high the number...
2
by: Richard Hollenbeck | last post by:
I use a temporary table to assemble unrelated data for specific forms and reports. After each use of this table, I have a delete query which empties the table out for its next use. I have one...
3
by: trueblue7 | last post by:
I apologize if this question has been asked before... I'm trying to reset autonumber fields back to 1. The autonumber fields are part of the composite primary keys. I followed the MS help with...
2
by: junkaccount | last post by:
Hello, I currently have a field named QuoteNumber in a table named Quotes. The field is set as autonumber and is used to assign sequential numbers as users enter information in the table through...
2
by: jillian.calderon | last post by:
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...
2
mkremkow
by: mkremkow | last post by:
Access 2003 on XP Someone here at work deleted a record (&$%^&*&!!!) and screwed up the Autonumber "Job ID" field . I need to reset the Autonumber field back to it's original numbers and still...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.