By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,483 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,483 IT Pros & Developers. It's quick & easy.

Finding out of sequence numbers

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.