Retrieving X number of records (1 Viewer)

Anauz

Registered User.
Local time
Today, 22:25
Joined
Nov 14, 2000
Messages
81
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

Registered User.
Local time
Today, 22:25
Joined
Jan 7, 2001
Messages
74
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

Registered User.
Local time
Today, 22:25
Joined
Nov 14, 2000
Messages
81
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

Super Moderator
Staff member
Local time
Today, 18:25
Joined
Feb 19, 2002
Messages
42,976
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.
 

Users who are viewing this thread

Top Bottom