Microsoft Access key field

Most of us are not "computer people" so post your technical questions and comments here. If you have computer or Internet expertise, share it here.

Moderators: carlson1, Keith B

Post Reply
User avatar

Topic author
Charles L. Cotton
Site Admin
Posts in topic: 3
Posts: 17787
Joined: Wed Dec 22, 2004 9:31 pm
Location: Friendswood, TX
Contact:

Microsoft Access key field

#1

Post by Charles L. Cotton »

Is there a way to reset an Access auto-generated primary key field to "0?" While setting up a database and doing testing, the primary key field has advanced and I need it reset, if at all possible.

Thanks,
Chas.

dalto
Member
Posts in topic: 3
Posts: 109
Joined: Tue Oct 19, 2010 4:57 pm
Location: Austin

Re: Microsoft Access key field

#2

Post by dalto »

Here is the procedure for resetting and autonumber field in access: http://support.microsoft.com/kb/812718" onclick="window.open(this.href);return false;
User avatar

suthdj
Senior Member
Posts in topic: 3
Posts: 2296
Joined: Mon Apr 20, 2009 8:49 pm
Location: North Ft Worth(Alliance area)

Re: Microsoft Access key field

#3

Post by suthdj »

I thought you could just do a TRUNCATE TABLE "tablename" in a SQL window.
21-Apr-09 filed online
05-Sep-09 Plastic Arrived
09-Sep-13 Plastic Arrived
21-june-18 Plasic Arrived

dalto
Member
Posts in topic: 3
Posts: 109
Joined: Tue Oct 19, 2010 4:57 pm
Location: Austin

Re: Microsoft Access key field

#4

Post by dalto »

suthdj wrote:I thought you could just do a TRUNCATE TABLE "tablename" in a SQL window.
That will delete all the data in the table.
User avatar

OldSchool
Senior Member
Posts in topic: 2
Posts: 728
Joined: Sat Nov 21, 2009 9:01 pm
Location: Brazoria County

Re: Microsoft Access key field

#5

Post by OldSchool »

dalto wrote:
suthdj wrote:I thought you could just do a TRUNCATE TABLE "tablename" in a SQL window.
That will delete all the data in the table.
Yes, one has to be careful with SQL calls to MS Access, since it uses non-standard SQL (MS has done this kind of thing regularly) -- one of the reasons I dumped it years ago. Access is actually only a front-end to a non-standard back-end file.
Life is for learning.
IANAL, thank gosh!
NRA Life Member - TSRA - PSC
NRA Certified Basic Rifle Instructor, Chief Range Safety Officer

12/23/2009: Packets delivered.
01/15/2010: Plastic in hand!
User avatar

pbwalker
Senior Member
Posts in topic: 2
Posts: 3032
Joined: Thu May 01, 2008 10:12 am
Location: Northern Colorado

Re: Microsoft Access key field

#6

Post by pbwalker »

OldSchool wrote:
dalto wrote:
suthdj wrote:I thought you could just do a TRUNCATE TABLE "tablename" in a SQL window.
That will delete all the data in the table.
Yes, one has to be careful with SQL calls to MS Access, since it uses non-standard SQL (MS has done this kind of thing regularly) -- one of the reasons I dumped it years ago. Access is actually only a front-end to a non-standard back-end file.
:iagree:

Be very careful with TSQL statement in Access. It uses the JET DB engine and even with literals and like strings, the syntax is different.

Charles - Some of the previous links cover it, but just wanted to throw my vote in for SQL Express. It's free and very easy to use. Might want to give that a look. :tiphat:
*NRA Endowment Member* | Veteran
Vote Adam Kraut for the NRA Board of Directors - http://www.adamkraut.com/
User avatar

OldSchool
Senior Member
Posts in topic: 2
Posts: 728
Joined: Sat Nov 21, 2009 9:01 pm
Location: Brazoria County

Re: Microsoft Access key field

#7

Post by OldSchool »

pbwalker wrote:
OldSchool wrote:
dalto wrote:
suthdj wrote:I thought you could just do a TRUNCATE TABLE "tablename" in a SQL window.
That will delete all the data in the table.
Yes, one has to be careful with SQL calls to MS Access, since it uses non-standard SQL (MS has done this kind of thing regularly) -- one of the reasons I dumped it years ago. Access is actually only a front-end to a non-standard back-end file.
:iagree:

Be very careful with TSQL statement in Access. It uses the JET DB engine and even with literals and like strings, the syntax is different.

Charles - Some of the previous links cover it, but just wanted to throw my vote in for SQL Express. It's free and very easy to use. Might want to give that a look. :tiphat:
True, it's never too soon to plan on converting to another database, even if you think it's years away. Anything can happen to the database engine you're using now, and Access has many built-in limitations that eventually show up.

Just recently made a project of converting a large MS Access database (that I inherited) because Access was dying due to the file size (6MB, even though it's advertised to handle hundreds of times larger than that), and our IT group had decided to "upgrade" to the new Office version (which is always a disaster, and never entirely backwards compatible).

Decided on SQLite, since that also uses a single-file database (very portable), is free (no seat licenses), and very reliable (this was an important database for my work).
ETA: Oh, yeah, almost forgot: It uses standard SQL with some extensions.
Ended up, after doing significant research, that the easiest way to do it was to convert the Access file to MS Excel, then to CSV, then imported into SQLite using one of the many tools out there. While the way I did it took a long time to complete, I am thoroughly pleased with the results (which I use every day)!
Life is for learning.
IANAL, thank gosh!
NRA Life Member - TSRA - PSC
NRA Certified Basic Rifle Instructor, Chief Range Safety Officer

12/23/2009: Packets delivered.
01/15/2010: Plastic in hand!
User avatar

Topic author
Charles L. Cotton
Site Admin
Posts in topic: 3
Posts: 17787
Joined: Wed Dec 22, 2004 9:31 pm
Location: Friendswood, TX
Contact:

Re: Microsoft Access key field

#8

Post by Charles L. Cotton »

Thanks for the input guys. My web host includes MySQL; is that an option as well?

Chas.

dalto
Member
Posts in topic: 3
Posts: 109
Joined: Tue Oct 19, 2010 4:57 pm
Location: Austin

Re: Microsoft Access key field

#9

Post by dalto »

Charles L. Cotton wrote:Thanks for the input guys. My web host includes MySQL; is that an option as well?

Chas.
Absolutely, but one thing to consider is how you are using access. Most of the things mentioned including mysql are database backends. If you are using Access to develop forms or software you would need to find another way to do that.

It really depends what you are trying to accomplish and what skills and time you have to bring to the table.
User avatar

pbwalker
Senior Member
Posts in topic: 2
Posts: 3032
Joined: Thu May 01, 2008 10:12 am
Location: Northern Colorado

Re: Microsoft Access key field

#10

Post by pbwalker »

Charles L. Cotton wrote:Thanks for the input guys. My web host includes MySQL; is that an option as well?

Chas.
100%. It's my favorite platform, hands down! (I only recommended SQL Express because it's MS and I figured there would be some migration tool)

MySQL provides great documentation, how-to's, and wikis. It was an easy transition for me (from SQL 2000).

http://dev.mysql.com/tech-resources/art ... osoft.html

Dalto is right though...MySQL can do a lot of stuff, but it is really a command line DB. It all depends on what you need. There are front end GUI's, but I haven't used any to make a recommendation. If you are using a lot of the GUI builders in MS Access, you may find MySQL to be too much of a hassle. Then again, there may be some nice open source tools that can do this...
*NRA Endowment Member* | Veteran
Vote Adam Kraut for the NRA Board of Directors - http://www.adamkraut.com/
User avatar

suthdj
Senior Member
Posts in topic: 3
Posts: 2296
Joined: Mon Apr 20, 2009 8:49 pm
Location: North Ft Worth(Alliance area)

Re: Microsoft Access key field

#11

Post by suthdj »

dalto wrote:
suthdj wrote:I thought you could just do a TRUNCATE TABLE "tablename" in a SQL window.
That will delete all the data in the table.
Yes but since it is test data it should not matter. If it is not test data then resetting could lead to other issues.
21-Apr-09 filed online
05-Sep-09 Plastic Arrived
09-Sep-13 Plastic Arrived
21-june-18 Plasic Arrived
User avatar

Topic author
Charles L. Cotton
Site Admin
Posts in topic: 3
Posts: 17787
Joined: Wed Dec 22, 2004 9:31 pm
Location: Friendswood, TX
Contact:

Re: Microsoft Access key field

#12

Post by Charles L. Cotton »

suthdj wrote:
dalto wrote:
suthdj wrote:I thought you could just do a TRUNCATE TABLE "tablename" in a SQL window.
That will delete all the data in the table.
Yes but since it is test data it should not matter. If it is not test data then resetting could lead to other issues.
One of the tables contains only test data, but others have live data and a lot of queries and forums have been created. If I can delete all the test data in one table and reset the auto number at the same time, then that's fine.

Thanks,
Chas.
User avatar

suthdj
Senior Member
Posts in topic: 3
Posts: 2296
Joined: Mon Apr 20, 2009 8:49 pm
Location: North Ft Worth(Alliance area)

Re: Microsoft Access key field

#13

Post by suthdj »

Charles L. Cotton wrote:
suthdj wrote:
dalto wrote:
suthdj wrote:I thought you could just do a TRUNCATE TABLE "tablename" in a SQL window.
That will delete all the data in the table.
Yes but since it is test data it should not matter. If it is not test data then resetting could lead to other issues.
One of the tables contains only test data, but others have live data and a lot of queries and forums have been created. If I can delete all the test data in one table and reset the auto number at the same time, then that's fine.

Thanks,
Chas.
Like dalto said it will wipe out the data in that table and reset the auto number, however if any other tables is referencing the data in that table then you might get some broken records. It all depends on how it is all connected.
21-Apr-09 filed online
05-Sep-09 Plastic Arrived
09-Sep-13 Plastic Arrived
21-june-18 Plasic Arrived
Post Reply

Return to “Technical Tips, Questions & Discussions (Computers & Internet)”