A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Problem with AutoNumber



 
 
Thread Tools Display Modes
  #1  
Old September 30th, 2004, 04:51 PM
accessmonk
external usenet poster
 
Posts: n/a
Default Problem with AutoNumber

My problem is concerning the autonumber
feature...particularly in a table...My tables did have the
autonumber feature enabled, then had some corruption with
the whole database.

I was able to recover the tables and all records, however,
the autonumber feature had be changed to number. Since I
wasn't able to just change the number field back to
autonumber, I went in and filled all the non-sequential
records with blank records (ex.: 1,2,4,5 - I put in a 3
with a blank record to fill the void to finish the
sequence). Now, I want to put an autonumber field back in
to be able to autonumber my tables.

Here is the problem...when I add a new autonumber field,
it resorts all the blank records to the bottom of the
table. Even if I sort ascending. Any suggestions out
there?
  #2  
Old September 30th, 2004, 07:41 PM
Tim Ferguson
external usenet poster
 
Posts: n/a
Default

"accessmonk" wrote in
:


Here is the problem...when I add a new autonumber field,
it resorts all the blank records to the bottom of the
table. Even if I sort ascending. Any suggestions out
there?


You only get sorting when you sort the table... if you sort by a column
that has blanks, then those blanks all move to the bottom.

To get back to your original problem, the way to convert a LongInteger
field back to an Autonumber is this:

1. Back up everything twice...

2. make a new empty table with all the fields as you want them,
including substituting the old number field with an AN.

3. append the old table into the new one. Make sure that the old
number field gets put into the new AN column -- for example

INSERT INTO NewTable (ANCounter, FName, DtOfBirth)
SELECT OldIDField, FName, DtOfBirth
FROM OldTable

This creates an exact copy, with the same numbers in the AN column as
you started with. The new AN counter will carry on from the highest
value of the OldIDField plus one, as you would expect.

4. Delete all the relationships

5. Rename the old table, rename the new table to the old table name,
then recreate the relationships.

6. After fully testing everything, you can delete the old table. Or
resort to your backups!

Hope that helps



Tim F

  #3  
Old September 30th, 2004, 08:57 PM
accessmonk
external usenet poster
 
Posts: n/a
Default


-----Original Message-----
"accessmonk" wrote

in
:


Here is the problem...when I add a new autonumber

field,
it resorts all the blank records to the bottom of the
table. Even if I sort ascending. Any suggestions out
there?


You only get sorting when you sort the table... if you

sort by a column
that has blanks, then those blanks all move to the bottom.

To get back to your original problem, the way to convert

a LongInteger
field back to an Autonumber is this:

1. Back up everything twice...

2. make a new empty table with all the fields as you want

them,
including substituting the old number field with an AN.

3. append the old table into the new one. Make sure that

the old
number field gets put into the new AN column -- for

example

INSERT INTO NewTable (ANCounter, FName, DtOfBirth)
SELECT OldIDField, FName, DtOfBirth
FROM OldTable

This creates an exact copy, with the same numbers in

the AN column as
you started with. The new AN counter will carry on

from the highest
value of the OldIDField plus one, as you would expect.

4. Delete all the relationships

5. Rename the old table, rename the new table to the old

table name,
then recreate the relationships.

6. After fully testing everything, you can delete the old

table. Or
resort to your backups!

Hope that helps



Tim F

.


That is just what I needed. Worked like a charm. Thanks a
million, Tim.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Instances problem Jordan Using Forms 1 July 19th, 2004 03:21 PM
Big Problem. We need the fix Captain K Calendar 0 July 8th, 2004 04:50 PM
Passport Logout Problem Chen qiang New Users 0 May 4th, 2004 09:26 AM
Help Microsoft? WORD11.ADM File Problem Line 818? Dwight Hutchinson New Users 2 May 3rd, 2004 08:25 PM
Word 2000 footnote problem: footnotes consistently too high (again) Lori Formatting Long Documents 2 May 1st, 2004 07:15 PM


All times are GMT +1. The time now is 04:58 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.