Hi
Have a look at the following:
http://www.fontstuff.com/access/acctut17.htm
Alternatively this is the short version
First create a query, Access doesn't let you create an "empty" query so you'll have to make something up (anything will do).
Now create a dialogue Form to collect the variable in this case the value of "n".
You can add to this form command button which will give you an event to run the VBA from.
Now use VBA to modify the query you saved earlier.
-
-
Dim strSQL, strVar As String
-
-
strVar = ‘Dialogue Form Control’
-
strSQL = "SELECT TOP " & strVar & " rest of SQL "
-
-
CurrentDb.QueryDefs("QueryName").SQL = strSQL
-
-
And that should do you. If you want to you can now open another form / report based on this query.