View Full Version : Retrieving X number of records


Anauz
02-09-2001, 08:00 AM
Hi

I have a form where the user enters a number x), I want to use this number to return the first X records in a query. Is this possible....if so can anyone help?

Thanx in advance

ntp
02-10-2001, 06:28 AM
Modify your query like this:

original query:
SELECT field1, field2 FROM qrySample
New query:
SELECT TOP X field1, field2 FROM qrySample ORDER BY field1

The new query returns the first X records returned when the queryis sorted by field1.

ntp

Anauz
02-11-2001, 07:28 AM
Thats great, thanks very much. Is there a way i can pass the parameter X to the query so it returns X records?

Pat Hartman
02-11-2001, 12:56 PM
No. You can't pass the max number as a variable. You'd need to create the query in code so Access can parse it for you.