Finding out of sequence numbers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • GSpiggle

    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.
  • PC Datasheet

    #2
    Re: Finding out of sequence numbers

    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 QryAllPossibleC heckNum based on the numbers table and in
    the numbers field enter the criteria:
    Between XXXStartCheckNu m And XXX EndCheckNum

    3. Build a query named QryCheckNumOfPo stedCheck and in the CheckNum field enter
    the criteria:
    Between XXXStartCheckNu m 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
    QryAllPossibleC heckNum that are not in (unmatched) QryCheckNumOfPo stedCheck.
    This new query will return all missing check numbers.

    --
    PC Datasheet
    Your Resource For Help With Access, Excel And Word Applications
    resource@pcdata sheet.com




    "GSpiggle" <gas43@yahoo.co m> wrote in message
    news:defd9fab.0 404121357.363c9 b6a@posting.goo gle.com...[color=blue]
    > 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.[/color]


    Comment

    • GSpiggle

      #3
      Re: Finding out of sequence numbers

      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" <spam@nospam.sp am> wrote in message news:<BPEec.577 0$zj3.1654@news read3.news.atl. earthlink.net>. ..[color=blue]
      > 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 QryAllPossibleC heckNum based on the numbers table and in
      > the numbers field enter the criteria:
      > Between XXXStartCheckNu m And XXX EndCheckNum
      >
      > 3. Build a query named QryCheckNumOfPo stedCheck and in the CheckNum field enter
      > the criteria:
      > Between XXXStartCheckNu m 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
      > QryAllPossibleC heckNum that are not in (unmatched) QryCheckNumOfPo stedCheck.
      > This new query will return all missing check numbers.
      >
      > --
      > PC Datasheet
      > Your Resource For Help With Access, Excel And Word Applications
      > resource@pcdata sheet.com
      > www.pcdatasheet.com
      >
      >
      >
      > "GSpiggle" <gas43@yahoo.co m> wrote in message
      > news:defd9fab.0 404121357.363c9 b6a@posting.goo gle.com...[color=green]
      > > 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.[/color][/color]

      Comment

      • PC Datasheet

        #4
        Re: Finding out of sequence numbers

        Thanks for the courtesy of a thank you!!

        Steve


        "GSpiggle" <gas43@yahoo.co m> wrote in message
        news:defd9fab.0 404130631.49b40 da2@posting.goo gle.com...[color=blue]
        > 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" <spam@nospam.sp am> wrote in message[/color]
        news:<BPEec.577 0$zj3.1654@news read3.news.atl. earthlink.net>. ..[color=blue][color=green]
        > > 1. Build a table of numbers that starts with the first check# in the[/color][/color]
        checking[color=blue][color=green]
        > > account and goes to what you anticipate will be the highest check number[/color][/color]
        ever[color=blue][color=green]
        > > used in the account. You can easily generate the numbers in Excel and then
        > > import into an Access table.
        > >
        > > 2. Build a query named QryAllPossibleC heckNum based on the numbers table[/color][/color]
        and in[color=blue][color=green]
        > > the numbers field enter the criteria:
        > > Between XXXStartCheckNu m And XXX EndCheckNum
        > >
        > > 3. Build a query named QryCheckNumOfPo stedCheck and in the CheckNum field[/color][/color]
        enter[color=blue][color=green]
        > > the criteria:
        > > Between XXXStartCheckNu m 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[/color][/color]
        options[color=blue][color=green]
        > > will be Find Unmatched Query. Use this wizard to find the numbers in
        > > QryAllPossibleC heckNum that are not in (unmatched) QryCheckNumOfPo stedCheck.
        > > This new query will return all missing check numbers.
        > >
        > > --
        > > PC Datasheet
        > > Your Resource For Help With Access, Excel And Word Applications
        > > resource@pcdata sheet.com
        > > www.pcdatasheet.com
        > >
        > >
        > >
        > > "GSpiggle" <gas43@yahoo.co m> wrote in message
        > > news:defd9fab.0 404121357.363c9 b6a@posting.goo gle.com...[color=darkred]
        > > > 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.[/color][/color][/color]


        Comment

        • CDB

          #5
          Re: Finding out of sequence numbers

          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.C heckID =
          N.L
          WHERE (((CheckRegiste r.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" <spam@nospam.sp am> wrote in message
          news:oJVec.6025 $l75.3973@newsr ead2.news.atl.e arthlink.net...[color=blue]
          > Thanks for the courtesy of a thank you!!
          >
          > Steve
          >
          >
          > "GSpiggle" <gas43@yahoo.co m> wrote in message
          > news:defd9fab.0 404130631.49b40 da2@posting.goo gle.com...[color=green]
          > > 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" <spam@nospam.sp am> wrote in message[/color]
          > news:<BPEec.577 0$zj3.1654@news read3.news.atl. earthlink.net>. ..[color=green][color=darkred]
          > > > 1. Build a table of numbers that starts with the first check# in the[/color][/color]
          > checking[color=green][color=darkred]
          > > > account and goes to what you anticipate will be the highest check[/color][/color][/color]
          number[color=blue]
          > ever[color=green][color=darkred]
          > > > used in the account. You can easily generate the numbers in Excel and[/color][/color][/color]
          then[color=blue][color=green][color=darkred]
          > > > import into an Access table.
          > > >
          > > > 2. Build a query named QryAllPossibleC heckNum based on the numbers[/color][/color][/color]
          table[color=blue]
          > and in[color=green][color=darkred]
          > > > the numbers field enter the criteria:
          > > > Between XXXStartCheckNu m And XXX EndCheckNum
          > > >
          > > > 3. Build a query named QryCheckNumOfPo stedCheck and in the CheckNum[/color][/color][/color]
          field[color=blue]
          > enter[color=green][color=darkred]
          > > > the criteria:
          > > > Between XXXStartCheckNu m And XXX EndCheckNum
          > > >
          > > > Note: You will have to determine how to write the actual criteria[/color][/color][/color]
          based on[color=blue][color=green][color=darkred]
          > > > where you get the first and last check#s.
          > > >
          > > > 4. At the database window, at the query tab, click on New. One of the[/color][/color]
          > options[color=green][color=darkred]
          > > > will be Find Unmatched Query. Use this wizard to find the numbers in
          > > > QryAllPossibleC heckNum that are not in (unmatched)[/color][/color][/color]
          QryCheckNumOfPo stedCheck.[color=blue][color=green][color=darkred]
          > > > This new query will return all missing check numbers.
          > > >
          > > > --
          > > > PC Datasheet
          > > > Your Resource For Help With Access, Excel And Word Applications
          > > > resource@pcdata sheet.com
          > > > www.pcdatasheet.com
          > > >
          > > >
          > > >
          > > > "GSpiggle" <gas43@yahoo.co m> wrote in message
          > > > news:defd9fab.0 404121357.363c9 b6a@posting.goo gle.com...
          > > > > 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[/color][/color][/color]
          the[color=blue][color=green][color=darkred]
          > > > > answer. I want to check to see if any check numbers are missing[/color][/color][/color]
          from[color=blue][color=green][color=darkred]
          > > > > the register, but can't figure out how to accomplish it. Thanks for
          > > > > any help.[/color][/color]
          >
          >[/color]


          Comment

          • Bruce

            #6
            Re: Finding out of sequence numbers

            "CDB" <alpha@delete.w ave.co.nz> wrote in message news:<c5hpe3$nt v$1@news.wave.c o.nz>...[color=blue]
            > 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.C heckID =
            > N.L
            > WHERE (((CheckRegiste r.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).[/color]

            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.openr ecordset("mytab le", 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

            Comment

            • CDB

              #7
              Re: Finding out of sequence numbers

              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" <bruce@aristotl e.net> wrote in message
              news:d3b3c84d.0 404141204.7657a 08e@posting.goo gle.com...[color=blue]
              > "CDB" <alpha@delete.w ave.co.nz> wrote in message[/color]
              news:<c5hpe3$nt v$1@news.wave.c o.nz>...[color=blue][color=green]
              > > It's a bit late for the original poster perhaps, but the following can[/color][/color]
              also[color=blue][color=green]
              > > 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
              > >[/color][/color]
              111*10^4+[O3].[Ordinal]*10^3+[O2].[Ordinal]*10^2+[O1].[Ordinal]*10+[O0].[Ord[color=blue][color=green]
              > > inal] AS L
              > > FROM Ones AS O0, Ones AS O1, Ones AS O2, Ones AS O3
              > > WHERE
              > >[/color][/color]
              (((111*10^4+[O3].[Ordinal]*10^3+[O2].[Ordinal]*10^2+[O1].[Ordinal]*10+[O0].[[color=blue][color=green]
              > > Ordinal]) Between 1117658 And 1117698))]. AS N ON CheckRegister.C heckID[/color][/color]
              =[color=blue][color=green]
              > > N.L
              > > WHERE (((CheckRegiste r.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).[/color]
              >
              > 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.openr ecordset("mytab le", 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[/color]


              Comment

              Working...