Results 1 to 6 of 6
  1. #1
    Join Date
    May 2003
    Location
    UK
    Posts
    233

    Unanswered: Last record in a table

    Hi,

    Can anyone tell me :-

    How do I create and append query that takes only the last record from a table.?

    Many thanks

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi

    There is no intrinsic stamp in Access to identify the last record so unless you use an incrementing Autonumber or something else that identifies the order that records were inserted you are a bit stuck I am afraid

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Oct 2005
    Posts
    15
    HTH is right. I would add a column to your table and make the Data Type 'AUTO NUMBER' then just right a query off of that table using "Max([AUTO NUMBER ])" This is the only way I know of pulling the last record off of a table.
    Hope this helps.
    Mike

  4. #4
    Join Date
    Apr 2005
    Posts
    89
    Or you can probably make a RECORDSET with a .Movelast

    LIKE
    DIM rs AS YOURTYPE.Recordset

    rs = SELECT * FROM MYTABLE

    rs.EXECUTE

    AND do a rs.Movelast this will take you to the last record
    Shelbygt22
    The solution is probably in your face
    but you dont see it !

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by mmetzler
    HTH is right. I would add a column to your table and make the Data Type 'AUTO NUMBER' then just right a query off of that table using "Max([AUTO NUMBER ])" This is the only way I know of pulling the last record off of a table.
    Hope this helps.
    Mike
    Nope - HTH is wrong. Use a correlated SubQ and the Last agg function e.g.

    Code:
     Select MyPK, MyDets 
    FROM MyT
    WHERE MyPK = (SELECT LAST(MyPK) FROM MyT)
    HTH = Hope This Helps BTW

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    May 2003
    Location
    UK
    Posts
    233
    Thanks very much -

    I chose the Max Autonumber option - works perfectly -

    Thanks again

Posting Permissions

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