Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    15

    Unanswered: "Last" Function in Query

    I have a query that uses the last function to retreive the last record entered in a table. It worked well for 2 months but all of a sudden it has gotten stuck on one record and won't show any records after 311 even though there are another 100 entries in the table after record 311.

    This is the SQL that is used:

    SELECT Last(Receipts.[Receipt No]) AS [LastOfReceipt No]
    FROM Receipts;

    If anyone has any ideas about this or know another more reliable way to retrieve the last record from a table can you please help.

    Cheers

  2. #2
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    Try ordering by ReceiptNo

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by rogue
    Try ordering by ReceiptNo
    And rogue is pointing out differing ways to get what you want ... Assuming that Receipt # is sequential and increasing, you can also get the LAST record by doing a query like:

    SELECT TOP 1 [Receipt No] FROM Receipts ORDER BY [Receipt No] DESC;
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Jul 2006
    Posts
    15
    Thanks for the responses, I already had it "ordered by" and it didnt work but that "top 1" worked perfectly thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •