I have an Access97 database (unfortunately) and I am querying it over ODBC.
I want to construct a query that will return me J ordered rows starting at offset K. Right now for a related operation I am using a sub-query and the TOP keyword, this works fine but I don’t think I can use it for this new operation I am trying to perform. I am wanting to do this because I want to add some form of paging to some software.
Ideally the user interface should be able to say, give me 50 records, starting at record 150, sorted by the date column.
Any help would be appreciated.
You’re basically trying to mimic ROW_NUMBER() in Access. Unfortunately, Access is not a good engine for doing this kind of thing. It gets dog slow after a hundred or so records.
With that said, here’s what you can do:
That will produce this resultset (in my particular table):
I would make a saved query in Access (a view in a SQL Server) and then write a query like this in your application:
Of course, “5” & “11” you would pass in from your client app, and would be based on the particular page you’re on. (It would probably be 50 and 100 or something for you).