473,756 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sequential number help

I have list of numbers in a table (originally from autonumber in a different
database) from 1 to 1,000,000. The list is not in sequential order - there
are loads of numbers missing. How can I identify what numbers are missing?

Thanks,
Lap
(I'd like to then use this 'missing number list' to use for new records,
instead of autonumber - I think I need to use DMax - can someone summarise
it's use..?)
Nov 12 '05 #1
5 3207
DFS
Lapchien,

If you're using this number for a primary key of some kind, you should
probably save yourself the trouble of "filling in the gaps" and just start
with the next available number. In your scenario, you'll have to identify
the missing numbers, store them somewhere, then use them one at a time and
mark each one as used (or delete it) until they're all gone. Almost
certainly not worth the trouble.

If you're concerned about having sequential ID numbers and your database
isn't very complicated, you could copy your data into a new table with a
fresh AutoNumber field.

But, if you are determined to find the missing numbers, try this:

dim i as long, rs as recordset, db as database
set db = Currentdb()
for i = 1 to dmax("ID","Tabl e")
set rs = db.openRecordse t("SELECT ID FROM Table WHERE ID = " & i & ";")
if rs.recordcount = 0 then
db.execute("INS ERT INTO MissingIDs (ID) VALUE (" & i & ");")
endif
rs.close
next i


"Lapchien" <cc****@nospamp lease.eclipse.c o.uk> wrote in message
news:10******** *******@ananke. eclipse.net.uk. ..
I have list of numbers in a table (originally from autonumber in a different database) from 1 to 1,000,000. The list is not in sequential order - there are loads of numbers missing. How can I identify what numbers are missing?
Thanks,
Lap
(I'd like to then use this 'missing number list' to use for new records,
instead of autonumber - I think I need to use DMax - can someone summarise
it's use..?)

Nov 12 '05 #2
(I guess Dmax wont work as it increments the number by 1 each time, and does
not reference a number table...)

"Lapchien" <cc****@nospamp lease.eclipse.c o.uk> wrote in message
news:10******** *******@ananke. eclipse.net.uk. ..
I have list of numbers in a table (originally from autonumber in a different database) from 1 to 1,000,000. The list is not in sequential order - there are loads of numbers missing. How can I identify what numbers are missing?
Thanks,
Lap
(I'd like to then use this 'missing number list' to use for new records,
instead of autonumber - I think I need to use DMax - can someone summarise
it's use..?)


Nov 12 '05 #3
Thanks DFS
--
Thanks,
Chris
cc****@NOSPAMec lipse.co.uk

"DFS" <no******@nospa m.com> wrote in message
news:vt******** ****@corp.super news.com...
Lapchien,

If you're using this number for a primary key of some kind, you should
probably save yourself the trouble of "filling in the gaps" and just start
with the next available number. In your scenario, you'll have to identify
the missing numbers, store them somewhere, then use them one at a time and
mark each one as used (or delete it) until they're all gone. Almost
certainly not worth the trouble.

If you're concerned about having sequential ID numbers and your database
isn't very complicated, you could copy your data into a new table with a
fresh AutoNumber field.

But, if you are determined to find the missing numbers, try this:

dim i as long, rs as recordset, db as database
set db = Currentdb()
for i = 1 to dmax("ID","Tabl e")
set rs = db.openRecordse t("SELECT ID FROM Table WHERE ID = " & i & ";")
if rs.recordcount = 0 then
db.execute("INS ERT INTO MissingIDs (ID) VALUE (" & i & ");")
endif
rs.close
next i


"Lapchien" <cc****@nospamp lease.eclipse.c o.uk> wrote in message
news:10******** *******@ananke. eclipse.net.uk. ..
I have list of numbers in a table (originally from autonumber in a

different
database) from 1 to 1,000,000. The list is not in sequential order -

there
are loads of numbers missing. How can I identify what numbers are

missing?

Thanks,
Lap
(I'd like to then use this 'missing number list' to use for new records,
instead of autonumber - I think I need to use DMax - can someone summarise it's use..?)


Nov 12 '05 #4
"Lapchien" <cc****@nospamp lease.eclipse.c o.uk> wrote in message news:<10******* ********@ananke .eclipse.net.uk >...
I have list of numbers in a table (originally from autonumber in a different
database) from 1 to 1,000,000. The list is not in sequential order - there
are loads of numbers missing. How can I identify what numbers are missing?

Thanks,
Lap
(I'd like to then use this 'missing number list' to use for new records,
instead of autonumber - I think I need to use DMax - can someone summarise
it's use..?)


Autonumbers are supposed to be meaningless - what's important is that
they're unique. is there a reason that you care what the numbers are?
If you *really* wanted, you could create a long integer field in your
table and then update that with incremental values... but why?
Nov 12 '05 #5
hi
create another table which has 1 field . eg chknumber and fill it with a
list of numbers from 1 to 1,000,000
use excel to create a list and then queries to load these in . . or what
ever method you find convenient.

when the list is complete, create a query that joins your new complete list
to the incomplete one.
set the link properties to show all new list records,

in the fields list add the new number 'chknumber' and the original number.
add a criteria under the original number of "not null"

this will show all the missing numbers. save this query and then use the
dmin function to find the lowest number you can use to create a new record
in your original table . . . hope this makes sense . .
cheers
paul g

"Lapchien" <no**@m.com> wrote in message
news:10******** *******@ananke. eclipse.net.uk. ..
(I guess Dmax wont work as it increments the number by 1 each time, and does not reference a number table...)

"Lapchien" <cc****@nospamp lease.eclipse.c o.uk> wrote in message
news:10******** *******@ananke. eclipse.net.uk. ..
I have list of numbers in a table (originally from autonumber in a

different
database) from 1 to 1,000,000. The list is not in sequential order -

there
are loads of numbers missing. How can I identify what numbers are

missing?

Thanks,
Lap
(I'd like to then use this 'missing number list' to use for new records,
instead of autonumber - I think I need to use DMax - can someone summarise it's use..?)


Nov 12 '05 #6

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

Similar topics

4
2970
by: cliff williams | last post by:
how can I set a form so that when i open it , it appears with the next sequential number. I want to set the number pattern and not use autonumber
7
5233
by: GAVO. | last post by:
Hello every one I have a database with a form called "frmOrders" on that for I need to create a sequential number for each city apart from the original autonumber. So the table "tblorders" would look something like this: OrderID (Autonumber) SeqNo City 1 1 London 2 1 Madrid 3 ...
2
1765
by: Mike Kingscott | last post by:
Hi all, I'd building an app that posts to a web service. One of the things that is required in the soap header is a sequential number appended to a ref, i.e. "IGI1001", "IGI1002", etc. Obviously the first part of the reference ("IGI") stays the same, but I need an incrementing number generated. Now, I was thinking of doing this via a SQL database, but it would be an awful waste as there would only be one table and one stored procedure...
1
4024
by: videostar | last post by:
Greetings, first post, but have read many times for various CF questions. My goal is, using CF and MS-SQL 2k, the following: and - I need to have either CF or MS-SQL upon a record insert, generate a sequential 3 digit number, that is incremented by 1. However, this number needs to check the date, as if it is the first of the month, it should reset the counter back to one.
19
4167
by: eric.nave | last post by:
this is a slight change to a fequently asked question around here. I have a table which contains a "sortorder" column where a user can specify some arbitrary order for records to be displayed in. Users have sometimes ordered records the way we used to number lines in a BASIC program (10,20,30, etc.). I'd like to do an update query and fix this so that every record is in sequential order. I found an example in this newsgroup of how to...
9
5180
by: Nooby | last post by:
New to Access here. I inherited a db that has the first column as an automatically generated sequential number. I want to bump it up, but for the life of me I can't figure out how to do it. Is this type of generation a built in function of Access? I'm sure it can be written manually, but I doubt someone took the trouble to do it... Can someone point me in the right direction to figure out how to change this number? Thank you one and all!...
1
2455
maxamis4
by: maxamis4 | last post by:
Hello folks, I have two forms a parent form and a subform. The parent form is an unbound form while the subform is a form that contains all a list of what I like to call 'in stock ' phone numbers. with in that subform the user has the ability to select between to radio buttons to do a bulk selection. The first option lets the user select the first X amount of numbers that he or she wants. The second option selects X amount of numbers but...
2
11115
by: masker | last post by:
I was on the web trying to find a javascript that would allow me to input a number on my website and have it increase by a given percentage every second. During my search I found the Earth Population Calculator on the javascripkit.com site. The Calculator functions just as I imagine I want my number generator to function, but I need it to present a different number. I work for a non profit organization that administers Head Start and...
24
9370
by: cwfent | last post by:
I was wondering if anyone could help me out with this problem. I have a script that has a bunch of code in it. For some reason the coder decided to use a hex for a id number (it's just a member number, nothing secret) anyway the code section that I want to change is this : function createUniqueID($table, $column) { $maxTries = 10; while(1) { if($maxTries <= 0) return false;
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
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
9722
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...
1
7259
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
6542
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
5155
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...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
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
3
2677
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.