First of all, there are some big hitters on here that know a very lot more about access than me - I might only be one page ahead (or behind) Alvis in the manual, but please don't have a pop at me for an inelegant solution. It's my best effort.
There I've apologised in advance.
Here goes then
Table1 is your data & looks like this
Field1ID
Field2
Notes:
1) Field1ID is an auto number PK field (doesn’t matter if some PK are deleted)
2) In my database Feild2 of every record is 1 (it’s a FK, I know it’ll never change) so unless you add a field with the number 1 in every record my method won’t work for you (it’s easy to add a field and make every record 1with an update query also set default to 1).
3) you can have whatever other fields you like in Table1 (Plus your other fields)
Query1 has three columns in the QBE Grid
Field: MyField1ID:Field1ID
Table: Table1
Total: Group By
Sort: LEAVE BLANK
Group By
Note: I have added an alias to the Field1ID above and called it MyField1ID: That’s so I can use MyField1ID and Field1ID in MyExpr below.
Field: Field2
Table: Table1
Sort: LEAVE BLANK
Total: Group By
Field: MyExpr: DSum(“Field2”,”Table1”,”Field1ID<=”[MyField1ID])
Table: LEAVE BLANK
Total: Expression
Sort :LEAVE BLANK
This query will number each line but MyExpr: comes back as a string not a number. I don’t know how to fix that right now, so I did this as a work around.
Query2
Field: MyField1ID
Table: Query1
Field: Field2
Table: Query1
Field: MyExpr:
Table: Query1
Field ValueExpr: Val(Query1.MyExpr])
Table: LEAVE BLANK
Note: Query2 last column simple makes MyExpr into a number (or Value) so that the criteria can be a number.
Criteria: It can be whatever number you like Say <=200 – will return the first 200 records
I am guessing you can have the criteria for ValueExpr read off a Form - something like
<=[Forms!form1,TextBox1]