Results 1 to 6 of 6
  1. #1
    Christine Boissoin is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2005
    Posts
    9

    Search for Next Available Number

    I have a table with the following values:

    182.11
    182.12
    182.13
    182.16

    I want my query to return 182.14 and/or 182.15 as available numbers for assignment. Is there any way to find missing numbers within a range of numbers?

    Thanks


    CB

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,728
    Could you provide context? What's with 2 decimal places?

  3. #3
    Christine Boissoin is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2005
    Posts
    9
    The numbers actually refer to an IP range - the "182." can be ignored. If the query could return just the 15 or 16 that would be sufficient.

    Thanks.
    cb

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,728
    I'm not fully understanding your situation and how it relates to a query. But, from the info supplied, I think you could create a function/subfunction to identify missing numbers.
    General logic.(not tested)
    sub testit()
    dim mStr as string
    Dim sMin as long
    Dim sMax as long
    sMin = DMin("YourField","YourTable")
    sMax = Dmax("YourField","YourTable")

    For x = sMin to sMax
    if dcount("*","yourtable","YourField = " & x) = 0 Then
    mstr = MStr & x & ","
    endif
    next x

    MsgBox " Values NOT in your table " & mStr

    End Sub
    good luck
    Last edited by orange; 10-05-2011 at 10:10 AM. Reason: spelling

  5. #5
    Christine Boissoin is offline Novice
    Windows XP Access 2010 64bit
    Join Date
    Jun 2005
    Posts
    9
    Thanks - this works perfectly.
    CB

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,728
    Glad to help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  2. Replies: 2
    Last Post: 08-31-2010, 08:57 PM
  3. Search a Number in Database Field
    By julia_877 in forum Programming
    Replies: 3
    Last Post: 08-06-2010, 01:24 PM
  4. Making New Record Number Next Numerical Number
    By jhillbrown in forum Access
    Replies: 1
    Last Post: 03-10-2010, 11:06 AM
  5. Sum Of Positive Number and Negative Number
    By maysamab in forum Reports
    Replies: 1
    Last Post: 10-20-2008, 04:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums