473,387 Members | 1,283 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 3181
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","Table")
set rs = db.openRecordset("SELECT ID FROM Table WHERE ID = " & i & ";")
if rs.recordcount = 0 then
db.execute("INSERT INTO MissingIDs (ID) VALUE (" & i & ");")
endif
rs.close
next i


"Lapchien" <cc****@nospamplease.eclipse.co.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****@nospamplease.eclipse.co.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****@NOSPAMeclipse.co.uk

"DFS" <no******@nospam.com> wrote in message
news:vt************@corp.supernews.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","Table")
set rs = db.openRecordset("SELECT ID FROM Table WHERE ID = " & i & ";")
if rs.recordcount = 0 then
db.execute("INSERT INTO MissingIDs (ID) VALUE (" & i & ");")
endif
rs.close
next i


"Lapchien" <cc****@nospamplease.eclipse.co.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****@nospamplease.eclipse.co.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****@nospamplease.eclipse.co.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
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
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...
2
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. ...
1
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...
19
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. ...
9
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...
1
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...
2
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...
24
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...
0
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...

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.