473,327 Members | 2,090 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,327 software developers and data experts.

Finding out of sequence numbers

I have a database with records that should have a consecutive number
ID (Check Register). Also has other records (deposits and adjusting
entries) that don't fit in the number range so autonumbering isn't the
answer. I want to check to see if any check numbers are missing from
the register, but can't figure out how to accomplish it. Thanks for
any help.
Nov 12 '05 #1
6 4574
1. Build a table of numbers that starts with the first check# in the checking
account and goes to what you anticipate will be the highest check number ever
used in the account. You can easily generate the numbers in Excel and then
import into an Access table.

2. Build a query named QryAllPossibleCheckNum based on the numbers table and in
the numbers field enter the criteria:
Between XXXStartCheckNum And XXX EndCheckNum

3. Build a query named QryCheckNumOfPostedCheck and in the CheckNum field enter
the criteria:
Between XXXStartCheckNum And XXX EndCheckNum

Note: You will have to determine how to write the actual criteria based on
where you get the first and last check#s.

4. At the database window, at the query tab, click on New. One of the options
will be Find Unmatched Query. Use this wizard to find the numbers in
QryAllPossibleCheckNum that are not in (unmatched) QryCheckNumOfPostedCheck.
This new query will return all missing check numbers.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"GSpiggle" <ga***@yahoo.com> wrote in message
news:de**************************@posting.google.c om...
I have a database with records that should have a consecutive number
ID (Check Register). Also has other records (deposits and adjusting
entries) that don't fit in the number range so autonumbering isn't the
answer. I want to check to see if any check numbers are missing from
the register, but can't figure out how to accomplish it. Thanks for
any help.

Nov 12 '05 #2
Thanks PCDatasheet. Have done something similar in the past, but
thought there might be a function or code that I had missed.
Appreciate the response.
"PC Datasheet" <sp**@nospam.spam> wrote in message news:<BP*****************@newsread3.news.atl.earth link.net>...
1. Build a table of numbers that starts with the first check# in the checking
account and goes to what you anticipate will be the highest check number ever
used in the account. You can easily generate the numbers in Excel and then
import into an Access table.

2. Build a query named QryAllPossibleCheckNum based on the numbers table and in
the numbers field enter the criteria:
Between XXXStartCheckNum And XXX EndCheckNum

3. Build a query named QryCheckNumOfPostedCheck and in the CheckNum field enter
the criteria:
Between XXXStartCheckNum And XXX EndCheckNum

Note: You will have to determine how to write the actual criteria based on
where you get the first and last check#s.

4. At the database window, at the query tab, click on New. One of the options
will be Find Unmatched Query. Use this wizard to find the numbers in
QryAllPossibleCheckNum that are not in (unmatched) QryCheckNumOfPostedCheck.
This new query will return all missing check numbers.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"GSpiggle" <ga***@yahoo.com> wrote in message
news:de**************************@posting.google.c om...
I have a database with records that should have a consecutive number
ID (Check Register). Also has other records (deposits and adjusting
entries) that don't fit in the number range so autonumbering isn't the
answer. I want to check to see if any check numbers are missing from
the register, but can't figure out how to accomplish it. Thanks for
any help.

Nov 12 '05 #3
Thanks for the courtesy of a thank you!!

Steve
"GSpiggle" <ga***@yahoo.com> wrote in message
news:de**************************@posting.google.c om...
Thanks PCDatasheet. Have done something similar in the past, but
thought there might be a function or code that I had missed.
Appreciate the response.
"PC Datasheet" <sp**@nospam.spam> wrote in message

news:<BP*****************@newsread3.news.atl.earth link.net>...
1. Build a table of numbers that starts with the first check# in the checking account and goes to what you anticipate will be the highest check number ever used in the account. You can easily generate the numbers in Excel and then
import into an Access table.

2. Build a query named QryAllPossibleCheckNum based on the numbers table and in the numbers field enter the criteria:
Between XXXStartCheckNum And XXX EndCheckNum

3. Build a query named QryCheckNumOfPostedCheck and in the CheckNum field enter the criteria:
Between XXXStartCheckNum And XXX EndCheckNum

Note: You will have to determine how to write the actual criteria based on
where you get the first and last check#s.

4. At the database window, at the query tab, click on New. One of the options will be Find Unmatched Query. Use this wizard to find the numbers in
QryAllPossibleCheckNum that are not in (unmatched) QryCheckNumOfPostedCheck.
This new query will return all missing check numbers.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"GSpiggle" <ga***@yahoo.com> wrote in message
news:de**************************@posting.google.c om...
I have a database with records that should have a consecutive number
ID (Check Register). Also has other records (deposits and adjusting
entries) that don't fit in the number range so autonumbering isn't the
answer. I want to check to see if any check numbers are missing from
the register, but can't figure out how to accomplish it. Thanks for
any help.

Nov 12 '05 #4
CDB
It's a bit late for the original poster perhaps, but the following can also
be used:

Table: Ones
Field: Ordinal
Values: 0 - 9 (10 rows)

Table: CheckRegister
Field: CheckID
Values: 1117658 to 1117698 with a few deletions.

Query:
SELECT N.L AS Missing
FROM CheckRegister RIGHT JOIN [SELECT
111*10^4+[O3].[Ordinal]*10^3+[O2].[Ordinal]*10^2+[O1].[Ordinal]*10+[O0].[Ord
inal] AS L
FROM Ones AS O0, Ones AS O1, Ones AS O2, Ones AS O3
WHERE
(((111*10^4+[O3].[Ordinal]*10^3+[O2].[Ordinal]*10^2+[O1].[Ordinal]*10+[O0].[
Ordinal]) Between 1117658 And 1117698))]. AS N ON CheckRegister.CheckID =
N.L
WHERE (((CheckRegister.CheckID) Is Null));

The "Ones" have only a Cartesian join. This creates for seven places a
rather large initial resultset, requiring many seconds. So the generated
number has been shortened to 4 digits, with the common "111" set as a
constant value. The above takes less than a second to run (1.2GHz).

Clive

"PC Datasheet" <sp**@nospam.spam> wrote in message
news:oJ*****************@newsread2.news.atl.earthl ink.net...
Thanks for the courtesy of a thank you!!

Steve
"GSpiggle" <ga***@yahoo.com> wrote in message
news:de**************************@posting.google.c om...
Thanks PCDatasheet. Have done something similar in the past, but
thought there might be a function or code that I had missed.
Appreciate the response.
"PC Datasheet" <sp**@nospam.spam> wrote in message news:<BP*****************@newsread3.news.atl.earth link.net>...
1. Build a table of numbers that starts with the first check# in the checking account and goes to what you anticipate will be the highest check number ever
used in the account. You can easily generate the numbers in Excel and
then import into an Access table.

2. Build a query named QryAllPossibleCheckNum based on the numbers table
and in the numbers field enter the criteria:
Between XXXStartCheckNum And XXX EndCheckNum

3. Build a query named QryCheckNumOfPostedCheck and in the CheckNum
field
enter the criteria:
Between XXXStartCheckNum And XXX EndCheckNum

Note: You will have to determine how to write the actual criteria
based on where you get the first and last check#s.

4. At the database window, at the query tab, click on New. One of the

options will be Find Unmatched Query. Use this wizard to find the numbers in
QryAllPossibleCheckNum that are not in (unmatched) QryCheckNumOfPostedCheck. This new query will return all missing check numbers.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

"GSpiggle" <ga***@yahoo.com> wrote in message
news:de**************************@posting.google.c om...
> I have a database with records that should have a consecutive number
> ID (Check Register). Also has other records (deposits and adjusting
> entries) that don't fit in the number range so autonumbering isn't the > answer. I want to check to see if any check numbers are missing from > the register, but can't figure out how to accomplish it. Thanks for
> any help.


Nov 12 '05 #5
"CDB" <al***@delete.wave.co.nz> wrote in message news:<c5**********@news.wave.co.nz>...
It's a bit late for the original poster perhaps, but the following can also
be used:

Table: Ones
Field: Ordinal
Values: 0 - 9 (10 rows)

Table: CheckRegister
Field: CheckID
Values: 1117658 to 1117698 with a few deletions.

Query:
SELECT N.L AS Missing
FROM CheckRegister RIGHT JOIN [SELECT
111*10^4+[O3].[Ordinal]*10^3+[O2].[Ordinal]*10^2+[O1].[Ordinal]*10+[O0].[Ord
inal] AS L
FROM Ones AS O0, Ones AS O1, Ones AS O2, Ones AS O3
WHERE
(((111*10^4+[O3].[Ordinal]*10^3+[O2].[Ordinal]*10^2+[O1].[Ordinal]*10+[O0].[
Ordinal]) Between 1117658 And 1117698))]. AS N ON CheckRegister.CheckID =
N.L
WHERE (((CheckRegister.CheckID) Is Null));

The "Ones" have only a Cartesian join. This creates for seven places a
rather large initial resultset, requiring many seconds. So the generated
number has been shortened to 4 digits, with the common "111" set as a
constant value. The above takes less than a second to run (1.2GHz).


Wow. Or, you could write a few lines of code:

sub showmissing()

dim rst as recordset
dim intStart as integer
dim intEnd as integer
dim i as integer

set rst = currentdb.openrecordset("mytable", dbopendynaset)

for i = intStart to intEnd
rst.findfirst "CheckID = " & i
if rst.nomatch then debug.print "CheckID ";i;" not found."
next i

end sub
rst.close
Nov 12 '05 #6
CDB
Bruce, you are quite right, of course, but you understate your case
somewhat.

I avoid using code in an RDB if tables and queries will do the job.

My solution can be modified to run as a stored proc in SQLServer - no front
end activity.

My resultset can be used "as is" to source a form for the user. (Your code
requires more lines to get to that stage.)

Your code needs fixing and extending to bring it to a commercial level.
(More code, more lines.)

The posting was more of an illustration of creating a sequence of numbers in
SQL, rather than using the first responder's suggestion of a table with
"all" the required numbers. I use the n*10^x approach regularly eg for users
to "add a year of days" to a business calendar.

With all due deference to the ancient wise...

Clive

"Bruce" <br***@aristotle.net> wrote in message
news:d3**************************@posting.google.c om...
"CDB" <al***@delete.wave.co.nz> wrote in message

news:<c5**********@news.wave.co.nz>...
It's a bit late for the original poster perhaps, but the following can also be used:

Table: Ones
Field: Ordinal
Values: 0 - 9 (10 rows)

Table: CheckRegister
Field: CheckID
Values: 1117658 to 1117698 with a few deletions.

Query:
SELECT N.L AS Missing
FROM CheckRegister RIGHT JOIN [SELECT
111*10^4+[O3].[Ordinal]*10^3+[O2].[Ordinal]*10^2+[O1].[Ordinal]*10+[O0].[Ord inal] AS L
FROM Ones AS O0, Ones AS O1, Ones AS O2, Ones AS O3
WHERE
(((111*10^4+[O3].[Ordinal]*10^3+[O2].[Ordinal]*10^2+[O1].[Ordinal]*10+[O0].[ Ordinal]) Between 1117658 And 1117698))]. AS N ON CheckRegister.CheckID = N.L
WHERE (((CheckRegister.CheckID) Is Null));

The "Ones" have only a Cartesian join. This creates for seven places a
rather large initial resultset, requiring many seconds. So the generated
number has been shortened to 4 digits, with the common "111" set as a
constant value. The above takes less than a second to run (1.2GHz).


Wow. Or, you could write a few lines of code:

sub showmissing()

dim rst as recordset
dim intStart as integer
dim intEnd as integer
dim i as integer

set rst = currentdb.openrecordset("mytable", dbopendynaset)

for i = intStart to intEnd
rst.findfirst "CheckID = " & i
if rst.nomatch then debug.print "CheckID ";i;" not found."
next i

end sub
rst.close

Nov 12 '05 #7

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

Similar topics

4
by: PhilC | last post by:
Hi Folks, If I have an array holding a pair of numbers, and that pairing is unique, is there a way that I can find the array index number for that pair? Thanks, PhilC
3
by: peterbe | last post by:
In a text that contains references to numbers like this: #583 I want to find them with a regular expression but I'm having problems with the hash. Hopefully this code explains where I'm stuck: ...
6
by: GSpiggle | last post by:
I have a database with records that should have a consecutive number ID (Check Register). Also has other records (deposits and adjusting entries) that don't fit in the number range so...
32
by: someone else | last post by:
hi all I'm a newbie to this group. my apologies if I break any rules. I've wrote a simple program to find the first 1,000,000 primes, and to find all primes within any range (up to 200 *...
4
by: Kamran K | last post by:
Hello I have created a client server application using C#. Existing application is using random number on client side to generate sequence numbers that are then assigned to transactions. This...
5
by: Eric E | last post by:
Hi, I have a question about sequences. I need a field to have values with no holes in the sequence. However, the values do not need to be in order. My users will draw a number or numbers from...
13
by: athiane | last post by:
I want a way to parse out all function names that appear in a couple of C files. When the parsing logic finds a function name in a file, it should print out the Function name, line number and file...
2
by: raylopez99 | last post by:
Here is a short program demonstrating using IEnumberable, Linq, predicates, extension methods and some tricks and how to convert an IEnumberable sequence into an array. For future reference, not...
8
by: Slaunger | last post by:
Hi all, I am a Python novice, and I have run into a problem in a project I am working on, which boils down to identifying the patterns in a sequence of integers, for example ..... 1 6 6 1 6 6...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.