MS Query Limit results

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a query in an Excel worksheet. I am unable to limit the returned data. The query currently returns 25 records. I only want 20. I am able to sort the records in the query, and even limit the data returned on the edit query page, by using the 'options' menu and limiting the recurods returned to 20, but when I return the data to Excel, the query returns the full set of data to the spreadsheet. I have VB code that is looking in specific cells for the data returned, so i can't just have the query insert cells. The query is set to overwrite existing data and clear unused cells. I would change the Code but It would take several days as the code is several thousand lines, and I didn't write it. It is undocumented, and not very well written. It would be much faster to be able to limit the return of data from the Query.
 
In your query builder change the viewto SQL and inbetween
SELECT Field1, Field2, put TOP 20 so it reads SELECT TOP
20 Field1, Field2

regards
KM
-----Original Message-----
I have a query in an Excel worksheet. I am unable to
limit the returned data. The query currently returns 25
records. I only want 20. I am able to sort the records
in the query, and even limit the data returned on the edit
query page, by using the 'options' menu and limiting the
recurods returned to 20, but when I return the data to
Excel, the query returns the full set of data to the
spreadsheet. I have VB code that is looking in specific
cells for the data returned, so i can't just have the
query insert cells. The query is set to overwrite
existing data and clear unused cells. I would change the
Code but It would take several days as the code is several
thousand lines, and I didn't write it. It is
undocumented, and not very well written. It would be much
faster to be able to limit the return of data from the
Query.
 
Thank you for replying. I am using parameters in my query, these are values that are stored on the excel sheet, on which these queries live. These parameters change each time the workbook is opened, based on the current date. It is not possible to hard code this data into the queries. If there is not a method for this, I will have to look at a rewrite :( But thats the way the cookie crumbles
 
Back
Top