Skip to content
Advertisement

Select Top X records starting at record Y

I am using MS Access VBA to make a few queries. I have a list of about 4000 items and I need query 1 to be the top 739 items and query 2 to be the top 428 items starting at record 740 and I need query 3 to be the rest starting at record 1168.

is there any way to do this?

Thank you.

Advertisement

Answer

First, create a query that will assign an ID to each record using one of the methods listed in my project VBA.RowNumbers.

The function RowNumber may fit you.

You will have to use a compound key (say, Field1 & "|" & Field2 & "|" & Field9) to obtain something unique, or you can’t do this.

Then run these queries:

Select * From YourQuery
Where ID Between 1 And 739

Select * From YourQuery
Where ID Between 740 And 1167

Select * From YourQuery
Where ID >= 1168
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement