473,695 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autonumber mess, figure out the number

I am in autonumber hell, it is important for me to get the AutoNumber
even in case of previous deleted records, and I cant get the value
through a 'test' insert and then delete method. There is no VBA
function that has that value in memory somewhere. That would be the
ideal.

For example:

AutoNumber-Field:
1
2
3
4
5 *-
6 *---- I need to delete these records
7 *-
8 *
9 *

*Delete*
so now I have

1
2
3
4
--> Next insert
10

From the example above, I really need to get that value '10' without
performing a 'test' insert, I was thinking of using a meta-table or
something, other than that I think I have tried everything, any ideas?
Nov 13 '05 #1
8 1882
bigbinc, You cannot reclaim those lost autonumbers nor should you want/need
to. This number should only serve to ensure the uniqueness of a record and
nothing else. You can design/create your own tracking number using other
functions/methods. More info here
http://www.mvps.org/access/general/gen0025.htm

--
Reggie

----------
"bigbinc" <bi*****@hotmai l.com> wrote in message
news:d1******** *************** ***@posting.goo gle.com...
I am in autonumber hell, it is important for me to get the AutoNumber
even in case of previous deleted records, and I cant get the value
through a 'test' insert and then delete method. There is no VBA
function that has that value in memory somewhere. That would be the
ideal.

For example:

AutoNumber-Field:
1
2
3
4
5 *-
6 *---- I need to delete these records
7 *-
8 *
9 *

*Delete*
so now I have

1
2
3
4
--> Next insert
10

From the example above, I really need to get that value '10' without
performing a 'test' insert, I was thinking of using a meta-table or
something, other than that I think I have tried everything, any ideas?

Nov 13 '05 #2
bi*****@hotmail .com (bigbinc) wrote in message news:<d1******* *************** ****@posting.go ogle.com>...
I am in autonumber hell, it is important for me to get the AutoNumber
even in case of previous deleted records, and I cant get the value
through a 'test' insert and then delete method. There is no VBA
function that has that value in memory somewhere. That would be the
ideal. From the example above, I really need to get that value '10' without
performing a 'test' insert, I was thinking of using a meta-table or
something, other than that I think I have tried everything, any ideas?


You misunderstand the purpose of an autonumber. An autonumber is only
guaranteeed to be unique. That's its sole purpose. If you need to
force the numbers to be sequential and fill in gaps where you've
deleted records, then you'll have to roll your own method.
Nov 13 '05 #3
Perhaps you're trying to use autonumber for something it is not
designed for. My recommendation would be to use autonumber as a unique
record key only, and if you need a consecutive number field for some
other purpose, then create one and populate it yourself on record
insert.

Hope this helps,

Peter De Baets
Peter's Software - MS Access Tools for Developers
http://www.peterssoftware.com

bi*****@hotmail .com (bigbinc) wrote in message news:<d1******* *************** ****@posting.go ogle.com>...
I am in autonumber hell, it is important for me to get the AutoNumber
even in case of previous deleted records, and I cant get the value
through a 'test' insert and then delete method. There is no VBA
function that has that value in memory somewhere. That would be the
ideal.

For example:

AutoNumber-Field:
1
2
3
4
5 *-
6 *---- I need to delete these records
7 *-
8 *
9 *

*Delete*
so now I have

1
2
3
4
--> Next insert
10

From the example above, I really need to get that value '10' without
performing a 'test' insert, I was thinking of using a meta-table or
something, other than that I think I have tried everything, any ideas?

Nov 13 '05 #4
"Reggie" <No**********@N oSpamsmittysine t.com> wrote in message news:<9v******* *************@c omcast.com>...
bigbinc, You cannot reclaim those lost autonumbers nor should you
From the example above, I really need to get that value '10' without
performing a 'test' insert, I was thinking of using a meta-table or
something, other than that I think I have tried everything, any ideas?


I just performed a null insert and then got the value of the
autonumber after the insert and then performed a delete. I didnt want
to do that, but whatever.
Nov 13 '05 #5
in**@peterssoft ware.com (Peter De Baets) wrote in message news:<f5******* *************** ****@posting.go ogle.com>...
Perhaps you're trying to use autonumber for something it is not
designed for. My recommendation would be to use autonumber as a unique
record key only, and if you need a consecutive number field for some
other purpose, then create one and populate it yourself on record
insert.

Hope this helps,

Peter De Baets
Peter's Software - MS Access Tools for Developers
http://www.peterssoftware.com

bi*****@hotmail .com (bigbinc) wrote in message news:<d1******* *************** ****@posting.go ogle.com>...
I am in autonumber hell, it is important for me to get the AutoNumber
even in case of previous deleted records, and I cant get the value
through a 'test' insert and then delete method. There is no VBA
function that has that value in memory somewhere. That would be the
ideal.

For example:

AutoNumber-Field:
1
2
3
4
5 *-
6 *---- I need to delete these records
7 *-
8 *
9 *

*Delete*
so now I have

1
2
3
4
--> Next insert
10

From the example above, I really need to get that value '10' without
performing a 'test' insert, I was thinking of using a meta-table or
something, other than that I think I have tried everything, any ideas?


Hmm, interesting, I didnt design the database, I just have to work
with it, ideally I need the autonumber-value to link with other tables
and that is why I need to find that value. I figure out the problem,
but wouldnt you agree if I can gather information through GUIDs on
external registry values or build DirectShow movies into an access
database, wouldnt it make sense to have some kind of COM function to
find just a simple value. Obviously the value is stored somewhere,
and I see this question asked all the time, so it is not an insane
idea.
Nov 13 '05 #6
In message <d1************ **************@ posting.google. com>, bigbinc
<bi*****@hotmai l.com> writes

Hmm, interesting, I didnt design the database, I just have to work
with it, ideally I need the autonumber-value to link with other tables
and that is why I need to find that value.


How about creating a query that links the tables and then updating that.
You wouldn't need to know what the value of the Autonumber filed is.

--
Bernard Peek
London, UK. DBA, Manager, Trainer & Author. Will work for money.

Nov 13 '05 #7
Bernard Peek <ba*@shrdlu.com > wrote in message news:<oC******* *******@shrdlu. com>...
In message <d1************ **************@ posting.google. com>, bigbinc
<bi*****@hotmai l.com> writes

Hmm, interesting, I didnt design the database, I just have to work
with it, ideally I need the autonumber-value to link with other tables
and that is why I need to find that value.


How about creating a query that links the tables and then updating that.
You wouldn't need to know what the value of the Autonumber filed is.

I have two tables, one is a link to the secondary-table, the
secondary-table contains the autonumber.

TABLE-PRIMARY:

[Auto-#] [We set the all the values in this table(i.e. 1
1 )]
1 -> records in table-secondary: 1-1
-> records in table-secondary: 1-2
-> records in table-secondary: 1-3
2 -> records in table-secondary: 2-1
-> records in table-secondary: 2-2
-> records in table-secondary: 2-3

3 ...
4 ...

5 ...

if we delete records 3 and 4 and 5, on the next insert,

*now insert*

6 -> records in table-secondary: 6-1
-> records in table-secondary: 6-2
-> records in table-secondary: 6-3

This is ideal, now assuming I cant change the structure of the table(I
can create meta-data tables), how would I get the value '6', (I
currently perform a null insert-delete and get the expected value, for
example '7'[skips 6])

I guess, the table should be setup with my own custom counter and that
should link back to the secondary-table, but the link(primary-table)
is on the autonumber.

if I perform 'select max auto-field' then I would get the value
'3'(wrong), so when I insert a record the link will be thrown off.

[Auto]
6 -> records in table-secondary: 3-1(wrong)
-> records in table-secondary: 3-2(wrong)
-> records in table-secondary: 3-3(wrong)
What do you think I could do that would be a better solution than what
I have.
Nov 13 '05 #8
In message <d1************ **************@ posting.google. com>, bigbinc
<bi*****@hotmai l.com> writes


What do you think I could do that would be a better solution than what
I have.


I'm still trying to work out why you need to know the value in the
autonumber field. If you create a query that is based on the primary and
secondary tables and linked via the autonumber field then you know that
the same value will be used in each table, without needing to know what
that value is.

Is there some other reason why you want to know the value?

--
Bernard Peek
London, UK. DBA, Manager, Trainer & Author. Will work for money.

Nov 13 '05 #9

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

Similar topics

33
4284
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...
4
4537
by: DHRRush | last post by:
I have a simple complaint tracking Db with one main table and one main form for entering data. I need for the users to be able to see the record number for future reference when they come back to the application to update or close that record. The record number is field RecordId and is an AutoNumber field. (Also the primary key) Is there a way to show the AutoNumber value in the form when a new record is opened?
0
1099
by: Zammy | last post by:
I have a split database with the backend on a server and sometimes when the data is saved from a form the autonumber populates the autonumber field and the account number field in the table. I have no idea what to start checking to figure out why this is happening. Any help would be appreciated.
11
4489
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...
3
5821
by: Ron | last post by:
Hi All, Okay, here's the deal: Access2000/WinXP. Have a database that's split, FE/BE with multiple users having FE and one of those users also has BE (still split though...). Have a form on FE for adding/editing transactions. Using TransactionID control as autonumber/primary key for tblTransactions. A while back, when I mentioned here that I was showing that control to my users as the transaction number, someone (can't remember who...
4
2348
imrosie
by: imrosie | last post by:
Hello All, (newbie)...I'm working on an Ordering app using the typical tables (customers, orders). I have a Search form to find existing customers prior to entering a new order. On the search form there's a combo control called 'custname' so that when a customer is located, the existing customer name is filled in and the account number goes into the Account control (from an autonumber field called CustomerID from Customer table). The rest of...
7
1654
imrosie
by: imrosie | last post by:
Hello all, My Customer table with Autonumbers used as the customer account number. There are two main forms (Order frm, Customer frm); the Customer's account number displays in a bound control on each. All relationships are tied to this account number, it's an Order entry system. The trouble comes in after adding a new customer. there's a combo control on Customer frm to search a name and if not found, the NotInList function is triggered....
5
4604
by: jnice814 | last post by:
I am trying to create an AutoNumber that will begin at a number that I specify. I have followed all instructions in MS Access Help, but it is still not working. I continue getting an error message that 1 record has a validation rule problem, but I cannot figure out what it is. I don't have anything in the validation rule fields on either table. I've checked everything in both tables. What can I be missing? This is very frustrating... I...
1
1449
by: lawitt | last post by:
I have a MakeTable query whose resulting table i'm using in a crosstab query. The fields in the crosstab are constantly changing (weekly), so my ultimate goal has been to somehow create a dynamic report that takes into consideration the ever changing fields. that's been VERY tricky. I've managed to get the MakeTable query to only display my 'top 10' fields and i've created a 'static' report that references a calculated field (Number) in that...
0
8650
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9140
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...
1
8864
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7685
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...
1
6510
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5843
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();...
1
3025
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
2
2290
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1987
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.