473,503 Members | 11,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Am I Screwed with Autonumber?????

I have a situation where I need to put back in a deleted record to a
table whose primary key is an Autonumber. And of course the autonumber
has to match what it was before. Any way of saving my butt on this one?

Nov 13 '05 #1
8 1695
Good news - you're not screwed.

1. Create a new query, and close the initial dialog without adding any tables.
2. Make your query an append query, and choose the table you need to add the
row to.
3. Select each field name of the target table in the "Append To:" cell of a
different column in the grid.
4. In the field line, type the values that go to the fields in the "Append
To:" cells below.
5. Run the query.

That's it - you're done.

One caveat. I've seen this cause Autonumber correction sometimes (not
always), so it's good to compact the database after you do this.

On 18 Feb 2005 11:31:15 -0800, "mathilda" <sm***********@yahoo.com> wrote:
I have a situation where I need to put back in a deleted record to a
table whose primary key is an Autonumber. And of course the autonumber
has to match what it was before. Any way of saving my butt on this one?


Nov 13 '05 #2

"mathilda" <sm***********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I have a situation where I need to put back in a deleted record to a
table whose primary key is an Autonumber. And of course the autonumber
has to match what it was before. Any way of saving my butt on this one?


No, I don't believe you are screwed. As long as your old "autonumber" has
not been reassigned you should be able to reisert a line with the same
number.

But Autonumber is used in a lot of circumstances where it should not be
used:

When you need an indexed table then you usually have some field that can be
used as identifier and you should index on that field. If there is no such
field
then the reason is usually that the table should not be indexed because of
its
nature.

The only real reason I know for using autonumber is like when you have a
table
of invoices and need a method of assigning a new invoice number for each
line
added to the table.

regards Sven
Nov 13 '05 #3
> I have a situation where I need to put back in a deleted record to a
table whose primary key is an Autonumber. And of course the autonumber
has to match what it was before. Any way of saving my butt on this one?


If you have 5 records autonumbered 1 thru 5, and you've deleted #5, you
could compact and close and re-enter the record. The new record should be
assigned autonumber 5.

But more likely you have thousands of records which are not autonumbered
sequentially and the one deleted was somewhere in the middle. If that's the
case, I'd be surprised if you find a way to get the record back in with the
same autonumber. Obviously, you'd be better off using something else as
unique identifier. Autonumber is a great choice for a primary key because
it's a single field, static identifier. But it's a poor choice if it makes
any difference what that number is.

If you want a unique, sequential identifier, there are ways to do it, e.g.
DMax("AcctNum", "tblAccts") + 1. But I'd still use Autonumber as a primary
key.
Nov 13 '05 #4

"deko" <de**@hotmail.com> schreef in bericht news:YP****************@newssvr14.news.prodigy.com ...
I'd be surprised if you find a way to get the record back in with the
same autonumber.


Surprize:
Make a duplicate table with the same fields as your original table (use copy and paste on your
original table)
In this table change your autonumber-field in long integer!
Add one record in this table with your desired autonumber.
Now use an appendquery and you're done.

--
Hope this helps
Arno R


Nov 13 '05 #5
> Make a duplicate table with the same fields as your original table (use
copy and paste on your
original table)
In this table change your autonumber-field in long integer!
Add one record in this table with your desired autonumber.
Now use an appendquery and you're done.


have you tried changing the field back to Autonumber after doing this?
Nov 13 '05 #6
Sorry, maybe I explained to fast.
You use the append query to append the long integer-record from the dupe-table to the
*original* table.

Arno R

"deko" <de**@hotmail.com> schreef in bericht
news:9h****************@newssvr13.news.prodigy.com ...
Make a duplicate table with the same fields as your original table (use

copy and paste on your
original table)
In this table change your autonumber-field in long integer!
Add one record in this table with your desired autonumber.
Now use an appendquery and you're done.


have you tried changing the field back to Autonumber after doing this?

Nov 13 '05 #7
> You use the append query to append the long integer-record from the
dupe-table to the
*original* table.


it worked. I *am* surprised :)
Nov 13 '05 #8
This worked perfectly!

Saved my keister on this one, thanks.

Nov 13 '05 #9

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

Similar topics

3
4759
by: Ilan Sebba | last post by:
I have a 'supertype' table with only one field: autonumber. Call this table the 'parent' table. There are two subtypes, 'androids' and 'martians'. Martian have only one thing in common: they give...
33
4239
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
35
7238
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key...
4
5147
by: yf | last post by:
A KB article "http://support.microsoft.com/default.aspx?scid=kb;en-us;209599" tells that the maximum number of records that a table may hold if the PRIMARY key data type is set to AUTONUMBER is...
26
3765
by: jimfortune | last post by:
Sometimes I use Autonumber fields for ID fields. Furthermore, sometimes I use those same fields in orderdetail type tables. So it's important in that case that once an autonumber key value is...
8
15948
by: petebeatty | last post by:
I have created a SQL string the properly inserts a record in the table. However, the insert does not occur at the end of the table. Instead it inserts a record after the last record that I viewed....
11
4468
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
1
3934
by: gtwannabe | last post by:
I'm having a problem with a form that uses AutoNumber as the primary key. I have an Abort button to delete the current record and close the form. If AutoNumber is assigned, the code executes a...
6
11745
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the...
0
7193
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
7067
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
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5562
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4992
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...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.