details expressed as ranges of values in a report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • StuartD
    New Member
    • Oct 2008
    • 4

    details expressed as ranges of values in a report

    I've created a physical inventory database for my company that creates and manages the serialized count sheets used during the inventory process. I'm struggling with an idea for the audit log that gets generated at the very end. Rather than listing all the count sheets by number for each inventory location, I'd prefer to save space and express the the count sheets in ranges. In this way, instead of listing:

    00001
    00002
    00003
    00004
    00005
    00015
    00016
    00017
    00018

    I could list:

    00001-00005
    00015-00018

    I was thinking I could save the first sheet of a range, loop through the sheet numbers and compare the last with the next until the two weren't contiguous, save the last, and repeat until all sheets for a given location were processed. One of the issues I see with this approach is having to set static variables for all the possible start/end sheet ranges...is there a way to set variables dynamically to avoid the static route?

    Backing up a minute, is there a better way?

    Thanks in advance?
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    I would expect this to be done using a Recordset. Queries don't really have any concept of next or previous. They are a set. It could be done in SQL if there were a way to identify each grouping (See example SQL below), but I'm afraid I see no way to identify them as a group.
    Code:
    SELECT   Min([Value]) & ('' + IIf(Min([Value]) = Max([Value]), Null, Max([Value])) AS [Range]
    FROM     [Table]
    GROUP BY [Some grouping value]
    For want of that grouping, a recordset could be used to determine the output values, but only if they are added to some temporary table, and later queried, can they be output as a query of any sort.

    Interesting question though ;-)

    Comment

    Working...