473,652 Members | 3,123 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 1703
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.goo glegroups.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.c om> schreef in bericht news:YP******** ********@newssv r14.news.prodig y.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.c om> schreef in bericht
news:9h******** ********@newssv r13.news.prodig y.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
4765
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 birth to identical mules. So each android and a martian have primary key which is a foreign key to the parent table. Now, I want to insert a new record in 'android' or 'martian'. This can be done easily using MS-Access forms. But I want to do...
33
4280
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 setting default value to a UDF that manages the auto-numbering. Access won't take a UDF as a default value. Okay, I'll use SQL WITHOUT any aggregate functions, for the default value. Access won't do that either. Okay, I create a second...
35
7258
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 start at 51 after the last 50 records are deleted? Thanks! Traci
4
5162
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 4,294,967,295. Suppose the PRIMARY key data type is set to "RANDOM" AutoNumber. Suppose an application (a) successfully INSERTS "X" records, then (b) successfully DELETES "Y" records (X >= Y), then
26
3803
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 assigned to a record that it doesn't change. Occasionally I find that due to corruption or an accidental deletion and restore of a record from a backup the autonumber field needs to be tidied up. So when I create (through AddNew) the autonumber...
8
15958
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. This would be OK, except it assigns a autonumber to be one greater than the last viewed record. This causes a duplicate autonumber. I know I can change the autonumber index (Primary Key) to not allow duplicates. How can I force the insert...
11
4484
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 AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their primary key to an "AutoNumber" type. If I'm right about this, I need some suggestions as to the...
1
3949
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 SQL statement that deletes the current record. I need to be able to detect when AutoNumber is unassigned (a new blank record) so that I can simply close the form without running the SQL delete statement. Unfortunately, no tests I can think of...
6
11756
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 contents of the form is inserted into the MS Access database. The Customer table in the database already has 30 records (with CustomerIDs 1 - 30) in it (from when the database was first created). The CustomerID field in the database is an...
0
8279
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8589
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5619
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2703
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 we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.