Hi Jerry -
Here is some (untested) code to try.
Code:
Dim SQL1 As string, SQL2 As String
Dim rst1 As Recordset, rst2 As Recordset
Dim db as Database
Dim DescriptionString As String
set db = CurrentDB
SQL1 = "Select Job, Suffix, Sequence, Description from YourTable " & _
" WHERE Sequence MOD 1000 = 0 order by Job, Suffix, Sequence"
'
' In rst1, each Job-Suffix-Sequence combination is unique
'
Set rst1 = db.OpenRecordset(SQL1)
While Not rst1.EOF
DescriptionString = rst1!Description
'
' Now get all the records in this group
'
SQL2 = "Select * from Yourtable where " & _
" Job = " & rst1!Job & " AND Suffix = " & rst1!Suffix & _
" AND Sequence \ 1000 = " & rst1!Sequence \ 1000 & _
" AND Sequence mod 1000 <> 0 order by Sequence"
set rst2=db.OpenRecordset(SQL2)
While Not rst2.EOF
'
' Concatenate the description
'
DescriptionString = DescriptionString & rst2!Description
rst2.MoveNext
Wend
'
' Add a record to the new table
' job=rst1!Job, Suffix=rst1!suffix, Sequence=rst1!Sequence, Description=DescriptionString
'
' Code to add a record goes here
rst1.MoveNext
Wend
rst1.Close
rst2.Close
set db = Nothing
The trickiest part is SQL2 - an example of it, once it's put together by the code, might be:
Select * from Yourtable where Job = 032456 AND Suffix = 001 AND Sequence \ 1000 = 1 AND Sequence mod 1000 <> 0 order by Sequence
The "\" operator is integer division : 1234 \ 1000 = 1
Quick question - are the job and prefix values numeric, or are they text strings that just look numeric? (i.e. what is their data type?)
Hope this helps you out.
John